@decohere/scaffold 0.0.1-dev.125 → 0.0.1-dev.18

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 (264) hide show
  1. package/package.json +9 -19
  2. package/src/add-api.action.ts +25 -0
  3. package/src/add-api.command.ts +31 -0
  4. package/src/add.command.ts +20 -0
  5. package/src/add.module.ts +11 -0
  6. package/src/cli.ts +4 -0
  7. package/src/create.command.ts +20 -0
  8. package/src/create.module.ts +11 -0
  9. package/src/domain/prompt.ts +50 -0
  10. package/{types/src/index.d.ts → src/index.ts} +0 -4
  11. package/src/models/compose.model.ts +205 -0
  12. package/src/models/config-yaml.model.ts +83 -0
  13. package/src/models/const.ts +20 -0
  14. package/src/models/dev-container.model.ts +136 -0
  15. package/src/models/docker-image.model.ts +343 -0
  16. package/src/models/env-file.model.ts +45 -0
  17. package/src/models/gitignore.model.ts +35 -0
  18. package/src/models/launch-json.model.ts +60 -0
  19. package/src/models/package-json.model.ts +169 -0
  20. package/src/models/project.model.ts +141 -0
  21. package/{types/src/models/source-file.d.ts → src/models/source-file.ts} +6 -4
  22. package/src/models/tsconfig.model.ts +29 -0
  23. package/src/models/vitest-config.model.ts +26 -0
  24. package/src/models/vscode-settings.model.ts +24 -0
  25. package/src/program.ts +63 -0
  26. package/{types/src/resolve-target-dir.d.ts → src/resolve-target-dir.ts} +4 -1
  27. package/src/services/scaffold.service.ts +89 -0
  28. package/src/version.ts +56 -0
  29. package/src/webapi/api-name.ts +73 -0
  30. package/src/webapi/cli-options.ts +56 -0
  31. package/{types/src/webapi/const.d.ts → src/webapi/const.ts} +21 -9
  32. package/src/webapi/create-api.ts +275 -0
  33. package/src/webapi/devcontainer/host-scripts.ts +35 -0
  34. package/src/webapi/features/auth.feature.ts +454 -0
  35. package/src/webapi/features/auth0-cli.ts +421 -0
  36. package/src/webapi/features/biome-format.ts +34 -0
  37. package/src/webapi/features/database.feature.ts +522 -0
  38. package/src/webapi/features/finalize.feature.ts +112 -0
  39. package/src/webapi/features/postman.feature.ts +287 -0
  40. package/src/webapi/models/api-package-json.model.ts +60 -0
  41. package/src/webapi/models/auth-config.model.ts +36 -0
  42. package/src/webapi/models/controller-source-file.model.ts +232 -0
  43. package/{es6/src/webapi/models/github-ci.model.js → src/webapi/models/github-ci.model.ts} +29 -27
  44. package/src/webapi/models/main-source-file.model.ts +208 -0
  45. package/src/webapi/models/production-dockerfile.model.ts +162 -0
  46. package/src/webapi/models/sample-files.model.ts +45 -0
  47. package/src/webapi/models/webapi-image.model.ts +21 -0
  48. package/src/webapi/postman/hello-openapi.ts +92 -0
  49. package/src/webapi/postman/local-view.ts +195 -0
  50. package/src/webapi/postman/openapi-to-postman.ts +208 -0
  51. package/src/webapi/workspace-readme.ts +192 -0
  52. package/src/webapi.action.ts +22 -0
  53. package/src/webapi.command.ts +41 -0
  54. package/tests/auth-postman.wiring.spec.ts +263 -0
  55. package/tests/auth0-cli.spec.ts +232 -0
  56. package/tests/biome-format.spec.ts +49 -0
  57. package/tests/cli.integration.spec.ts +658 -0
  58. package/tests/compose.model.spec.ts +51 -0
  59. package/tests/container-image.model.spec.ts +162 -0
  60. package/tests/dev-container.model.spec.ts +29 -0
  61. package/tests/devcontainer-base-image.spec.ts +32 -0
  62. package/tests/hello-di-inject.scaffold.spec.ts +18 -0
  63. package/tests/hello-route.contract.spec.ts +94 -0
  64. package/tests/package-json.order.spec.ts +59 -0
  65. package/tests/postman-from-openapi.spec.ts +197 -0
  66. package/tests/seed-devcontainer-templates.ts +40 -0
  67. package/tests/webapi/devcontainer/codebase-rag-mcp.spec.ts +96 -0
  68. package/LICENSE +0 -15
  69. package/commonjs/src/add-api.action.js +0 -37
  70. package/commonjs/src/add-api.command.js +0 -39
  71. package/commonjs/src/add.command.js +0 -22
  72. package/commonjs/src/add.module.js +0 -24
  73. package/commonjs/src/auth0-configure.action.js +0 -28
  74. package/commonjs/src/auth0-configure.command.js +0 -24
  75. package/commonjs/src/auth0-login.action.js +0 -28
  76. package/commonjs/src/auth0-login.command.js +0 -23
  77. package/commonjs/src/auth0.command.js +0 -22
  78. package/commonjs/src/auth0.module.js +0 -28
  79. package/commonjs/src/cli.js +0 -8
  80. package/commonjs/src/create.command.js +0 -22
  81. package/commonjs/src/create.module.js +0 -24
  82. package/commonjs/src/domain/prompt.js +0 -62
  83. package/commonjs/src/index.js +0 -48
  84. package/commonjs/src/models/compose.model.js +0 -258
  85. package/commonjs/src/models/config-yaml.model.js +0 -86
  86. package/commonjs/src/models/const.js +0 -30
  87. package/commonjs/src/models/dev-container.model.js +0 -172
  88. package/commonjs/src/models/docker-image.model.js +0 -277
  89. package/commonjs/src/models/env-file.model.js +0 -48
  90. package/commonjs/src/models/gitignore.model.js +0 -48
  91. package/commonjs/src/models/launch-json.model.js +0 -70
  92. package/commonjs/src/models/package-json.model.js +0 -156
  93. package/commonjs/src/models/project.model.js +0 -132
  94. package/commonjs/src/models/source-file.js +0 -4
  95. package/commonjs/src/models/tsconfig.model.js +0 -32
  96. package/commonjs/src/models/vitest-config.model.js +0 -33
  97. package/commonjs/src/models/vscode-settings.model.js +0 -29
  98. package/commonjs/src/program.js +0 -64
  99. package/commonjs/src/resolve-target-dir.js +0 -17
  100. package/commonjs/src/services/scaffold.service.js +0 -60
  101. package/commonjs/src/version.js +0 -55
  102. package/commonjs/src/webapi/api-name.js +0 -93
  103. package/commonjs/src/webapi/auth0-commands.js +0 -250
  104. package/commonjs/src/webapi/authorize-scopes.js +0 -79
  105. package/commonjs/src/webapi/cli-options.js +0 -99
  106. package/commonjs/src/webapi/const.js +0 -54
  107. package/commonjs/src/webapi/create-api.js +0 -265
  108. package/commonjs/src/webapi/devcontainer/codebase-rag-mcp.js +0 -164
  109. package/commonjs/src/webapi/devcontainer/codebase-rag-mcp.ts +0 -182
  110. package/commonjs/src/webapi/devcontainer/host-scripts.js +0 -50
  111. package/commonjs/src/webapi/devcontainer/templates/codebase-rag.env.example +0 -3
  112. package/commonjs/src/webapi/devcontainer/templates/initialize.sh +0 -169
  113. package/commonjs/src/webapi/devcontainer/templates/post-create.sh +0 -35
  114. package/commonjs/src/webapi/devcontainer/templates/post-start.sh +0 -65
  115. package/commonjs/src/webapi/devcontainer/templates/tty-prompt.sh +0 -38
  116. package/commonjs/src/webapi/features/auth.feature.js +0 -408
  117. package/commonjs/src/webapi/features/auth0-cli.js +0 -472
  118. package/commonjs/src/webapi/features/biome-format.js +0 -47
  119. package/commonjs/src/webapi/features/database.feature.js +0 -433
  120. package/commonjs/src/webapi/features/finalize.feature.js +0 -93
  121. package/commonjs/src/webapi/features/postman.feature.js +0 -322
  122. package/commonjs/src/webapi/models/api-package-json.model.js +0 -58
  123. package/commonjs/src/webapi/models/auth-config.model.js +0 -24
  124. package/commonjs/src/webapi/models/controller-source-file.model.js +0 -190
  125. package/commonjs/src/webapi/models/github-ci.model.js +0 -193
  126. package/commonjs/src/webapi/models/main-source-file.model.js +0 -165
  127. package/commonjs/src/webapi/models/production-dockerfile.model.js +0 -75
  128. package/commonjs/src/webapi/models/sample-files.model.js +0 -58
  129. package/commonjs/src/webapi/models/webapi-image.model.js +0 -25
  130. package/commonjs/src/webapi/postman/hello-openapi.js +0 -173
  131. package/commonjs/src/webapi/postman/local-view.js +0 -182
  132. package/commonjs/src/webapi/postman/openapi-to-postman.js +0 -238
  133. package/commonjs/src/webapi/workspace-readme.js +0 -109
  134. package/commonjs/src/webapi.action.js +0 -28
  135. package/commonjs/src/webapi.command.js +0 -43
  136. package/es6/src/add-api.action.js +0 -27
  137. package/es6/src/add-api.command.js +0 -29
  138. package/es6/src/add.command.js +0 -12
  139. package/es6/src/add.module.js +0 -14
  140. package/es6/src/auth0-configure.action.js +0 -18
  141. package/es6/src/auth0-configure.command.js +0 -14
  142. package/es6/src/auth0-login.action.js +0 -18
  143. package/es6/src/auth0-login.command.js +0 -13
  144. package/es6/src/auth0.command.js +0 -12
  145. package/es6/src/auth0.module.js +0 -18
  146. package/es6/src/cli.js +0 -4
  147. package/es6/src/create.command.js +0 -12
  148. package/es6/src/create.module.js +0 -14
  149. package/es6/src/domain/prompt.js +0 -41
  150. package/es6/src/index.js +0 -9
  151. package/es6/src/models/compose.model.js +0 -254
  152. package/es6/src/models/config-yaml.model.js +0 -74
  153. package/es6/src/models/const.js +0 -20
  154. package/es6/src/models/dev-container.model.js +0 -162
  155. package/es6/src/models/docker-image.model.js +0 -235
  156. package/es6/src/models/env-file.model.js +0 -44
  157. package/es6/src/models/gitignore.model.js +0 -38
  158. package/es6/src/models/launch-json.model.js +0 -60
  159. package/es6/src/models/package-json.model.js +0 -141
  160. package/es6/src/models/project.model.js +0 -117
  161. package/es6/src/models/source-file.js +0 -1
  162. package/es6/src/models/tsconfig.model.js +0 -22
  163. package/es6/src/models/vitest-config.model.js +0 -23
  164. package/es6/src/models/vscode-settings.model.js +0 -19
  165. package/es6/src/program.js +0 -50
  166. package/es6/src/resolve-target-dir.js +0 -7
  167. package/es6/src/services/scaffold.service.js +0 -50
  168. package/es6/src/version.js +0 -34
  169. package/es6/src/webapi/api-name.js +0 -57
  170. package/es6/src/webapi/auth0-commands.js +0 -185
  171. package/es6/src/webapi/authorize-scopes.js +0 -55
  172. package/es6/src/webapi/cli-options.js +0 -34
  173. package/es6/src/webapi/const.js +0 -21
  174. package/es6/src/webapi/create-api.js +0 -245
  175. package/es6/src/webapi/devcontainer/codebase-rag-mcp.js +0 -154
  176. package/es6/src/webapi/devcontainer/codebase-rag-mcp.ts +0 -182
  177. package/es6/src/webapi/devcontainer/host-scripts.js +0 -29
  178. package/es6/src/webapi/devcontainer/templates/codebase-rag.env.example +0 -3
  179. package/es6/src/webapi/devcontainer/templates/initialize.sh +0 -169
  180. package/es6/src/webapi/devcontainer/templates/post-create.sh +0 -35
  181. package/es6/src/webapi/devcontainer/templates/post-start.sh +0 -65
  182. package/es6/src/webapi/devcontainer/templates/tty-prompt.sh +0 -38
  183. package/es6/src/webapi/features/auth.feature.js +0 -357
  184. package/es6/src/webapi/features/auth0-cli.js +0 -406
  185. package/es6/src/webapi/features/biome-format.js +0 -40
  186. package/es6/src/webapi/features/database.feature.js +0 -423
  187. package/es6/src/webapi/features/finalize.feature.js +0 -83
  188. package/es6/src/webapi/features/postman.feature.js +0 -256
  189. package/es6/src/webapi/models/api-package-json.model.js +0 -53
  190. package/es6/src/webapi/models/auth-config.model.js +0 -20
  191. package/es6/src/webapi/models/controller-source-file.model.js +0 -181
  192. package/es6/src/webapi/models/main-source-file.model.js +0 -161
  193. package/es6/src/webapi/models/production-dockerfile.model.js +0 -66
  194. package/es6/src/webapi/models/sample-files.model.js +0 -40
  195. package/es6/src/webapi/models/webapi-image.model.js +0 -18
  196. package/es6/src/webapi/postman/hello-openapi.js +0 -166
  197. package/es6/src/webapi/postman/local-view.js +0 -167
  198. package/es6/src/webapi/postman/openapi-to-postman.js +0 -179
  199. package/es6/src/webapi/workspace-readme.js +0 -88
  200. package/es6/src/webapi.action.js +0 -18
  201. package/es6/src/webapi.command.js +0 -33
  202. package/types/src/add-api.action.d.ts +0 -13
  203. package/types/src/add-api.command.d.ts +0 -7
  204. package/types/src/add.command.d.ts +0 -6
  205. package/types/src/add.module.d.ts +0 -14
  206. package/types/src/auth0-configure.action.d.ts +0 -7
  207. package/types/src/auth0-configure.command.d.ts +0 -6
  208. package/types/src/auth0-login.action.d.ts +0 -4
  209. package/types/src/auth0-login.command.d.ts +0 -6
  210. package/types/src/auth0.command.d.ts +0 -6
  211. package/types/src/auth0.module.d.ts +0 -18
  212. package/types/src/cli.d.ts +0 -2
  213. package/types/src/create.command.d.ts +0 -6
  214. package/types/src/create.module.d.ts +0 -14
  215. package/types/src/domain/prompt.d.ts +0 -4
  216. package/types/src/models/compose.model.d.ts +0 -73
  217. package/types/src/models/config-yaml.model.d.ts +0 -27
  218. package/types/src/models/const.d.ts +0 -20
  219. package/types/src/models/dev-container.model.d.ts +0 -49
  220. package/types/src/models/docker-image.model.d.ts +0 -90
  221. package/types/src/models/env-file.model.d.ts +0 -16
  222. package/types/src/models/gitignore.model.d.ts +0 -9
  223. package/types/src/models/launch-json.model.d.ts +0 -7
  224. package/types/src/models/package-json.model.d.ts +0 -36
  225. package/types/src/models/project.model.d.ts +0 -60
  226. package/types/src/models/tsconfig.model.d.ts +0 -5
  227. package/types/src/models/vitest-config.model.d.ts +0 -5
  228. package/types/src/models/vscode-settings.model.d.ts +0 -7
  229. package/types/src/program.d.ts +0 -8
  230. package/types/src/services/scaffold.service.d.ts +0 -22
  231. package/types/src/version.d.ts +0 -6
  232. package/types/src/webapi/api-name.d.ts +0 -14
  233. package/types/src/webapi/auth0-commands.d.ts +0 -11
  234. package/types/src/webapi/authorize-scopes.d.ts +0 -7
  235. package/types/src/webapi/cli-options.d.ts +0 -6
  236. package/types/src/webapi/create-api.d.ts +0 -15
  237. package/types/src/webapi/devcontainer/codebase-rag-mcp.d.ts +0 -32
  238. package/types/src/webapi/devcontainer/codebase-rag-mcp.ts +0 -182
  239. package/types/src/webapi/devcontainer/host-scripts.d.ts +0 -7
  240. package/types/src/webapi/devcontainer/templates/codebase-rag.env.example +0 -3
  241. package/types/src/webapi/devcontainer/templates/initialize.sh +0 -169
  242. package/types/src/webapi/devcontainer/templates/post-create.sh +0 -35
  243. package/types/src/webapi/devcontainer/templates/post-start.sh +0 -65
  244. package/types/src/webapi/devcontainer/templates/tty-prompt.sh +0 -38
  245. package/types/src/webapi/features/auth.feature.d.ts +0 -10
  246. package/types/src/webapi/features/auth0-cli.d.ts +0 -84
  247. package/types/src/webapi/features/biome-format.d.ts +0 -5
  248. package/types/src/webapi/features/database.feature.d.ts +0 -7
  249. package/types/src/webapi/features/finalize.feature.d.ts +0 -2
  250. package/types/src/webapi/features/postman.feature.d.ts +0 -16
  251. package/types/src/webapi/models/api-package-json.model.d.ts +0 -18
  252. package/types/src/webapi/models/auth-config.model.d.ts +0 -26
  253. package/types/src/webapi/models/controller-source-file.model.d.ts +0 -46
  254. package/types/src/webapi/models/github-ci.model.d.ts +0 -9
  255. package/types/src/webapi/models/main-source-file.model.d.ts +0 -54
  256. package/types/src/webapi/models/production-dockerfile.model.d.ts +0 -18
  257. package/types/src/webapi/models/sample-files.model.d.ts +0 -7
  258. package/types/src/webapi/models/webapi-image.model.d.ts +0 -12
  259. package/types/src/webapi/postman/hello-openapi.d.ts +0 -19
  260. package/types/src/webapi/postman/local-view.d.ts +0 -17
  261. package/types/src/webapi/postman/openapi-to-postman.d.ts +0 -62
  262. package/types/src/webapi/workspace-readme.d.ts +0 -18
  263. package/types/src/webapi.action.d.ts +0 -14
  264. package/types/src/webapi.command.d.ts +0 -11
@@ -1,60 +0,0 @@
1
- import type { KeyedModel, SourceFile, SourceFileProvider } from "./source-file.js";
2
- /**
3
- * A sub-unit of the monorepo (e.g. `projects/api`).
4
- *
5
- * Models and files registered here produce paths relative to `dir`. The parent
6
- * `MonoRepoScaffold` calls `files()` and prepends `dir/` to every path, so
7
- * models remain unaware of where they live in the repo.
8
- */
9
- export declare class ProjectScaffold {
10
- readonly dir: string;
11
- private readonly _models;
12
- private readonly _files;
13
- constructor(dir: string);
14
- addModel<T extends KeyedModel>(model: T): T;
15
- addFile(provider: SourceFileProvider): this;
16
- getModel<T extends SourceFileProvider>(key: string): T | undefined;
17
- getModels<T extends SourceFileProvider>(ctor: new (...args: never[]) => T): T[];
18
- /** Returns all files with `dir/` prepended to each path. */
19
- files(): SourceFile[];
20
- }
21
- export declare abstract class WorkspaceScaffold {
22
- readonly files: SourceFile[];
23
- targetDir: string;
24
- private _name;
25
- /** Project name — host directory basename, not the in-container mount path. */
26
- get name(): string;
27
- setName(name: string): this;
28
- /** Add an ad-hoc file provider whose output is included at render time. */
29
- addFile(provider: SourceFileProvider): this;
30
- abstract addModel<T extends KeyedModel>(model: T): T;
31
- abstract getModel<T extends SourceFileProvider>(key: string): T | undefined;
32
- abstract getModels<T extends SourceFileProvider>(ctor: new (...args: never[]) => T): T[];
33
- abstract getProject(dir: string): ProjectScaffold | undefined;
34
- abstract getProjects(): readonly ProjectScaffold[];
35
- abstract scaffold(): Promise<void> | void;
36
- }
37
- export declare class MonoRepoScaffold extends WorkspaceScaffold {
38
- private readonly _models;
39
- private readonly _projects;
40
- /** Register a named project. */
41
- addProject(project: ProjectScaffold): ProjectScaffold;
42
- /** Retrieve a previously-registered project by its directory path. */
43
- getProject(dir: string): ProjectScaffold | undefined;
44
- /** All registered projects, in registration order. */
45
- getProjects(): readonly ProjectScaffold[];
46
- /** Register a named model at workspace level. */
47
- addModel<T extends KeyedModel>(model: T): T;
48
- /**
49
- * Retrieve a model by key. Searches workspace models first, then all
50
- * registered projects in order.
51
- */
52
- getModel<T extends SourceFileProvider>(key: string): T | undefined;
53
- /**
54
- * Retrieve all models of a given type. Searches workspace models and all
55
- * projects, so features can discover controllers across multiple projects.
56
- */
57
- getModels<T extends SourceFileProvider>(ctor: new (...args: never[]) => T): T[];
58
- /** Render all models and projects into files, then write everything to disk. */
59
- scaffold(): Promise<void>;
60
- }
@@ -1,5 +0,0 @@
1
- import type { KeyedModel, SourceFile } from "./source-file.js";
2
- export declare class TsConfig implements KeyedModel {
3
- readonly key: string;
4
- files(): SourceFile[];
5
- }
@@ -1,5 +0,0 @@
1
- import type { KeyedModel, SourceFile } from "./source-file.js";
2
- export declare class VitestConfig implements KeyedModel {
3
- readonly key: string;
4
- files(): SourceFile[];
5
- }
@@ -1,7 +0,0 @@
1
- import type { KeyedModel, SourceFile } from "./source-file.js";
2
- export declare class VSCodeSettings implements KeyedModel {
3
- private readonly title;
4
- readonly key: string;
5
- constructor(title: string);
6
- files(): SourceFile[];
7
- }
@@ -1,8 +0,0 @@
1
- import { Command } from "commander";
2
- export declare function createProgram(): Command;
3
- /**
4
- * Runs the CLI and returns its exit code; the bin (`cli.ts`) exits with it. Returning instead
5
- * of calling `process.exit` here lets tests run it in process: a run that finished after its
6
- * test had timed out used to call `process.exit` in whichever test came next (#662).
7
- */
8
- export declare function runCli(argv?: string[]): Promise<number>;
@@ -1,22 +0,0 @@
1
- import type { WorkspaceScaffold } from "../models/project.model.js";
2
- /**
3
- * A feature has three responsibilities:
4
- * 1. `getOptions` — resolve provider selection and any follow-up questions.
5
- * Receives the options collected so far; returns only the keys it owns.
6
- * Short-circuits if the caller already supplied those keys via CLI flags.
7
- * 2. `scaffold` — mutate the workspace models and/or write files using the
8
- * fully-resolved options. Called after ALL features have gathered options
9
- * but BEFORE files are written to disk.
10
- * 3. `finalize` (optional) — run post-write actions (e.g. install dependencies).
11
- * Called after workspace.scaffold() has flushed all files to disk.
12
- */
13
- export interface Feature<TOptions extends object = object> {
14
- getOptions(workspace: WorkspaceScaffold, cliOptions: Partial<TOptions>): Promise<Partial<TOptions>>;
15
- scaffold(workspace: WorkspaceScaffold, options: TOptions): Promise<void> | void;
16
- finalize?(workspace: WorkspaceScaffold, options: TOptions): Promise<void> | void;
17
- }
18
- declare function scaffold(workspace: WorkspaceScaffold, cliOptions: object, features: Feature[]): Promise<void>;
19
- export declare const ScaffoldService: {
20
- scaffold: typeof scaffold;
21
- };
22
- export {};
@@ -1,6 +0,0 @@
1
- /** Version of @decohere/create, used to pin scaffolded @decohere/* dependencies. */
2
- export declare const CREATE_VERSION: string;
3
- /** Canonical published Docker repository for the @decohere/create builder image. */
4
- export declare const CREATE_IMAGE_REPOSITORY: string;
5
- /** Published app Dev Container base (`docker pull` updates shared layers). */
6
- export declare const DEVCONTAINER_IMAGE_REPOSITORY: string;
@@ -1,14 +0,0 @@
1
- /** Lowercase npm-safe directory slug: `billing`, `admin-api`. */
2
- export declare const API_NAME_PATTERN: RegExp;
3
- export declare class CreateCliError extends Error {
4
- constructor(message: string);
5
- }
6
- export declare function assertValidApiName(name: string): void;
7
- /** Default `["api"]` when the caller omitted `--name`. Rejects duplicates and invalid slugs. */
8
- export declare function parseApiNames(raw: readonly string[] | undefined): string[];
9
- export declare function isDecohereWorkspace(dir: string): boolean;
10
- /** Directory names under `projects/` that already have a `package.json`. */
11
- export declare function listExistingApiNames(dir: string): string[];
12
- /** `billing` → `BILLING`, `admin-api` → `ADMIN_API` — prefix for `{PREFIX}_DB_HOST`. */
13
- export declare function apiEnvPrefix(apiName: string): string;
14
- export declare function apiNameFromProjectDir(dir: string): string;
@@ -1,11 +0,0 @@
1
- import * as auth0Cli from "./features/auth0-cli.js";
2
- export declare const AUTH0_CLI_INSTALL_MESSAGE: string;
3
- /** Throw if the `auth0` binary is missing. */
4
- export declare function requireInstalled(): void;
5
- /**
6
- * Log in when there is no tenant session or the Management API token is expired.
7
- * Returns the active tenant.
8
- */
9
- export declare function ensureLoggedIn(): auth0Cli.Auth0Tenant;
10
- export declare function runAuth0Login(): void;
11
- export declare function runAuth0Configure(directory?: string): void;
@@ -1,7 +0,0 @@
1
- /** OIDC scopes requested on the Postman SPA token (not Auth0 API permissions). */
2
- export declare const OIDC_SCOPES: readonly ["openid", "profile", "email"];
3
- /** Collect action:Subject scopes from Authorize decorators in each API src tree. */
4
- export declare function discoverAuthorizeScopes(rootDir: string): string[];
5
- /** Additive union so Auth0 CLI scope replace does not drop permissions already on the API. */
6
- export declare function mergeApiScopes(discovered: readonly string[], existing: readonly string[]): string[];
7
- export declare function postmanRequestedScopes(apiScopes: readonly string[]): string;
@@ -1,6 +0,0 @@
1
- import type { Command } from "commander";
2
- import type { ApiOptions } from "./create-api.js";
3
- export declare function collectName(value: string, previous: string[]): string[];
4
- export declare function addWebapiFeatureOptions(cmd: Command): Command;
5
- export declare function toApiOptions(directory: string | undefined, opts: Record<string, unknown>, extra?: Partial<ApiOptions>): ApiOptions;
6
- export declare function runScaffoldApi(normalized: ApiOptions): Promise<void>;
@@ -1,15 +0,0 @@
1
- export { WEBAPI_PROJECT_DIR, WEBAPI_RELEASE_ENTRY } from "./const.js";
2
- export type ApiOptions = {
3
- d?: string;
4
- /** Host project name (directory basename). Required when scaffolding into the create-builder `/workspace` mount. */
5
- projectName?: string;
6
- /** API slugs under `projects/`. Default `["api"]`. Repeatable `--name`. */
7
- names?: string[];
8
- /** Add APIs to an existing Decohere workspace instead of creating a new one. */
9
- add?: boolean;
10
- authProvider?: "auth0" | "none";
11
- databaseProvider?: "none" | "postgres/typeorm";
12
- postmanProvider?: "api" | "local" | "none";
13
- installDependencies?: "yes" | "no";
14
- };
15
- export declare function scaffoldApi(cliOptions: ApiOptions): Promise<void>;
@@ -1,32 +0,0 @@
1
- export type CodebaseRagCredentials = {
2
- url: string;
3
- token: string;
4
- };
5
- export type McpJson = {
6
- mcpServers?: Record<string, unknown>;
7
- [key: string]: unknown;
8
- };
9
- declare function loadDotenv(path: string, env: NodeJS.ProcessEnv): void;
10
- declare function seedFromMcpJson(raw: string): CodebaseRagCredentials | null;
11
- declare function mergeIntoMcpJson(input: {
12
- mcpPath: string;
13
- url: string;
14
- token: string;
15
- hostRoot: string;
16
- }): {
17
- skipped?: string;
18
- path?: string;
19
- root?: string;
20
- };
21
- declare function mergeFromEnv(env?: NodeJS.ProcessEnv): number;
22
- declare function seedPrint(mcpPath: string): number;
23
- declare function main(argv?: string[]): number;
24
- export declare const codebaseRagMcp: {
25
- loadDotenv: typeof loadDotenv;
26
- seedFromMcpJson: typeof seedFromMcpJson;
27
- mergeIntoMcpJson: typeof mergeIntoMcpJson;
28
- mergeFromEnv: typeof mergeFromEnv;
29
- seedPrint: typeof seedPrint;
30
- main: typeof main;
31
- };
32
- export {};
@@ -1,182 +0,0 @@
1
- import {
2
- chmodSync,
3
- mkdirSync,
4
- readFileSync,
5
- renameSync,
6
- statSync,
7
- writeFileSync,
8
- } from "node:fs";
9
- import { dirname, join } from "node:path";
10
- import { fileURLToPath } from "node:url";
11
-
12
- export type CodebaseRagCredentials = {
13
- url: string;
14
- token: string;
15
- };
16
-
17
- export type McpJson = {
18
- mcpServers?: Record<string, unknown>;
19
- [key: string]: unknown;
20
- };
21
-
22
- function isRecord(value: unknown): value is Record<string, unknown> {
23
- return value != null && typeof value === "object" && !Array.isArray(value);
24
- }
25
-
26
- function loadDotenv(path: string, env: NodeJS.ProcessEnv): void {
27
- let raw: string;
28
- try {
29
- raw = readFileSync(path, "utf8");
30
- } catch {
31
- return;
32
- }
33
- for (const line of raw.split(/\r?\n/)) {
34
- const trimmed = line.trim();
35
- if (!trimmed || trimmed.startsWith("#") || !trimmed.includes("=")) continue;
36
- const eq = trimmed.indexOf("=");
37
- const key = trimmed.slice(0, eq).trim();
38
- const value = trimmed
39
- .slice(eq + 1)
40
- .trim()
41
- .replace(/^["']|["']$/g, "");
42
- if (key && env[key] === undefined) env[key] = value;
43
- }
44
- }
45
-
46
- function seedFromMcpJson(raw: string): CodebaseRagCredentials | null {
47
- let data: unknown;
48
- try {
49
- data = JSON.parse(raw);
50
- } catch {
51
- return null;
52
- }
53
- if (!isRecord(data)) return null;
54
- const servers = data.mcpServers;
55
- if (!isRecord(servers)) return null;
56
- const server = servers["codebase-rag"];
57
- if (!isRecord(server)) return null;
58
- const url = typeof server.url === "string" ? server.url.trim() : "";
59
- const headers = isRecord(server.headers) ? server.headers : {};
60
- const auth = typeof headers.Authorization === "string" ? headers.Authorization.trim() : "";
61
- const token = auth.toLowerCase().startsWith("bearer ") ? auth.slice(7).trim() : "";
62
- if (!url.startsWith("http") || token.length === 0) return null;
63
- return { url, token };
64
- }
65
-
66
- function mergeIntoMcpJson(input: {
67
- mcpPath: string;
68
- url: string;
69
- token: string;
70
- hostRoot: string;
71
- }): { skipped?: string; path?: string; root?: string } {
72
- const { mcpPath, url, token, hostRoot } = input;
73
- if (!url || !token) {
74
- return { skipped: "no URL/token" };
75
- }
76
-
77
- const xRoot = hostRoot || "${workspaceFolder}";
78
- mkdirSync(dirname(mcpPath), { recursive: true });
79
-
80
- let data: McpJson = { mcpServers: {} };
81
- try {
82
- if (statSync(mcpPath).size > 0) {
83
- const loaded: unknown = JSON.parse(readFileSync(mcpPath, "utf8"));
84
- if (isRecord(loaded)) data = loaded as McpJson;
85
- }
86
- } catch (err) {
87
- const code = isRecord(err) && typeof err.code === "string" ? err.code : "";
88
- if (code !== "ENOENT") {
89
- console.log(
90
- "codebase-rag MCP: existing mcp.json is invalid JSON; replacing rag entry only after backup",
91
- );
92
- renameSync(mcpPath, `${mcpPath}.bak`);
93
- }
94
- }
95
-
96
- const servers = isRecord(data.mcpServers) ? data.mcpServers : {};
97
- data.mcpServers = servers;
98
- servers["codebase-rag"] = {
99
- url,
100
- headers: {
101
- Authorization: `Bearer ${token}`,
102
- "X-Codebase-Root": xRoot,
103
- },
104
- };
105
- writeFileSync(mcpPath, `${JSON.stringify(data, null, 2)}\n`, "utf8");
106
- try {
107
- chmodSync(mcpPath, 0o600);
108
- } catch {
109
- // memfs and some hosts omit chmod
110
- }
111
- return { path: mcpPath, root: xRoot };
112
- }
113
-
114
- function workspaceRoot(env: NodeJS.ProcessEnv = process.env): string {
115
- const fromEnv = env.CODEBASE_RAG_WORKSPACE?.trim();
116
- if (fromEnv) return fromEnv;
117
- // Scaffolded copy lives at <repo>/.devcontainer/codebase-rag-mcp.ts
118
- return dirname(dirname(fileURLToPath(import.meta.url)));
119
- }
120
-
121
- function mergeFromEnv(env: NodeJS.ProcessEnv = process.env): number {
122
- const root = workspaceRoot(env);
123
- const cursorDir = join(root, ".cursor");
124
- loadDotenv(join(cursorDir, "codebase-rag.env"), env);
125
- const url = (env.CODEBASE_RAG_MCP_URL ?? "").trim();
126
- const token = (env.CODEBASE_RAG_MCP_TOKEN ?? "").trim();
127
- const hostRoot = (env.CODEBASE_RAG_MCP_ROOT ?? "").trim() || root;
128
- const result = mergeIntoMcpJson({
129
- mcpPath: join(cursorDir, "mcp.json"),
130
- url,
131
- token,
132
- hostRoot,
133
- });
134
- if (result.skipped != null) {
135
- console.log(`codebase-rag MCP: skipped (${result.skipped})`);
136
- return 0;
137
- }
138
- console.log(`codebase-rag MCP: wrote ${result.path} url=${url} root=${result.root}`);
139
- return 0;
140
- }
141
-
142
- function seedPrint(mcpPath: string): number {
143
- let raw: string;
144
- try {
145
- raw = readFileSync(mcpPath, "utf8");
146
- } catch {
147
- return 1;
148
- }
149
- const creds = seedFromMcpJson(raw);
150
- if (creds == null) return 1;
151
- console.log(creds.url);
152
- console.log(creds.token);
153
- return 0;
154
- }
155
-
156
- function main(argv = process.argv.slice(2)): number {
157
- const command = argv[0] ?? "merge";
158
- if (command === "seed-print") {
159
- const mcpPath = argv[1];
160
- if (mcpPath == null || mcpPath.length === 0) return 1;
161
- return seedPrint(mcpPath);
162
- }
163
- if (command === "merge") {
164
- return mergeFromEnv();
165
- }
166
- console.error(`codebase-rag MCP: unknown command ${command}`);
167
- return 1;
168
- }
169
-
170
- const invoked = (process.argv[1] ?? "").replaceAll("\\", "/");
171
- if (invoked.endsWith("/codebase-rag-mcp.ts") || invoked.endsWith("/codebase-rag-mcp.js")) {
172
- process.exit(main());
173
- }
174
-
175
- export const codebaseRagMcp = {
176
- loadDotenv,
177
- seedFromMcpJson,
178
- mergeIntoMcpJson,
179
- mergeFromEnv,
180
- seedPrint,
181
- main,
182
- };
@@ -1,7 +0,0 @@
1
- import type { SourceFile, SourceFileProvider } from "../../models/source-file.js";
2
- export declare function devcontainerTemplatePath(name: string): string;
3
- export declare function codebaseRagMcpSourcePath(): string;
4
- /** Host + container scripts for the scaffolded Dev Container. */
5
- export declare class DevContainerHostScripts implements SourceFileProvider {
6
- files(): SourceFile[];
7
- }
@@ -1,3 +0,0 @@
1
- # Optional. Written to .cursor/codebase-rag.env by initialize.sh (gitignored).
2
- # CODEBASE_RAG_MCP_URL=https://rag.example.com/mcp
3
- # CODEBASE_RAG_MCP_TOKEN=
@@ -1,169 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Runs on the host before the container is created (devcontainer initializeCommand).
3
- # Creates bind-mount sources as the host user so Docker does not create them as root.
4
- # Optional npm / gh / MCP setup is y/N on a TTY; no TTY skips.
5
- set -euo pipefail
6
-
7
- root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
8
- here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
9
- # shellcheck source=tty-prompt.sh
10
- source "$here/tty-prompt.sh"
11
-
12
- npm_dir="$root/.devcontainer/npm-auth"
13
- gh_dir="$root/.devcontainer/gh-auth"
14
- gh_env="$root/.devcontainer/gh.env"
15
- cursor_dir="$root/.cursor"
16
- RAG_ENV="$cursor_dir/codebase-rag.env"
17
-
18
- run_codebase_rag_mcp() {
19
- local script="$here/codebase-rag-mcp.ts"
20
- CODEBASE_RAG_WORKSPACE="$root" node --experimental-strip-types "$script" "$@"
21
- }
22
-
23
- load_rag_env() {
24
- RAG_URL=""
25
- RAG_TOKEN=""
26
- [[ -f "$RAG_ENV" ]] || return 0
27
- # shellcheck disable=SC1090
28
- set -a
29
- # shellcheck disable=SC1090
30
- source "$RAG_ENV"
31
- set +a
32
- RAG_URL="${CODEBASE_RAG_MCP_URL:-}"
33
- RAG_TOKEN="${CODEBASE_RAG_MCP_TOKEN:-}"
34
- }
35
-
36
- write_rag_env() {
37
- mkdir -p "$(dirname "$RAG_ENV")"
38
- umask 077
39
- cat >"$RAG_ENV" <<EOF
40
- # Written by .devcontainer/initialize.sh. Not in git.
41
- CODEBASE_RAG_MCP_URL=${RAG_URL}
42
- CODEBASE_RAG_MCP_TOKEN=${RAG_TOKEN}
43
- CODEBASE_RAG_MCP_ROOT=${root}
44
- EOF
45
- chmod 600 "$RAG_ENV"
46
- if [[ -n "$RAG_URL" && -n "$RAG_TOKEN" ]]; then
47
- run_codebase_rag_mcp merge || true
48
- fi
49
- }
50
-
51
- seed_rag_from_host_mcp() {
52
- local mcp="${HOME}/.cursor/mcp.json"
53
- [[ -f "$mcp" ]] || return 1
54
- command -v node >/dev/null 2>&1 || return 1
55
- run_codebase_rag_mcp seed-print "$mcp"
56
- }
57
-
58
- ensure_cursor_dir() {
59
- mkdir -p "$cursor_dir"
60
- }
61
-
62
- ensure_auth_dir() {
63
- local dir="$1"
64
- if ! mkdir -p "$dir" 2>/dev/null; then
65
- echo "Cannot create $dir (permission denied)." >&2
66
- echo "The scaffold container likely left .devcontainer root-owned. Fix with:" >&2
67
- echo " sudo chown -R \"$USER:$USER\" \"$root\"" >&2
68
- exit 1
69
- fi
70
- {
71
- echo "*"
72
- echo "!.gitignore"
73
- } >"$dir/.gitignore"
74
- }
75
-
76
- ensure_gh_env() {
77
- if [[ -d "$gh_env" ]]; then
78
- echo "Refusing to start: $gh_env is a directory (left by a prior bind mount). Remove it and rebuild." >&2
79
- exit 1
80
- fi
81
- touch "$gh_env"
82
- }
83
-
84
- setup_npm_auth() {
85
- if [[ -f "$npm_dir/.npmrc" ]]; then
86
- echo "npm auth: using $npm_dir/.npmrc"
87
- return 0
88
- fi
89
- if ! prompt_yn "Configure npm auth for this workspace?"; then
90
- echo "npm auth: skipped"
91
- return 0
92
- fi
93
- if [[ -f "${HOME}/.npmrc" ]]; then
94
- cp -a "${HOME}/.npmrc" "$npm_dir/.npmrc"
95
- echo "npm auth: copied ~/.npmrc → $npm_dir/.npmrc"
96
- return 0
97
- fi
98
- echo "npm auth: no ~/.npmrc — log in inside the container if prompted"
99
- }
100
-
101
- setup_gh_auth() {
102
- if [[ -f "$gh_dir/hosts.yml" ]]; then
103
- echo "gh auth: using $gh_dir/hosts.yml"
104
- return 0
105
- fi
106
- if ! prompt_yn "Configure GitHub CLI auth for this workspace?"; then
107
- echo "gh auth: skipped"
108
- return 0
109
- fi
110
- if [[ -f "${HOME}/.config/gh/hosts.yml" ]]; then
111
- cp -a "${HOME}/.config/gh/hosts.yml" "$gh_dir/hosts.yml"
112
- [[ -f "${HOME}/.config/gh/config.yml" ]] &&
113
- cp -a "${HOME}/.config/gh/config.yml" "$gh_dir/config.yml"
114
- echo "gh auth: copied ~/.config/gh → $gh_dir"
115
- return 0
116
- fi
117
- echo "gh auth: no ~/.config/gh/hosts.yml — log in inside the container if prompted"
118
- }
119
-
120
- setup_codebase_rag_env() {
121
- load_rag_env
122
- if [[ -n "$RAG_URL" && -n "$RAG_TOKEN" ]]; then
123
- write_rag_env
124
- echo "codebase-rag MCP: using $RAG_ENV"
125
- return 0
126
- fi
127
-
128
- local seeded
129
- if seeded="$(seed_rag_from_host_mcp 2>/dev/null)"; then
130
- if prompt_yn "Found codebase-rag in ~/.cursor/mcp.json. Use it for this workspace?" y; then
131
- RAG_URL="$(printf '%s\n' "$seeded" | sed -n '1p')"
132
- RAG_TOKEN="$(printf '%s\n' "$seeded" | sed -n '2p')"
133
- write_rag_env
134
- echo "codebase-rag MCP: imported HTTP server from ~/.cursor/mcp.json → $RAG_ENV"
135
- return 0
136
- fi
137
- fi
138
-
139
- if ! prompt_yn "Configure codebase RAG MCP (semantic search)?"; then
140
- RAG_URL=""
141
- RAG_TOKEN=""
142
- write_rag_env
143
- echo "codebase-rag MCP: skipped"
144
- return 0
145
- fi
146
-
147
- printf '%s\n' "Empty URL skips. Example: https://rag.example.com/mcp" >/dev/tty
148
- printf '%s' "MCP URL: " >/dev/tty
149
- read_tty RAG_URL
150
- RAG_URL="$(printf '%s' "$RAG_URL" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')"
151
- if [[ -z "$RAG_URL" ]]; then
152
- RAG_TOKEN=""
153
- write_rag_env
154
- echo "codebase-rag MCP: skipped"
155
- return 0
156
- fi
157
- printf '%s' "Bearer token (hidden): " >/dev/tty
158
- read_tty RAG_TOKEN hidden
159
- write_rag_env
160
- echo "codebase-rag MCP: saved $RAG_ENV"
161
- }
162
-
163
- ensure_auth_dir "$npm_dir"
164
- ensure_auth_dir "$gh_dir"
165
- ensure_gh_env
166
- ensure_cursor_dir
167
- setup_npm_auth
168
- setup_gh_auth
169
- setup_codebase_rag_env
@@ -1,35 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Runs after container create and when workspace content updates
3
- # (devcontainer postCreateCommand / updateContentCommand).
4
- # Installs deps when missing or when the lockfile changed; skips otherwise.
5
- set -euo pipefail
6
-
7
- root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
8
- cd "$root"
9
-
10
- lockfile="pnpm-lock.yaml"
11
- stamp="node_modules/.decohere-pnpm-lock.sha"
12
-
13
- current_hash=""
14
- if [[ -f "$lockfile" ]]; then
15
- current_hash="$(sha256sum "$lockfile" | awk '{print $1}')"
16
- elif [[ -f package.json ]]; then
17
- current_hash="$(sha256sum package.json | awk '{print $1}')"
18
- fi
19
-
20
- if [[ -d node_modules/.bin ]] && [[ -n "$current_hash" ]] && [[ -f "$stamp" ]] && [[ "$(cat "$stamp")" == "$current_hash" ]]; then
21
- echo "node_modules: up to date, skipping pnpm install"
22
- exit 0
23
- fi
24
-
25
- echo "node_modules: installing dependencies (first create may take a while)..."
26
- if [[ -f "$lockfile" ]]; then
27
- pnpm install --frozen-lockfile
28
- else
29
- pnpm install
30
- fi
31
-
32
- if [[ -n "$current_hash" ]]; then
33
- mkdir -p node_modules
34
- printf '%s\n' "$current_hash" >"$stamp"
35
- fi