dxcomplete 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 (121) hide show
  1. package/.env.example +11 -0
  2. package/README.md +215 -0
  3. package/dist/cli.d.ts +2 -0
  4. package/dist/cli.js +212 -0
  5. package/dist/http/server.d.ts +7 -0
  6. package/dist/http/server.js +236 -0
  7. package/dist/http/service.d.ts +7 -0
  8. package/dist/http/service.js +725 -0
  9. package/dist/init.d.ts +13 -0
  10. package/dist/init.js +128 -0
  11. package/dist/install-manifest.d.ts +25 -0
  12. package/dist/install-manifest.js +96 -0
  13. package/dist/mcp/docs.d.ts +98 -0
  14. package/dist/mcp/docs.js +438 -0
  15. package/dist/mcp/server.d.ts +20 -0
  16. package/dist/mcp/server.js +2345 -0
  17. package/dist/package-root.d.ts +2 -0
  18. package/dist/package-root.js +28 -0
  19. package/dist/runtime/actor.d.ts +14 -0
  20. package/dist/runtime/actor.js +42 -0
  21. package/dist/runtime/auth.d.ts +162 -0
  22. package/dist/runtime/auth.js +394 -0
  23. package/dist/runtime/check.d.ts +7 -0
  24. package/dist/runtime/check.js +16 -0
  25. package/dist/runtime/config.d.ts +17 -0
  26. package/dist/runtime/config.js +93 -0
  27. package/dist/runtime/mongo.d.ts +9 -0
  28. package/dist/runtime/mongo.js +56 -0
  29. package/dist/runtime/records.d.ts +336 -0
  30. package/dist/runtime/records.js +1463 -0
  31. package/dist/runtime/workspace.d.ts +19 -0
  32. package/dist/runtime/workspace.js +102 -0
  33. package/dist/upgrade.d.ts +20 -0
  34. package/dist/upgrade.js +246 -0
  35. package/dist/validate.d.ts +10 -0
  36. package/dist/validate.js +119 -0
  37. package/dist/version.d.ts +3 -0
  38. package/dist/version.js +12 -0
  39. package/docs/codex-integration.md +29 -0
  40. package/docs/cost-model.md +61 -0
  41. package/docs/decision-basis.md +57 -0
  42. package/docs/diagrams.md +31 -0
  43. package/docs/glossary.md +147 -0
  44. package/docs/index.md +60 -0
  45. package/docs/model.md +110 -0
  46. package/docs/open-questions.md +61 -0
  47. package/docs/roles.md +42 -0
  48. package/docs/taxonomy.md +96 -0
  49. package/docs/workflows.md +60 -0
  50. package/package.json +62 -0
  51. package/scripts/check-env-surface.mjs +136 -0
  52. package/scripts/check-public-copy.mjs +263 -0
  53. package/scripts/check-service-boundary.mjs +63 -0
  54. package/scripts/dogfood-work-order.mjs +506 -0
  55. package/scripts/smoke-mcp-http.mjs +3572 -0
  56. package/src/cli.ts +268 -0
  57. package/src/http/server.ts +314 -0
  58. package/src/http/service.ts +934 -0
  59. package/src/init.ts +227 -0
  60. package/src/install-manifest.ts +144 -0
  61. package/src/mcp/docs.ts +557 -0
  62. package/src/mcp/server.ts +3525 -0
  63. package/src/package-root.ts +31 -0
  64. package/src/runtime/actor.ts +61 -0
  65. package/src/runtime/auth.ts +673 -0
  66. package/src/runtime/check.ts +18 -0
  67. package/src/runtime/config.ts +128 -0
  68. package/src/runtime/mongo.ts +89 -0
  69. package/src/runtime/records.ts +2303 -0
  70. package/src/runtime/workspace.ts +155 -0
  71. package/src/upgrade.ts +356 -0
  72. package/src/validate.ts +139 -0
  73. package/src/version.ts +16 -0
  74. package/templates/github/workflows/dxcomplete.yml +16 -0
  75. package/templates/next/pages/api/auth/callback/google.js +12 -0
  76. package/templates/next/pages/api/dxcomplete/[...path].js +12 -0
  77. package/templates/next/pages/api/dxcomplete.js +12 -0
  78. package/templates/next/pages/api/mcp.js +12 -0
  79. package/templates/next/vercel.json +18 -0
  80. package/templates/process/README.md +38 -0
  81. package/templates/process/controls.yml +113 -0
  82. package/templates/process/cost-model.yml +71 -0
  83. package/templates/process/decision-basis.yml +53 -0
  84. package/templates/process/decisions/.gitkeep +1 -0
  85. package/templates/process/diagrams/00-decision-basis.mmd +24 -0
  86. package/templates/process/diagrams/00-overview.mmd +20 -0
  87. package/templates/process/diagrams/01-intake-triage.mmd +20 -0
  88. package/templates/process/diagrams/02-product-definition.mmd +14 -0
  89. package/templates/process/diagrams/03-engineering-execution.mmd +15 -0
  90. package/templates/process/diagrams/04-qa-verification.mmd +12 -0
  91. package/templates/process/diagrams/05-product-validation.mmd +12 -0
  92. package/templates/process/diagrams/06-change-release-control.mmd +16 -0
  93. package/templates/process/diagrams/07-deployment-operations.mmd +16 -0
  94. package/templates/process/diagrams/08-support-incident-management.mmd +16 -0
  95. package/templates/process/diagrams/09-problem-improvement.mmd +14 -0
  96. package/templates/process/diagrams/10-risk-control-management.mmd +14 -0
  97. package/templates/process/diagrams/11-audit-evidence-capture.mmd +13 -0
  98. package/templates/process/evidence/.gitkeep +1 -0
  99. package/templates/process/risks/.gitkeep +1 -0
  100. package/templates/process/roles.yml +96 -0
  101. package/templates/process/taxonomy.yml +514 -0
  102. package/templates/process/workflows.yml +210 -0
  103. package/website/.well-known/oauth-authorization-server +22 -0
  104. package/website/.well-known/oauth-protected-resource/api/dxcomplete/mcp +10 -0
  105. package/website/.well-known/oauth-protected-resource/api/mcp +10 -0
  106. package/website/README.md +12 -0
  107. package/website/app.js +36 -0
  108. package/website/flow.html +85 -0
  109. package/website/glossary.html +280 -0
  110. package/website/index.html +90 -0
  111. package/website/objects.html +287 -0
  112. package/website/outcomes.html +117 -0
  113. package/website/phase-build.html +101 -0
  114. package/website/phase-elicit.html +102 -0
  115. package/website/phase-go-live.html +103 -0
  116. package/website/phase-measure.html +93 -0
  117. package/website/phase-operate.html +102 -0
  118. package/website/phase-orient.html +92 -0
  119. package/website/phase-weigh.html +98 -0
  120. package/website/roles.html +52 -0
  121. package/website/styles.css +1169 -0
package/.env.example ADDED
@@ -0,0 +1,11 @@
1
+ # Central service deployment
2
+ DXC_MONGODB_URI=
3
+ DXC_DATABASE_NAME=dxcomplete
4
+ DXC_GOOGLE_CLIENT_ID=
5
+ DXC_GOOGLE_CLIENT_SECRET=
6
+ DXC_SERVICE_PROVISIONING_SECRET=
7
+
8
+ # Workspace MCP deployment
9
+ DXC_SERVICE_URL=
10
+ DXC_SERVICE_CLIENT_ID=
11
+ DXC_SERVICE_CLIENT_SECRET=
package/README.md ADDED
@@ -0,0 +1,215 @@
1
+ # DX Complete
2
+
3
+ DX Complete is an exploratory npm package for installing a reusable documentation, process, and MCP route kit into a Next.js workspace project.
4
+
5
+ The broader product premise is:
6
+
7
+ ```text
8
+ DX Complete = Decision Basis + Complete Engineering + Operations Measurement
9
+ ```
10
+
11
+ The target command is:
12
+
13
+ ```sh
14
+ npx dxcomplete init
15
+ ```
16
+
17
+ The scaffold is intended to help a team describe and revise a full engineering and service lifecycle model. It deliberately does not present the current model as decided. Roles, workflows, object taxonomy, and diagrams are draft material that should be edited as the operating model becomes clearer.
18
+
19
+ ## Product Outcome
20
+
21
+ Running `dxcomplete init` in a Next.js project creates an editable starting point for process documentation, Mermaid diagrams, taxonomy files, decision-basis templates, cost-model templates, workflow templates, placeholder controls, evidence folders, workspace configuration, Next-compatible MCP route wrappers, and optional GitHub workflow checks.
22
+
23
+ The current draft model covers:
24
+
25
+ - Direction
26
+ - Product definition
27
+ - Engineering execution
28
+ - Engineer implementation, including Codex-assisted work where appropriate
29
+ - QA verification
30
+ - Product validation
31
+ - Change and release control
32
+ - Deployment
33
+ - Operation
34
+ - User support
35
+ - Administration as part of operation
36
+ - Audit and evidence
37
+
38
+ ## Current Framing
39
+
40
+ The working hypothesis is that DX Complete describes a full decision-basis, engineering, and service lifecycle, not only software development. It includes cost and benefit reasoning before engineering begins, both build/change responsibilities and run/service responsibilities, and actual measurement after delivery where available.
41
+
42
+ The current role model includes Owner, Engineer, Tester, Operator, Support Agent, and End User. The model keeps outcome authority, requirements, product validation, and risk acceptance visible inside Owner; implementation responsibilities inside Engineer; and administration responsibilities inside Operator.
43
+
44
+ Current draft concepts include Workspace, Statement, Expectation, Requirement, Commitment, Deferral, Task, Environment, Component, Estimate, Benefits, Feedback, AuthoritativeRequest, FeatureRequest, Change, Incident, Problem, SupportTicket, Release, Deployment, Decision, Risk, and Control. These are represented in editable YAML and Markdown so they can evolve.
45
+
46
+ ## Usage
47
+
48
+ Install the scaffold into the current Next.js project:
49
+
50
+ ```sh
51
+ npx dxcomplete init
52
+ ```
53
+
54
+ Install into another directory:
55
+
56
+ ```sh
57
+ npx dxcomplete init --target ./some-project
58
+ ```
59
+
60
+ Preview without writing files:
61
+
62
+ ```sh
63
+ npx dxcomplete init --dry-run
64
+ ```
65
+
66
+ Preview compatibility-critical scaffold updates for an installed workspace:
67
+
68
+ ```sh
69
+ npx dxcomplete upgrade
70
+ ```
71
+
72
+ Apply those updates:
73
+
74
+ ```sh
75
+ npx dxcomplete upgrade --apply
76
+ ```
77
+
78
+ Validate the scaffold shape:
79
+
80
+ ```sh
81
+ npx dxcomplete validate
82
+ ```
83
+
84
+ By default, the scaffold is written to `dxcomplete/` and a placeholder workflow is written to `.github/workflows/dxcomplete.yml`. Existing files are not overwritten unless `--force` is provided.
85
+
86
+ `dxcomplete upgrade` previews by default. It manages the installed route wrappers, Vercel compatibility configuration, and `dxcomplete/.install-manifest.json`. It does not overwrite `dxcomplete/workspace.json`. It reports drift in `dxcomplete/docs` and `dxcomplete/process` because those files are expected to become user-owned after installation.
87
+ Run `dxcomplete init` before `dxcomplete upgrade`; upgrade refuses targets that do not already have `dxcomplete/workspace.json`.
88
+
89
+ The installed MCP route wrappers are written under `pages/api/` so the workspace can remain a normal Next.js app on Vercel:
90
+
91
+ ```text
92
+ pages/api/mcp.js
93
+ pages/api/dxcomplete.js
94
+ pages/api/dxcomplete/[...path].js
95
+ pages/api/auth/callback/google.js
96
+ ```
97
+
98
+ The workspace identity is written to `dxcomplete/workspace.json` inside the installed project. That file belongs to the workspace app repo, not to the central DX Complete repo.
99
+
100
+ ## Package and Compatibility Versioning
101
+
102
+ DX Complete uses one package version, one workspace compatibility gate, and one surface fingerprint:
103
+
104
+ - `packageVersion` is the npm package release version from `package.json`.
105
+ - `workspaceCompatibility` is the installed workspace compatibility gate. It changes only when an installed workspace must update its route/proxy surface to keep talking safely to the central service.
106
+ - `surfaceFingerprint` is an automatic hash of the live MCP tools, tool schemas, process guide, and on-demand doc references. It can change without requiring a package release or workspace upgrade.
107
+
108
+ The MCP `surfaceVersion` field is a stable surface identifier. Use `surfaceFingerprint` for exact surface reconciliation and `workspaceCompatibility` for upgrade decisions.
109
+
110
+ ## Runtime Dogfood
111
+
112
+ The documentation scaffold is the first milestone. The next layer is a hosted runtime and MCP server so DX Complete can coordinate its own records. The runtime now treats Workspace as the boundary for one service scope.
113
+
114
+ The default MCP deployment model is one endpoint per workspace. A Next.js project repo installs DX Complete and exposes an MCP route for that workspace, but that workspace server does not open the database directly. It proxies auth and MCP requests to the central DX Complete service. Access is scoped by the installed repo's `dxcomplete/workspace.json`, authenticated actor identity, and workspace membership. Do not use a workspace environment variable for this boundary.
115
+
116
+ For the central service deployment, provide the database and Google OAuth configuration:
117
+
118
+ ```sh
119
+ DXC_MONGODB_URI=mongodb+srv://...
120
+ DXC_DATABASE_NAME=dxcomplete
121
+ DXC_GOOGLE_CLIENT_ID=...
122
+ DXC_GOOGLE_CLIENT_SECRET=...
123
+ DXC_SERVICE_PROVISIONING_SECRET=...
124
+ ```
125
+
126
+ `DXC_MONGODB_URI` is a secret, `DXC_DATABASE_NAME` is environment-specific, `DXC_GOOGLE_CLIENT_ID` is a provisioning detail, `DXC_GOOGLE_CLIENT_SECRET` is a secret, and `DXC_SERVICE_PROVISIONING_SECRET` is a secret.
127
+
128
+ For a workspace MCP deployment, provide only the central-service connection:
129
+
130
+ ```sh
131
+ DXC_SERVICE_URL=https://dxcomplete.example
132
+ DXC_SERVICE_CLIENT_ID=...
133
+ DXC_SERVICE_CLIENT_SECRET=...
134
+ ```
135
+
136
+ `DXC_SERVICE_URL` is environment-specific, `DXC_SERVICE_CLIENT_ID` is a provisioning detail, and `DXC_SERVICE_CLIENT_SECRET` is a secret. Workspace MCP deployments must not require `DXC_MONGODB_URI`, `DXC_GOOGLE_CLIENT_ID`, or `DXC_GOOGLE_CLIENT_SECRET`.
137
+
138
+ Then build and check the runtime:
139
+
140
+ ```sh
141
+ npm run build
142
+ npm run runtime:check
143
+ ```
144
+
145
+ The first runtime collections cover workspaces, statements, journal entries, environments, components, estimates, benefits, expectations, requirements, commitments, deferrals, tasks, changes, decisions, and risks. Dogfooding should use the normal MCP tools to create and link those records inside the intended workspace. Workspace-scoped lifecycle records receive a human-readable reference such as `REQ-0001` while UUID remains the primary key and link target.
146
+
147
+ Environment and Component records form the Operational Registry. The registry is an inventory of operational state: what exists in each environment, where it lives, and which secret names or locations are relevant. It is not monitoring, diagnostics, a secret vault, an event log, or a runbook engine. Secret pointers should identify stores and keys only; do not record secret values.
148
+
149
+ Useful MCP tools for dogfooding include:
150
+
151
+ - `runtime_status` to confirm the connected server process and MCP surface fingerprint.
152
+ - `get_process_guide` to give MCP clients the current phase guide: Orient, Elicit, Weigh, Build, Go Live, Operate, and Measure.
153
+ - `get_doc` to retrieve richer reference content for outcomes, flow, records, roles, and glossary terms on demand.
154
+ - `create_dxcomplete_ticket`, `append_dxcomplete_ticket`, `list_dxcomplete_tickets`, and `archive_dxcomplete_ticket` for private, appendable DX Complete Tickets from the current actor.
155
+ - `list_unread_dxcomplete_ticket_replies` to see which tickets have unread DX Complete replies without returning the reply body, and `read_dxcomplete_ticket` to open a ticket and mark those replies read.
156
+ - `append_journal_note`, `read_journal`, `get_journal_entry`, and `append_journal_summary` for shared workspace context that has no dedicated record home.
157
+ - `get_record`, `list_records`, and `list_linked_records` to inspect records and relationships.
158
+ - `create_workspace`, `create_statement`, and `update_statement` to establish the workspace, service scope, and traceable source wording.
159
+ - `create_environment`, `update_environment`, `list_environments`, `create_component`, `update_component`, and `list_components` for the Operational Registry.
160
+ - `create_expectation` and `update_expectation` for user-facing conditions of satisfaction, with prior versions preserved on update.
161
+ - `create_requirement` and `update_requirement` for requirement work, with prior requirement versions preserved on update.
162
+ - `create_task` and `append_task_entry` for task work, where current status comes from the latest status-change entry.
163
+ - `create_estimate` and `update_estimate` for itemized cost estimates used during Weigh, with prior versions preserved on update.
164
+ - `create_benefits` and `update_benefits` for Owner-authored Benefits records used during Weigh, with prior versions preserved on update.
165
+ - `create_commitment` and `create_deferral` for recording the Owner's Weigh outcome.
166
+ - `append_deferral_event` for condition updates, notes, resolution into Commitment, or abandonment.
167
+ - `create_decision` and `append_decision_entry` for recording revisitable choices, arguments, notes, and later decision entries.
168
+ - `link_decision_input` for linking a Decision to the records that informed it.
169
+ - `link_records` and `unlink_records` for explicit relationships when a typed tool does not already create or remove the link.
170
+ - `archive_record` for cleanup without deleting evidence.
171
+
172
+ Hosted MCP is exposed at `/api/mcp`. The workspace route uses Streamable HTTP, advertises OAuth metadata for remote MCP clients, proxies OAuth through the central service, sends users through Google OAuth, and then returns DX Complete bearer tokens scoped to the configured workspace. The installed repo supplies workspace identity through `dxcomplete/workspace.json`; the central service stores workspace memberships and executes MCP tools. The current dogfood workspace grants Owner access to `sam.bourque@gmail.com`.
173
+
174
+ The central service exposes internal routes under `/api/dxcomplete/service/*`. Workspace servers authenticate to those routes with `DXC_SERVICE_CLIENT_ID` and `DXC_SERVICE_CLIENT_SECRET`. The provisioning route creates the workspace record, seeds the Owner membership, and returns the one-time workspace service-client secret.
175
+
176
+ For Google OAuth provisioning, set the callback URL to `/api/auth/callback/google` on the hosted workspace domain. For the dogfood deployment, use `https://dxcomplete.directeddomains.com/api/auth/callback/google`.
177
+
178
+ Use `runtime_status` to reconcile the MCP-facing contract. `surfaceFingerprint` is the single client-facing identity for the tools, tool schemas, process guide, and on-demand doc references together. `get_process_guide` and `get_doc` return the same `surfaceVersion` and `surfaceFingerprint`, so an MCP client can treat a mismatch as a stale or inconsistent surface and refresh before continuing.
179
+
180
+ On Vercel, `vercel.json` must include `dxcomplete/workspace.json` in the API function bundle. The scaffold includes this by default with `functions["pages/api/**/*.js"].includeFiles`. Vercel reserves `/.well-known`, so the installed Next app rewrites the OAuth discovery metadata paths to the DX Complete route wrapper.
181
+
182
+ A DX Complete Ticket is the private place for an MCP client user to raise a question, report, request, correction, or follow-up with DX Complete. It has an ID and can receive appended entries over time. The durable content is the title plus entries; summary is optional and is not generated automatically. DX Complete replies can be tracked as unread or read by the submitting actor. The unread list identifies tickets that need attention; reading the ticket opens the full content and marks addressed replies read. A ticket does not ingest files or assets, and does not automatically create a requirement, task, incident, or decision. Formal shared work should be created or linked separately when someone decides the ticket needs process follow-up.
183
+
184
+ The Journal is shared workspace context, not a private ticket. It is for useful notes that do not already belong in a dedicated record such as Statement, Expectation, Requirement, Decision, Risk, Change, or Task. The routing test is: will another record reference or depend on this? If yes, prefer a dedicated record. Journal content that becomes load-bearing should be promoted to the appropriate record and linked back where useful. Journal entries are append-only and can be linked as decision inputs or provenance. The default journal read returns the hot tier: active summaries plus active raw notes. Summary entries point back to covered raw notes, and covered notes are archived out of the hot read without being deleted.
185
+
186
+ For dogfood maintenance work that needs direct database access, batch the work in one process instead of running repeated one-off Mongo commands:
187
+
188
+ ```sh
189
+ npm run dogfood:work-order -- --plan ./work-order.json
190
+ ```
191
+
192
+ The work-order runner opens one runtime connection, runs ticket summaries, ticket reads, DX Complete replies, simple archives, link-residue checks, or a local one-off module, then closes the connection. It is a maintainer tool for dogfood cleanup and migration work; the normal product path remains the hosted MCP tools.
193
+
194
+ Run the hosted MCP smoke test after runtime changes:
195
+
196
+ ```sh
197
+ npm run smoke:mcp:http
198
+ ```
199
+
200
+ After updating a remote connector, compare its `runtime_status` fingerprint with the hosted smoke-test fingerprint before relying on newly added tools.
201
+
202
+ ## Repository Structure
203
+
204
+ ```text
205
+ docs/ Package documentation and draft model notes
206
+ templates/process/ Installed process scaffold
207
+ templates/next/ Installed Next.js route wrappers
208
+ templates/github/ Optional GitHub workflow placeholder
209
+ src/ TypeScript CLI, runtime, and MCP source
210
+ dist/ Runtime JavaScript CLI
211
+ ```
212
+
213
+ ## Design Principle
214
+
215
+ Use the scaffold to preserve the current thinking without freezing it. Prefer explicit draft status, open questions, TODOs, and editable configuration over hardcoded claims about how the model must work.
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/cli.js ADDED
@@ -0,0 +1,212 @@
1
+ #!/usr/bin/env node
2
+ import { initProject } from "./init.js";
3
+ import { checkRuntime } from "./runtime/check.js";
4
+ import { upgradeProject } from "./upgrade.js";
5
+ import { validateScaffold } from "./validate.js";
6
+ import { DXCOMPLETE_PACKAGE_VERSION } from "./version.js";
7
+ main(process.argv.slice(2)).catch((error) => {
8
+ const message = error instanceof Error ? error.message : String(error);
9
+ console.error(`dxcomplete: ${message}`);
10
+ process.exitCode = 1;
11
+ });
12
+ async function main(argv) {
13
+ const args = parseArgs(argv);
14
+ if (args.version) {
15
+ console.log(DXCOMPLETE_PACKAGE_VERSION);
16
+ return;
17
+ }
18
+ if (args.help || !args.command) {
19
+ printHelp();
20
+ return;
21
+ }
22
+ if (args.command === "init") {
23
+ const result = await initProject({
24
+ targetDir: args.targetDir,
25
+ force: args.force,
26
+ dryRun: args.dryRun,
27
+ includeGithubWorkflow: args.includeGithubWorkflow
28
+ });
29
+ if (args.dryRun) {
30
+ console.log(`Would initialize DX Complete scaffold in ${result.targetDir}`);
31
+ printList("Would write", result.planned);
32
+ printList("Would skip existing", result.skipped);
33
+ return;
34
+ }
35
+ console.log(`Initialized DX Complete scaffold in ${result.targetDir}`);
36
+ printList("Written", result.written);
37
+ printList("Skipped existing", result.skipped);
38
+ console.log("Review dxcomplete/docs/open-questions.md before treating the draft model as policy.");
39
+ return;
40
+ }
41
+ if (args.command === "upgrade") {
42
+ const result = await upgradeProject({
43
+ targetDir: args.targetDir,
44
+ apply: args.apply,
45
+ force: args.force
46
+ });
47
+ if (args.apply) {
48
+ console.log(result.manualReview.length > 0
49
+ ? `DX Complete upgrade requires manual review in ${result.targetDir}`
50
+ : `Upgraded DX Complete scaffold in ${result.targetDir}`);
51
+ printList("Written", result.written);
52
+ printList("Already current", result.unchanged);
53
+ printList("Manual review required", result.manualReview);
54
+ printList("User-owned scaffold drift", result.userOwnedDrift);
55
+ if (result.manualReview.length > 0) {
56
+ process.exitCode = 1;
57
+ }
58
+ return;
59
+ }
60
+ console.log(`Would upgrade DX Complete scaffold in ${result.targetDir}`);
61
+ console.log(`Package version ${result.packageVersion}; workspace compatibility ${result.workspaceCompatibility}.`);
62
+ printList("Would write", result.planned);
63
+ printList("Already current", result.unchanged);
64
+ printList("Manual review required", result.manualReview);
65
+ printList("User-owned scaffold drift", result.userOwnedDrift);
66
+ console.log("Run dxcomplete upgrade --apply to write compatibility-critical scaffold updates.");
67
+ return;
68
+ }
69
+ if (args.command === "validate") {
70
+ const result = await validateScaffold({
71
+ targetDir: args.targetDir,
72
+ packageLayout: args.packageLayout
73
+ });
74
+ if (result.ok) {
75
+ console.log(`DX Complete scaffold shape is valid in ${result.targetDir}`);
76
+ return;
77
+ }
78
+ console.error(`DX Complete scaffold is missing ${result.missing.length} required file(s):`);
79
+ for (const file of result.missing) {
80
+ console.error(`- ${file}`);
81
+ }
82
+ process.exitCode = 1;
83
+ return;
84
+ }
85
+ if (args.command === "check-runtime") {
86
+ const result = await checkRuntime({ envFile: args.envFile });
87
+ console.log(JSON.stringify(result, null, 2));
88
+ return;
89
+ }
90
+ throw new Error(`Unknown command "${args.command}".`);
91
+ }
92
+ function parseArgs(argv) {
93
+ const parsed = {
94
+ targetDir: process.cwd(),
95
+ force: false,
96
+ dryRun: false,
97
+ apply: false,
98
+ includeGithubWorkflow: true,
99
+ packageLayout: false,
100
+ help: false,
101
+ version: false
102
+ };
103
+ const positionals = [];
104
+ for (let index = 0; index < argv.length; index += 1) {
105
+ const arg = argv[index];
106
+ if (arg === "--help" || arg === "-h") {
107
+ parsed.help = true;
108
+ continue;
109
+ }
110
+ if (arg === "--apply") {
111
+ parsed.apply = true;
112
+ continue;
113
+ }
114
+ if (arg === "--version" || arg === "-v") {
115
+ parsed.version = true;
116
+ continue;
117
+ }
118
+ if (arg === "--target") {
119
+ const value = argv[index + 1];
120
+ if (!value) {
121
+ throw new Error("--target requires a directory.");
122
+ }
123
+ parsed.targetDir = value;
124
+ index += 1;
125
+ continue;
126
+ }
127
+ if (arg.startsWith("--target=")) {
128
+ parsed.targetDir = arg.slice("--target=".length);
129
+ continue;
130
+ }
131
+ if (arg === "--env") {
132
+ const value = argv[index + 1];
133
+ if (!value) {
134
+ throw new Error("--env requires a file path.");
135
+ }
136
+ parsed.envFile = value;
137
+ index += 1;
138
+ continue;
139
+ }
140
+ if (arg.startsWith("--env=")) {
141
+ parsed.envFile = arg.slice("--env=".length);
142
+ continue;
143
+ }
144
+ if (arg === "--force") {
145
+ parsed.force = true;
146
+ continue;
147
+ }
148
+ if (arg === "--dry-run") {
149
+ parsed.dryRun = true;
150
+ continue;
151
+ }
152
+ if (arg === "--no-github-workflow") {
153
+ parsed.includeGithubWorkflow = false;
154
+ continue;
155
+ }
156
+ if (arg === "--package-layout") {
157
+ parsed.packageLayout = true;
158
+ continue;
159
+ }
160
+ if (arg.startsWith("-")) {
161
+ throw new Error(`Unknown option "${arg}".`);
162
+ }
163
+ positionals.push(arg);
164
+ }
165
+ parsed.command = positionals[0];
166
+ if (positionals.length > 1) {
167
+ throw new Error(`Unexpected argument "${positionals[1]}".`);
168
+ }
169
+ if (parsed.apply && parsed.command !== "upgrade") {
170
+ throw new Error("--apply is only supported by upgrade.");
171
+ }
172
+ if (parsed.command === "upgrade" && parsed.apply && parsed.dryRun) {
173
+ throw new Error("upgrade cannot combine --apply and --dry-run.");
174
+ }
175
+ return parsed;
176
+ }
177
+ function printHelp() {
178
+ console.log(`dxcomplete
179
+
180
+ Usage:
181
+ dxcomplete init [--target <dir>] [--force] [--dry-run] [--no-github-workflow]
182
+ dxcomplete upgrade [--target <dir>] [--apply] [--force]
183
+ dxcomplete validate [--target <dir>]
184
+ dxcomplete check-runtime [--env <file>]
185
+
186
+ Commands:
187
+ init Install the editable draft scaffold into a project.
188
+ upgrade Preview or apply compatibility-critical scaffold updates.
189
+ validate Validate the expected scaffold file shape.
190
+ check-runtime Verify MongoDB connectivity and required collections.
191
+
192
+ Options:
193
+ --target <dir> Target project directory. Defaults to the current directory.
194
+ --env <file> Runtime env file. Defaults to .env.local when present.
195
+ --apply Write upgrade changes. Upgrade previews by default.
196
+ --force Overwrite existing scaffold files.
197
+ --dry-run Show what would be written without changing files.
198
+ --no-github-workflow Skip installing .github/workflows/dxcomplete.yml.
199
+ --package-layout Validate this package repository layout instead of an installed scaffold.
200
+ --help Show help.
201
+ --version Show version.
202
+ `);
203
+ }
204
+ function printList(label, values) {
205
+ if (values.length === 0) {
206
+ return;
207
+ }
208
+ console.log(`${label}:`);
209
+ for (const value of values) {
210
+ console.log(`- ${value}`);
211
+ }
212
+ }
@@ -0,0 +1,7 @@
1
+ import type { IncomingMessage, ServerResponse } from "node:http";
2
+ export declare function configureDxcompleteWorkspace(config: unknown): void;
3
+ export declare function closeDxcompleteHttpRuntime(): Promise<void>;
4
+ export default function handleDxcompleteHttpRequest(req: IncomingMessage & {
5
+ body?: unknown;
6
+ query?: Record<string, unknown>;
7
+ }, res: ServerResponse): Promise<void>;