@mnstry/atelier 0.2.0-alpha.1

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 (260) hide show
  1. package/CHANGELOG.md +383 -0
  2. package/LICENSE +202 -0
  3. package/NOTICE +5 -0
  4. package/README.md +262 -0
  5. package/SECURITY.md +93 -0
  6. package/TRADEMARKS.md +88 -0
  7. package/announcements/2026-08-06-announcements-channel.v1.json +12 -0
  8. package/announcements/keys/mnstry-announcements.public.v1.json +9 -0
  9. package/bin/atelier.mjs +2 -0
  10. package/bin/mnstry-atelier.mjs +3 -0
  11. package/contracts/analysis-adapter.v1.schema.json +248 -0
  12. package/contracts/atelier-action-intent.v1.schema.json +143 -0
  13. package/contracts/atelier-analysis-adapter.v1.schema.json +360 -0
  14. package/contracts/atelier-attestation.v1.schema.json +239 -0
  15. package/contracts/atelier-boundary-policy.v1.schema.json +339 -0
  16. package/contracts/atelier-claim.v1.schema.json +97 -0
  17. package/contracts/atelier-export.v1.schema.json +1015 -0
  18. package/contracts/atelier-extension-pack.v1.schema.json +290 -0
  19. package/contracts/atelier-kit-manifest.v1.schema.json +273 -0
  20. package/contracts/atelier-lock.v1.schema.json +364 -0
  21. package/contracts/atelier-migration.v1.schema.json +162 -0
  22. package/contracts/atelier-project-config.v1.schema.json +352 -0
  23. package/contracts/atelier-readiness-protocol.v1.schema.json +517 -0
  24. package/contracts/atelier-readiness-run.v1.schema.json +229 -0
  25. package/contracts/atelier-readiness.v1.schema.json +457 -0
  26. package/contracts/compat-baseline.json +10 -0
  27. package/contracts/git-promote-event.v1.schema.json +145 -0
  28. package/contracts/knowledge-source-sidecar.v1.schema.json +157 -0
  29. package/contracts/mnstry-atelier-semantic-profile.v1.json +254 -0
  30. package/docs/announcements.md +101 -0
  31. package/docs/atelier-runtime.md +34 -0
  32. package/docs/attestation.md +201 -0
  33. package/docs/continuity.md +55 -0
  34. package/docs/contract-stability.md +111 -0
  35. package/docs/distributions.md +220 -0
  36. package/docs/install.md +140 -0
  37. package/docs/knowledge-graph.md +140 -0
  38. package/docs/ontology.md +206 -0
  39. package/docs/release-engineering.md +151 -0
  40. package/docs/repo-boundary-guard.md +199 -0
  41. package/docs/tenant-readiness.md +64 -0
  42. package/docs/upgrade.md +124 -0
  43. package/fixtures/analysis/invalid/native-graph.v1.json +4 -0
  44. package/fixtures/analysis/invalid/promoted-claim.v1.json +17 -0
  45. package/fixtures/analysis/invalid/runtime-import.v1.json +20 -0
  46. package/fixtures/analysis/valid/output.claims.v1.json +17 -0
  47. package/fixtures/analysis-adapter/invalid/manifest-hidden-provider.v1.json +24 -0
  48. package/fixtures/analysis-adapter/invalid/output-frontmatter-mutation.v1.json +21 -0
  49. package/fixtures/analysis-adapter/invalid/output-native-graph.v1.json +14 -0
  50. package/fixtures/analysis-adapter/manifest.disabled.v1.json +22 -0
  51. package/fixtures/analysis-adapter/manifest.enabled-local.v1.json +23 -0
  52. package/fixtures/analysis-adapter/output.claims.v1.json +21 -0
  53. package/fixtures/atelier-action-intent/invalid/runtime-mutation-authority.v1.json +16 -0
  54. package/fixtures/atelier-action-intent/invalid/unknown-top-level-field.v1.json +17 -0
  55. package/fixtures/atelier-action-intent/invalid/writes-beyond-clipboard.v1.json +16 -0
  56. package/fixtures/atelier-action-intent/valid/copy-agent-prompt.v1.json +16 -0
  57. package/fixtures/atelier-action-intent/valid/copy-repo-path.v1.json +22 -0
  58. package/fixtures/atelier-analysis-adapter/invalid/hidden-model-provider.v1.json +24 -0
  59. package/fixtures/atelier-analysis-adapter/invalid/inert-with-execute-command.v1.json +24 -0
  60. package/fixtures/atelier-analysis-adapter/invalid/proposals-with-runtime-import.v1.json +30 -0
  61. package/fixtures/atelier-analysis-adapter/valid/manifest-inert.v1.json +24 -0
  62. package/fixtures/atelier-analysis-adapter/valid/proposals-claim-only.v1.json +27 -0
  63. package/fixtures/atelier-attestation/invalid/bad-digest.v1.json +23 -0
  64. package/fixtures/atelier-attestation/invalid/conformance-scope.v1.json +23 -0
  65. package/fixtures/atelier-attestation/invalid/missing-signature.v1.json +22 -0
  66. package/fixtures/atelier-attestation/invalid/unknown-root-field.v1.json +24 -0
  67. package/fixtures/atelier-attestation/keys/roundtrip-issuer.public.v1.json +9 -0
  68. package/fixtures/atelier-attestation/valid/rejected-with-reasons.v1.json +49 -0
  69. package/fixtures/atelier-attestation/valid/signed-admitted.v1.json +35 -0
  70. package/fixtures/atelier-attestation/valid/signed-roundtrip.v1.json +29 -0
  71. package/fixtures/atelier-attestation/valid/unsigned-advisory.v1.json +23 -0
  72. package/fixtures/atelier-claim/invalid/unknown-provider.v1.json +15 -0
  73. package/fixtures/atelier-claim/invalid/unknown-top-level-field.v1.json +16 -0
  74. package/fixtures/atelier-claim/invalid/wrong-schema-const.v1.json +15 -0
  75. package/fixtures/atelier-claim/valid/adapter-style-proposed-relation.v1.json +19 -0
  76. package/fixtures/atelier-claim/valid/codex-proposed-relation.v1.json +16 -0
  77. package/fixtures/atelier-claim/valid/manual-proposed-relation.v1.json +16 -0
  78. package/fixtures/atelier-claim/valid/readiness-proposed-relation.v1.json +18 -0
  79. package/fixtures/atelier-export/invalid/dirty-unforced-empty-taint.v1.json +19 -0
  80. package/fixtures/atelier-export/invalid/object-local-audience-visibility.v1.json +11 -0
  81. package/fixtures/atelier-export/invalid/open-object-class-owner.v1.json +23 -0
  82. package/fixtures/atelier-export/invalid/pricing-legacy-amount.v1.json +23 -0
  83. package/fixtures/atelier-export/invalid/public-disguised-internal-source-ref.v1.json +11 -0
  84. package/fixtures/atelier-export/invalid/public-nested-private-source-ref.v1.json +17 -0
  85. package/fixtures/atelier-export/invalid/public-resolved-private-source-ref.v1.json +13 -0
  86. package/fixtures/atelier-export/invalid/public-resolved-sensitive-source-ref.v1.json +13 -0
  87. package/fixtures/atelier-export/invalid/public-source-ref-missing-provenance.v1.json +20 -0
  88. package/fixtures/atelier-export/invalid/public-source-team-kg.json +12 -0
  89. package/fixtures/atelier-export/invalid/source-node-legacy-visibility.v1.json +21 -0
  90. package/fixtures/atelier-export/invalid/source-node-unknown-field.v1.json +18 -0
  91. package/fixtures/atelier-export/invalid/unresolved-public-source-ref.v1.json +11 -0
  92. package/fixtures/atelier-export/sample-studio-offer.v1.json +397 -0
  93. package/fixtures/atelier-extension-pack/invalid/bundled-slug-collision.v1.json +22 -0
  94. package/fixtures/atelier-extension-pack/invalid/escapes-root.v1.json +22 -0
  95. package/fixtures/atelier-extension-pack/invalid/posture-tampered.v1.json +22 -0
  96. package/fixtures/atelier-extension-pack/invalid/protocols/autonomous-authority.v1.json +118 -0
  97. package/fixtures/atelier-extension-pack/invalid/protocols/offer-map.v1.json +109 -0
  98. package/fixtures/atelier-extension-pack/invalid/redefines-runtime-term.v1.json +19 -0
  99. package/fixtures/atelier-extension-pack/invalid/wrong-namespace.v1.json +19 -0
  100. package/fixtures/atelier-extension-pack/valid/protocols/contract-gate.v1.json +109 -0
  101. package/fixtures/atelier-extension-pack/valid/sample-pack.v1.json +48 -0
  102. package/fixtures/atelier-kit-manifest/invalid/runtime-copy-without-canonical-role.v1.json +53 -0
  103. package/fixtures/atelier-kit-manifest/invalid/telemetry-send-path.v1.json +21 -0
  104. package/fixtures/atelier-kit-manifest/valid/mnstry-atelier.valid.v1.json +76 -0
  105. package/fixtures/atelier-lock/invalid/absolute-contract-path.v1.json +40 -0
  106. package/fixtures/atelier-lock/invalid/runtime-mutation-enabled.v1.json +41 -0
  107. package/fixtures/atelier-lock/invalid/unknown-top-level-field.v1.json +42 -0
  108. package/fixtures/atelier-lock/valid/extension-pack.v1.json +55 -0
  109. package/fixtures/atelier-lock/valid/minimal.v1.json +44 -0
  110. package/fixtures/atelier-migration/invalid/live-apply-mode.v1.json +21 -0
  111. package/fixtures/atelier-migration/invalid/missing-review-evidence.v1.json +20 -0
  112. package/fixtures/atelier-migration/invalid/runtime-mutation-enabled.v1.json +21 -0
  113. package/fixtures/atelier-migration/valid/minimal.v1.json +32 -0
  114. package/fixtures/atelier-project-config/invalid/absolute-repo-path.v1.json +11 -0
  115. package/fixtures/atelier-project-config/invalid/ext-not-object.v1.json +12 -0
  116. package/fixtures/atelier-project-config/invalid/external-kind-read-boundary.v1.json +12 -0
  117. package/fixtures/atelier-project-config/invalid/missing-repos-and-alignment.v1.json +7 -0
  118. package/fixtures/atelier-project-config/invalid/unknown-top-level-field.v1.json +14 -0
  119. package/fixtures/atelier-project-config/valid/alignment-scaffold.v1.json +15 -0
  120. package/fixtures/atelier-project-config/valid/ext-extension-packs.v1.json +36 -0
  121. package/fixtures/atelier-project-config/valid/repo-workspace.v1.json +23 -0
  122. package/fixtures/atelier-project-config/validator-only/ext-member-not-object.v1.json +14 -0
  123. package/fixtures/atelier-readiness/invalid/dry-run-only-false.v1.json +87 -0
  124. package/fixtures/atelier-readiness/invalid/support-bundle-send-path.v1.json +87 -0
  125. package/fixtures/atelier-readiness/invalid/unknown-top-level-field.v1.json +88 -0
  126. package/fixtures/atelier-readiness/valid/ready-workspace.v1.json +84 -0
  127. package/fixtures/boundary-policy/invalid/content-rule-exception-blanket-path.v1.json +67 -0
  128. package/fixtures/boundary-policy/invalid/invalid-actor-private-repo-mapping.v1.json +20 -0
  129. package/fixtures/boundary-policy/invalid/legacy-warning-missing-warning.v1.json +20 -0
  130. package/fixtures/boundary-policy/invalid/missing-repo-coverage.v1.json +19 -0
  131. package/fixtures/boundary-policy/invalid/unknown-key.v1.json +12 -0
  132. package/fixtures/boundary-policy/valid/content-rule-exception.v1.json +67 -0
  133. package/fixtures/boundary-policy/valid/legacy-warning.v1.json +33 -0
  134. package/fixtures/boundary-policy/valid/strict-private-shared.v1.json +40 -0
  135. package/fixtures/git-promote/invalid/provision-named-revocable.v1.json +29 -0
  136. package/fixtures/git-promote/private-to-team.v1.json +29 -0
  137. package/fixtures/knowledge-source-sidecar/invalid/legacy-visibility-field.v1.json +17 -0
  138. package/fixtures/knowledge-source-sidecar/invalid/missing-audience.v1.json +15 -0
  139. package/fixtures/knowledge-source-sidecar/invalid/unknown-relation-kind.v1.json +18 -0
  140. package/fixtures/knowledge-source-sidecar/valid/html-source.v1.json +18 -0
  141. package/fixtures/knowledge-source-sidecar/valid/pdf-evidence.v1.json +18 -0
  142. package/fixtures/projects/neutral-project/atelier.project.json +15 -0
  143. package/fixtures/projects/neutral-project/ops/config/repo-access.v1.json +12 -0
  144. package/fixtures/projects/neutral-project/project-knowledge.graph.json +69 -0
  145. package/fixtures/projects/sample-workspace/atelier.project.json +23 -0
  146. package/fixtures/projects/sample-workspace/boundary-policy.v1.json +59 -0
  147. package/fixtures/projects/sample-workspace/content/README.md +16 -0
  148. package/fixtures/projects/sample-workspace/content/source.html +5 -0
  149. package/fixtures/projects/sample-workspace/content/source.html.kg.json +15 -0
  150. package/fixtures/projects/sample-workspace/repo-access.v1.json +9 -0
  151. package/fixtures/projects/source-formats-workspace/atelier.project.json +23 -0
  152. package/fixtures/projects/source-formats-workspace/content/README.md +17 -0
  153. package/fixtures/projects/source-formats-workspace/content/data.json +7 -0
  154. package/fixtures/projects/source-formats-workspace/content/data.json.kg.json +15 -0
  155. package/fixtures/projects/source-formats-workspace/content/logo.png.kg.json +15 -0
  156. package/fixtures/projects/source-formats-workspace/content/metrics.csv +3 -0
  157. package/fixtures/projects/source-formats-workspace/content/metrics.csv.kg.json +15 -0
  158. package/fixtures/projects/source-formats-workspace/content/pipeline.yaml +4 -0
  159. package/fixtures/projects/source-formats-workspace/content/pipeline.yaml.kg.json +15 -0
  160. package/fixtures/projects/source-formats-workspace/repo-access.v1.json +9 -0
  161. package/fixtures/readiness-protocols/extension-pack/invalid/protocol-missing-path.v1.json +20 -0
  162. package/fixtures/readiness-protocols/extension-pack/valid/with-protocol.v1.json +24 -0
  163. package/fixtures/readiness-protocols/protocol/invalid/missing-check-target.v1.json +103 -0
  164. package/fixtures/readiness-protocols/protocol/invalid/runtime-mutation-enabled.v1.json +107 -0
  165. package/fixtures/readiness-protocols/protocol/valid/minimal.v1.json +100 -0
  166. package/fixtures/readiness-protocols/run/invalid/missing-evidence.v1.json +37 -0
  167. package/fixtures/readiness-protocols/run/invalid/pass-with-blocker.v1.json +22 -0
  168. package/fixtures/readiness-protocols/run/invalid/runtime-mutation-enabled.v1.json +22 -0
  169. package/fixtures/readiness-protocols/run/valid/pass.v1.json +44 -0
  170. package/fixtures/support/invalid/leaky-support.v1.json +13 -0
  171. package/fixtures/support/valid/minimal-safe.v1.json +20 -0
  172. package/package.json +98 -0
  173. package/skills/claude/atelier-open/SKILL.md +68 -0
  174. package/skills/claude/mnstry-readiness/SKILL.md +41 -0
  175. package/skills/codex/atelier-open/SKILL.md +68 -0
  176. package/skills/codex/mnstry-readiness/SKILL.md +41 -0
  177. package/src/analysis/adapter.mjs +20 -0
  178. package/src/analysis/analysis-claim-contract.mjs +335 -0
  179. package/src/attestation/jcs.mjs +64 -0
  180. package/src/attestation/sign.mjs +305 -0
  181. package/src/boundary/content-rules.mjs +262 -0
  182. package/src/boundary/policy.mjs +806 -0
  183. package/src/check-atelier-export-contract.mjs +116 -0
  184. package/src/cli/run.mjs +283 -0
  185. package/src/collaboration/proposals.mjs +262 -0
  186. package/src/commands/analysis.mjs +8 -0
  187. package/src/commands/announcements.mjs +308 -0
  188. package/src/commands/attestation.mjs +198 -0
  189. package/src/commands/boundary.mjs +25 -0
  190. package/src/commands/config.mjs +4 -0
  191. package/src/commands/context.mjs +3 -0
  192. package/src/commands/distribution.mjs +224 -0
  193. package/src/commands/egress.mjs +11 -0
  194. package/src/commands/extension-pack.mjs +209 -0
  195. package/src/commands/feedback.mjs +3 -0
  196. package/src/commands/graph.mjs +3 -0
  197. package/src/commands/init.mjs +130 -0
  198. package/src/commands/lock.mjs +3 -0
  199. package/src/commands/project.mjs +3 -0
  200. package/src/commands/promote.mjs +4 -0
  201. package/src/commands/readiness.mjs +3 -0
  202. package/src/commands/server.mjs +6 -0
  203. package/src/commands/setup.mjs +250 -0
  204. package/src/commands/support.mjs +3 -0
  205. package/src/commands/upgrade.mjs +3 -0
  206. package/src/contracts/corpus.mjs +171 -0
  207. package/src/egress/check.mjs +45 -0
  208. package/src/egress/forbidden-egress.mjs +323 -0
  209. package/src/export/atelier-export-contract.mjs +722 -0
  210. package/src/extension-packs/loader.mjs +491 -0
  211. package/src/graph/graph.mjs +370 -0
  212. package/src/graph/knowledge-graph.mjs +887 -0
  213. package/src/harness/context-client.mjs +144 -0
  214. package/src/harness/context.mjs +27 -0
  215. package/src/index.mjs +88 -0
  216. package/src/project/config.mjs +557 -0
  217. package/src/project/file-class.mjs +113 -0
  218. package/src/project/git-ignore.mjs +31 -0
  219. package/src/project/path-match.mjs +30 -0
  220. package/src/project/repo-identity.mjs +176 -0
  221. package/src/projection/alignment-projection.mjs +169 -0
  222. package/src/projection/policy.mjs +90 -0
  223. package/src/projection/project.mjs +152 -0
  224. package/src/readiness/readiness.mjs +312 -0
  225. package/src/readiness-protocols/bundled-pack.mjs +766 -0
  226. package/src/readiness-protocols/runtime.mjs +419 -0
  227. package/src/server/local-sidecar.mjs +640 -0
  228. package/src/server/security.mjs +229 -0
  229. package/src/server/server.mjs +42 -0
  230. package/src/support/feedback-report.mjs +414 -0
  231. package/src/support/support-bundle.mjs +226 -0
  232. package/src/ui/html-primitives.mjs +104 -0
  233. package/src/upgrade/upgrade.mjs +701 -0
  234. package/src/validate-atelier-export-dry-run.mjs +75 -0
  235. package/templates/atelier.project.example.json +23 -0
  236. package/templates/distribution-workspace/.claude/launch.json +12 -0
  237. package/templates/distribution-workspace/README.md +86 -0
  238. package/templates/distribution-workspace/atelier.project.json +36 -0
  239. package/templates/distribution-workspace/boundary-policy.v1.json +61 -0
  240. package/templates/distribution-workspace/gitignore +29 -0
  241. package/templates/distribution-workspace/governance/repo-boundary-ledger.md +5 -0
  242. package/templates/distribution-workspace/project/README.md +19 -0
  243. package/templates/distribution-workspace/repo-access.v1.json +9 -0
  244. package/templates/launch.json +12 -0
  245. package/templates/private-domain-workspace/.claude/launch.json +12 -0
  246. package/templates/private-domain-workspace/README.md +50 -0
  247. package/templates/private-domain-workspace/atelier.project.json +28 -0
  248. package/templates/private-domain-workspace/boundary-policy.v1.json +54 -0
  249. package/templates/private-domain-workspace/domain/README.md +19 -0
  250. package/templates/private-domain-workspace/gitignore +29 -0
  251. package/templates/private-domain-workspace/governance/repo-boundary-ledger.md +4 -0
  252. package/templates/private-domain-workspace/repo-access.v1.json +9 -0
  253. package/templates/shared-project-workspace/.claude/launch.json +12 -0
  254. package/templates/shared-project-workspace/README.md +51 -0
  255. package/templates/shared-project-workspace/atelier.project.json +28 -0
  256. package/templates/shared-project-workspace/boundary-policy.v1.json +61 -0
  257. package/templates/shared-project-workspace/gitignore +29 -0
  258. package/templates/shared-project-workspace/governance/repo-boundary-ledger.md +5 -0
  259. package/templates/shared-project-workspace/project/README.md +19 -0
  260. package/templates/shared-project-workspace/repo-access.v1.json +9 -0
@@ -0,0 +1,250 @@
1
+ #!/usr/bin/env node
2
+ import fs from 'node:fs'
3
+ import path from 'node:path'
4
+ import {
5
+ LOCAL_OVERLAY_SCHEMA,
6
+ LOCAL_STATE_DIR,
7
+ commandProject,
8
+ ensureLocalState,
9
+ firstString,
10
+ parseArgs,
11
+ resolveProjectConfig,
12
+ writeJson,
13
+ } from '../project/config.mjs'
14
+ import { auditRepoIdentities } from '../project/repo-identity.mjs'
15
+
16
+ const PROFILE_SET = new Set(['single-repo', 'private-domain', 'shared-project', 'multi-repo', 'monorepo', 'control-workspace'])
17
+ const IGNORE_LINES = [
18
+ '.atelier-local/',
19
+ 'atelier.local.json',
20
+ 'atelier.workspace.local.json',
21
+ 'atelier-attestation-key.local.json',
22
+ '.mnstry-local/',
23
+ '.atelier-proposals/',
24
+ '.atelier-current',
25
+ '.atelier-current.json',
26
+ '.atelier-presence.json',
27
+ '.atelier-nonce',
28
+ '.atelier-capability-grants.json',
29
+ '.atelier-events.jsonl',
30
+ '.atelier-audit.jsonl',
31
+ '.atelier-session.json',
32
+ '.atelier-session.jsonl',
33
+ '.atelier-sessions/',
34
+ '.atelier-support/',
35
+ 'atelier-output/',
36
+ 'support-bundle*',
37
+ 'support-bundles/',
38
+ 'transcripts/',
39
+ 'prompts/',
40
+ 'node_modules/',
41
+ 'npm-debug.log*',
42
+ '.DS_Store',
43
+ ]
44
+
45
+ function slug(value) {
46
+ return String(value || '')
47
+ .trim()
48
+ .toLowerCase()
49
+ .replace(/[^a-z0-9._-]+/g, '-')
50
+ .replace(/^-+|-+$/g, '') || 'atelier-project'
51
+ }
52
+
53
+ function appendIgnoreLines(root) {
54
+ const file = path.join(root, '.gitignore')
55
+ const existing = fs.existsSync(file) ? fs.readFileSync(file, 'utf8') : ''
56
+ const lines = new Set(existing.split('\n').map((line) => line.trim()).filter(Boolean))
57
+ const missing = IGNORE_LINES.filter((line) => !lines.has(line))
58
+ if (!missing.length) return { file, changed: false, added: [] }
59
+ const prefix = existing && !existing.endsWith('\n') ? '\n' : ''
60
+ fs.appendFileSync(file, `${prefix}${missing.join('\n')}\n`)
61
+ return { file, changed: true, added: missing }
62
+ }
63
+
64
+ function localOverlayFor(project) {
65
+ const repos = {}
66
+ for (const repo of project.repos ?? []) {
67
+ if (!repo.name || !repo.path) continue
68
+ repos[repo.name] = {
69
+ path: path.relative(project.configDir, repo.path).split(path.sep).join('/') || '.',
70
+ pathSource: repo.pathSource || 'tracked-config',
71
+ }
72
+ }
73
+ return {
74
+ schema: LOCAL_OVERLAY_SCHEMA,
75
+ generatedBy: 'atelier setup',
76
+ generatedAt: new Date().toISOString(),
77
+ repos,
78
+ }
79
+ }
80
+
81
+ function writeLocalOverlay(project, { dryRun = false } = {}) {
82
+ const root = path.join(project.configDir, LOCAL_STATE_DIR)
83
+ const file = path.join(root, 'workspace.json')
84
+ const overlay = localOverlayFor(project)
85
+ if (!dryRun) {
86
+ fs.mkdirSync(root, { recursive: true })
87
+ writeJson(file, overlay)
88
+ }
89
+ return { file, overlay, wrote: !dryRun }
90
+ }
91
+
92
+ function runSetup(argv) {
93
+ const args = parseArgs(argv)
94
+ const dryRun = Boolean(args['dry-run'])
95
+ const repair = Boolean(args.yes || args.fix || args._[0] === 'doctor')
96
+ const project = commandProject({ argv })
97
+ let ignore = { changed: false, added: [] }
98
+ let state = ensureLocalState(project, { write: false })
99
+ if (!state.ignored && repair && !dryRun) {
100
+ ignore = appendIgnoreLines(project.configDir)
101
+ state = ensureLocalState(project, { write: false })
102
+ }
103
+ if (!state.ignored) {
104
+ console.error(`Atelier local state is not ignored at ${state.root}`)
105
+ console.error('Run: atelier setup --yes --project ./atelier.project.json')
106
+ process.exit(1)
107
+ }
108
+ if (!dryRun) state = ensureLocalState(project, { write: true })
109
+ const overlay = writeLocalOverlay(project, { dryRun })
110
+ const report = {
111
+ ok: true,
112
+ command: 'setup',
113
+ dryRun,
114
+ configPath: project.configPath,
115
+ localState: state,
116
+ ignore,
117
+ overlay,
118
+ repos: project.repos.map((repo) => ({ name: repo.name, path: repo.path, pathSource: repo.pathSource })),
119
+ }
120
+ console.log(JSON.stringify(report, null, 2))
121
+ }
122
+
123
+ function baseBoundaryPolicy({ repoName, profile, actor }) {
124
+ const privateDomain = profile === 'shared-project' ? `${actor}-private` : repoName
125
+ const shared = profile === 'shared-project'
126
+ return {
127
+ schema: 'mnstry.atelier-boundary-policy@v1',
128
+ mode: 'strict',
129
+ actors: {
130
+ [actor]: {
131
+ githubLogin: `${actor.toUpperCase()}_GITHUB_LOGIN_PLACEHOLDER`,
132
+ gitEmails: [`${actor}@example.invalid`],
133
+ privateDomainRepo: privateDomain,
134
+ },
135
+ },
136
+ repos: {
137
+ [repoName]: {
138
+ kind: shared ? 'shared' : 'private_domain',
139
+ ownerActor: shared ? undefined : actor,
140
+ readBoundary: shared ? 'team' : 'private',
141
+ allowedAudiences: shared ? ['team', 'operator', 'staff', 'public'] : ['private', 'sensitive', 'team', 'operator', 'staff', 'public'],
142
+ forbiddenAudiences: shared ? ['private', 'sensitive'] : [],
143
+ autoCommit: 'guarded',
144
+ },
145
+ },
146
+ promotion: {
147
+ requiresGitPromote: true,
148
+ recordsPath: 'governance/git-promote-events.jsonl',
149
+ },
150
+ forbiddenPaths: [
151
+ '.atelier-local/**',
152
+ 'atelier.local.json',
153
+ 'atelier.workspace.local.json',
154
+ 'atelier-attestation-key.local.json',
155
+ '.mnstry-local/**',
156
+ '.atelier-proposals/**',
157
+ 'support-bundles/**',
158
+ 'prompts/**',
159
+ 'transcripts/**',
160
+ ],
161
+ governanceLedgerPath: 'governance/repo-boundary-ledger.md',
162
+ }
163
+ }
164
+
165
+ function cleanUndefined(value) {
166
+ if (Array.isArray(value)) return value.map(cleanUndefined)
167
+ if (value && typeof value === 'object') {
168
+ return Object.fromEntries(Object.entries(value).filter(([, item]) => item !== undefined).map(([key, item]) => [key, cleanUndefined(item)]))
169
+ }
170
+ return value
171
+ }
172
+
173
+ function runAdopt(argv) {
174
+ const args = parseArgs(argv)
175
+ const target = path.resolve(firstString(args.target) || process.cwd())
176
+ const profile = firstString(args.profile, args.template) || 'single-repo'
177
+ if (!PROFILE_SET.has(profile)) throw new Error(`unsupported Atelier setup profile: ${profile}`)
178
+ if (profile === 'monorepo' && !firstString(args.include, args.includes)) {
179
+ throw new Error('monorepo adopt requires --include so Atelier does not scan the whole repo by accident')
180
+ }
181
+ fs.mkdirSync(target, { recursive: true })
182
+ appendIgnoreLines(target)
183
+ const repoName = slug(firstString(args.name) || path.basename(target))
184
+ const actor = slug(firstString(args.actor) || process.env.USER || 'owner')
185
+ const projectPath = path.join(target, 'atelier.project.json')
186
+ if (!fs.existsSync(projectPath)) {
187
+ writeJson(projectPath, {
188
+ schema: 'mnstry.atelier-project-config@v1',
189
+ name: repoName,
190
+ roots: { workspace: '.', repoOps: '.' },
191
+ graph: { repoAccessPath: 'repo-access.v1.json', outputPath: 'atelier-output/knowledge.graph.json' },
192
+ projection: { outputRoot: 'atelier-output', readinessPath: 'atelier-output/atelier-readiness.json' },
193
+ boundaries: { policyPath: 'boundary-policy.v1.json', governanceLedgerPath: 'governance/repo-boundary-ledger.md', strictNewRepos: true },
194
+ setup: { profile, include: firstString(args.include, args.includes) || null, exclude: firstString(args.exclude, args.excludes) || null },
195
+ repos: [{ name: repoName, path: '.', readBoundary: profile === 'shared-project' ? 'team' : 'private', role: profile }],
196
+ })
197
+ }
198
+ if (!fs.existsSync(path.join(target, 'repo-access.v1.json'))) {
199
+ writeJson(path.join(target, 'repo-access.v1.json'), {
200
+ schema: 'mnstry.atelier-repo-access@v1',
201
+ defaultReadBoundary: profile === 'shared-project' ? 'team' : 'private',
202
+ repos: { [repoName]: { readBoundary: profile === 'shared-project' ? 'team' : 'private' } },
203
+ })
204
+ }
205
+ if (!fs.existsSync(path.join(target, 'boundary-policy.v1.json'))) {
206
+ writeJson(path.join(target, 'boundary-policy.v1.json'), cleanUndefined(baseBoundaryPolicy({ repoName, profile, actor })))
207
+ }
208
+ const project = resolveProjectConfig({ cwd: target, argv: ['--project', projectPath] })
209
+ ensureLocalState(project, { write: true })
210
+ writeLocalOverlay(project)
211
+ console.log(JSON.stringify({ ok: true, command: 'adopt', profile, target, projectPath }, null, 2))
212
+ }
213
+
214
+ function runDoctor(argv) {
215
+ const args = parseArgs(argv)
216
+ const project = commandProject({ argv })
217
+ const dryRun = Boolean(args['dry-run'])
218
+ const fix = Boolean(args.fix)
219
+ const stateBefore = ensureLocalState(project, { write: false })
220
+ let setup = null
221
+ if (fix) {
222
+ runSetup(['--project', project.configPath, '--yes', ...(dryRun ? ['--dry-run'] : [])])
223
+ return
224
+ }
225
+ setup = { localState: stateBefore }
226
+ const identity = auditRepoIdentities(project)
227
+ const ok = stateBefore.ignored && identity.ok
228
+ console.log(JSON.stringify({
229
+ ok,
230
+ command: 'doctor',
231
+ configPath: project.configPath,
232
+ repos: project.repos.map((repo) => ({ name: repo.name, path: repo.path, pathSource: repo.pathSource, external: Boolean(repo.external) })),
233
+ identity,
234
+ setup,
235
+ }, null, 2))
236
+ process.exit(ok ? 0 : 1)
237
+ }
238
+
239
+ const argv = process.argv.slice(2)
240
+ const args = parseArgs(argv)
241
+ const subcommand = args._[0] || 'setup'
242
+ try {
243
+ if (subcommand === 'setup') runSetup(argv.filter((arg) => arg !== 'setup'))
244
+ else if (subcommand === 'adopt') runAdopt(argv.filter((arg) => arg !== 'adopt'))
245
+ else if (subcommand === 'doctor') runDoctor(argv.filter((arg) => arg !== 'doctor'))
246
+ else throw new Error(`unknown setup command: ${subcommand}`)
247
+ } catch (error) {
248
+ console.error(error.message)
249
+ process.exit(1)
250
+ }
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import { runSupportCommand } from '../support/support-bundle.mjs'
3
+ runSupportCommand()
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import { runUpgradeCommand } from '../upgrade/upgrade.mjs'
3
+ runUpgradeCommand()
@@ -0,0 +1,171 @@
1
+ import fs from 'node:fs'
2
+ import path from 'node:path'
3
+ import { fileURLToPath } from 'node:url'
4
+
5
+ // Shared contract corpus: one entry per validated document shape, consumed by
6
+ // test/contract-registry.test.mjs (fixture wiring for otherwise-unreferenced
7
+ // contracts) and scripts/check-contract-compat.mjs (epoch compatibility gate).
8
+ //
9
+ // Entry shape:
10
+ // - name stable entry id (unique)
11
+ // - contractFile repo-relative contract path
12
+ // - docPointer optional JSON pointer fragment ('#/$defs/...') when the
13
+ // validated document shape is a subschema rather than the root
14
+ // - fixtureRoot repo-relative directory containing valid/ and invalid/ subdirs
15
+ // - validFiles explicit repo-relative valid documents (used instead of
16
+ // fixtureRoot when fixtures live in place next to other assets)
17
+ // - invalidFiles explicit repo-relative invalid documents
18
+ // - registry true when test/contract-registry.test.mjs owns positive and
19
+ // negative coverage for the entry (contracts with no dedicated
20
+ // test file); entries covered by an existing dedicated test
21
+ // carry registry: false and exist for the compat gate
22
+ // - loadGeneratedDocs optional async loader returning generated documents that
23
+ // must also satisfy the contract (generated docs drift first)
24
+ //
25
+ // The semantic profile (contracts/mnstry-atelier-semantic-profile.v1.json) is a
26
+ // document, not a schema, and is deliberately absent.
27
+
28
+ export const CONTRACT_CORPUS = [
29
+ {
30
+ name: 'atelier-lock',
31
+ contractFile: 'contracts/atelier-lock.v1.schema.json',
32
+ fixtureRoot: 'fixtures/atelier-lock',
33
+ registry: false,
34
+ },
35
+ {
36
+ name: 'atelier-migration',
37
+ contractFile: 'contracts/atelier-migration.v1.schema.json',
38
+ fixtureRoot: 'fixtures/atelier-migration',
39
+ registry: false,
40
+ },
41
+ {
42
+ name: 'atelier-boundary-policy',
43
+ contractFile: 'contracts/atelier-boundary-policy.v1.schema.json',
44
+ fixtureRoot: 'fixtures/boundary-policy',
45
+ registry: false,
46
+ },
47
+ {
48
+ name: 'atelier-export',
49
+ contractFile: 'contracts/atelier-export.v1.schema.json',
50
+ validFiles: ['fixtures/atelier-export/sample-studio-offer.v1.json'],
51
+ registry: false,
52
+ },
53
+ {
54
+ name: 'atelier-kit-manifest',
55
+ contractFile: 'contracts/atelier-kit-manifest.v1.schema.json',
56
+ fixtureRoot: 'fixtures/atelier-kit-manifest',
57
+ registry: false,
58
+ },
59
+ {
60
+ name: 'atelier-extension-pack',
61
+ contractFile: 'contracts/atelier-extension-pack.v1.schema.json',
62
+ fixtureRoot: 'fixtures/readiness-protocols/extension-pack',
63
+ registry: false,
64
+ },
65
+ {
66
+ name: 'atelier-readiness-protocol',
67
+ contractFile: 'contracts/atelier-readiness-protocol.v1.schema.json',
68
+ fixtureRoot: 'fixtures/readiness-protocols/protocol',
69
+ registry: false,
70
+ loadGeneratedDocs: async () =>
71
+ (await import('../readiness-protocols/bundled-pack.mjs')).bundledReadinessProtocols,
72
+ },
73
+ {
74
+ name: 'atelier-readiness-run',
75
+ contractFile: 'contracts/atelier-readiness-run.v1.schema.json',
76
+ fixtureRoot: 'fixtures/readiness-protocols/run',
77
+ registry: false,
78
+ },
79
+ {
80
+ name: 'atelier-attestation',
81
+ contractFile: 'contracts/atelier-attestation.v1.schema.json',
82
+ fixtureRoot: 'fixtures/atelier-attestation',
83
+ registry: false,
84
+ },
85
+ {
86
+ name: 'atelier-claim',
87
+ contractFile: 'contracts/atelier-claim.v1.schema.json',
88
+ fixtureRoot: 'fixtures/atelier-claim',
89
+ registry: true,
90
+ },
91
+ {
92
+ name: 'atelier-project-config',
93
+ contractFile: 'contracts/atelier-project-config.v1.schema.json',
94
+ fixtureRoot: 'fixtures/atelier-project-config',
95
+ registry: true,
96
+ },
97
+ {
98
+ name: 'atelier-readiness',
99
+ contractFile: 'contracts/atelier-readiness.v1.schema.json',
100
+ fixtureRoot: 'fixtures/atelier-readiness',
101
+ registry: true,
102
+ },
103
+ {
104
+ name: 'atelier-action-intent',
105
+ contractFile: 'contracts/atelier-action-intent.v1.schema.json',
106
+ fixtureRoot: 'fixtures/atelier-action-intent',
107
+ registry: true,
108
+ },
109
+ {
110
+ name: 'atelier-analysis-adapter',
111
+ contractFile: 'contracts/atelier-analysis-adapter.v1.schema.json',
112
+ fixtureRoot: 'fixtures/atelier-analysis-adapter',
113
+ registry: true,
114
+ },
115
+ {
116
+ name: 'knowledge-source-sidecar',
117
+ contractFile: 'contracts/knowledge-source-sidecar.v1.schema.json',
118
+ fixtureRoot: 'fixtures/knowledge-source-sidecar',
119
+ registry: true,
120
+ },
121
+ {
122
+ name: 'git-promote-event',
123
+ contractFile: 'contracts/git-promote-event.v1.schema.json',
124
+ validFiles: ['fixtures/git-promote/private-to-team.v1.json'],
125
+ invalidFiles: ['fixtures/git-promote/invalid/provision-named-revocable.v1.json'],
126
+ registry: true,
127
+ },
128
+ {
129
+ name: 'analysis-adapter-manifest',
130
+ contractFile: 'contracts/analysis-adapter.v1.schema.json',
131
+ docPointer: '#/$defs/manifest',
132
+ validFiles: [
133
+ 'fixtures/analysis-adapter/manifest.disabled.v1.json',
134
+ 'fixtures/analysis-adapter/manifest.enabled-local.v1.json',
135
+ ],
136
+ invalidFiles: ['fixtures/analysis-adapter/invalid/manifest-hidden-provider.v1.json'],
137
+ registry: true,
138
+ },
139
+ {
140
+ name: 'analysis-adapter-claim-output',
141
+ contractFile: 'contracts/analysis-adapter.v1.schema.json',
142
+ docPointer: '#/$defs/claimOutput',
143
+ validFiles: ['fixtures/analysis-adapter/output.claims.v1.json'],
144
+ invalidFiles: [
145
+ 'fixtures/analysis-adapter/invalid/output-frontmatter-mutation.v1.json',
146
+ 'fixtures/analysis-adapter/invalid/output-native-graph.v1.json',
147
+ ],
148
+ registry: true,
149
+ },
150
+ ]
151
+
152
+ export const CORPUS_ROOT = fileURLToPath(new URL('../..', import.meta.url))
153
+
154
+ function listJsonFiles(dir) {
155
+ if (!fs.existsSync(dir)) return []
156
+ return fs.readdirSync(dir)
157
+ .filter((name) => name.endsWith('.json'))
158
+ .sort()
159
+ .map((name) => path.join(dir, name))
160
+ }
161
+
162
+ export function corpusValidFiles(entry, root = CORPUS_ROOT) {
163
+ if (entry.validFiles) return entry.validFiles.map((file) => path.join(root, file))
164
+ return listJsonFiles(path.join(root, entry.fixtureRoot, 'valid'))
165
+ }
166
+
167
+ export function corpusInvalidFiles(entry, root = CORPUS_ROOT) {
168
+ if (entry.invalidFiles) return entry.invalidFiles.map((file) => path.join(root, file))
169
+ if (!entry.fixtureRoot) return []
170
+ return listJsonFiles(path.join(root, entry.fixtureRoot, 'invalid'))
171
+ }
@@ -0,0 +1,45 @@
1
+ import fs from 'node:fs'
2
+ import path from 'node:path'
3
+
4
+ const ROOT = path.resolve(new URL('../..', import.meta.url).pathname)
5
+ const SCAN_DIRS = ['bin', 'src']
6
+ const FORBIDDEN = [
7
+ { pattern: /fetch\(\s*['"]https?:\/\/(?!127\.0\.0\.1|localhost|\[::1\])/, label: 'non-localhost fetch' },
8
+ { pattern: /https?\.request\s*\(/, label: 'http request primitive' },
9
+ { pattern: /new\s+WebSocket\s*\(/, label: 'websocket egress primitive' },
10
+ { pattern: /net\.connect\s*\(/, label: 'net connect primitive' },
11
+ { pattern: /dns\./, label: 'dns primitive' },
12
+ { pattern: /\bcurl\s+https?:\/\//, label: 'shell network call' },
13
+ ]
14
+
15
+ function walk(dir, files = []) {
16
+ if (!fs.existsSync(dir)) return files
17
+ for (const ent of fs.readdirSync(dir, { withFileTypes: true })) {
18
+ const abs = path.join(dir, ent.name)
19
+ if (ent.isDirectory()) walk(abs, files)
20
+ else if (/\.(mjs|js|sh)$/.test(ent.name)) files.push(abs)
21
+ }
22
+ return files
23
+ }
24
+
25
+ export function checkForbiddenEgress(root = ROOT) {
26
+ const failures = []
27
+ for (const rel of SCAN_DIRS) {
28
+ for (const file of walk(path.join(root, rel))) {
29
+ const text = fs.readFileSync(file, 'utf8')
30
+ for (const rule of FORBIDDEN) {
31
+ if (rule.pattern.test(text)) failures.push(`${path.relative(root, file)}:${rule.label}`)
32
+ }
33
+ }
34
+ }
35
+ return failures
36
+ }
37
+
38
+ export function runEgressCommand() {
39
+ const failures = checkForbiddenEgress()
40
+ if (failures.length) {
41
+ console.error(failures.join('\n'))
42
+ process.exit(1)
43
+ }
44
+ console.log('[egress:check] no forbidden non-localhost egress found in package runtime paths')
45
+ }