@decohere/scaffold 0.0.1-dev.100
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.
- package/commonjs/src/add-api.action.js +37 -0
- package/commonjs/src/add-api.command.js +39 -0
- package/commonjs/src/add.command.js +22 -0
- package/commonjs/src/add.module.js +24 -0
- package/commonjs/src/auth0-configure.action.js +28 -0
- package/commonjs/src/auth0-configure.command.js +24 -0
- package/commonjs/src/auth0-login.action.js +28 -0
- package/commonjs/src/auth0-login.command.js +23 -0
- package/commonjs/src/auth0.command.js +22 -0
- package/commonjs/src/auth0.module.js +28 -0
- package/commonjs/src/cli.js +7 -0
- package/commonjs/src/create.command.js +22 -0
- package/commonjs/src/create.module.js +24 -0
- package/commonjs/src/domain/prompt.js +62 -0
- package/commonjs/src/index.js +48 -0
- package/commonjs/src/models/compose.model.js +258 -0
- package/commonjs/src/models/config-yaml.model.js +86 -0
- package/commonjs/src/models/const.js +30 -0
- package/commonjs/src/models/dev-container.model.js +172 -0
- package/commonjs/src/models/docker-image.model.js +277 -0
- package/commonjs/src/models/env-file.model.js +48 -0
- package/commonjs/src/models/gitignore.model.js +48 -0
- package/commonjs/src/models/launch-json.model.js +70 -0
- package/commonjs/src/models/package-json.model.js +156 -0
- package/commonjs/src/models/project.model.js +132 -0
- package/commonjs/src/models/source-file.js +4 -0
- package/commonjs/src/models/tsconfig.model.js +32 -0
- package/commonjs/src/models/vitest-config.model.js +33 -0
- package/commonjs/src/models/vscode-settings.model.js +29 -0
- package/commonjs/src/program.js +64 -0
- package/commonjs/src/resolve-target-dir.js +17 -0
- package/commonjs/src/services/scaffold.service.js +60 -0
- package/commonjs/src/version.js +55 -0
- package/commonjs/src/webapi/api-name.js +93 -0
- package/commonjs/src/webapi/auth0-commands.js +250 -0
- package/commonjs/src/webapi/authorize-scopes.js +79 -0
- package/commonjs/src/webapi/cli-options.js +99 -0
- package/commonjs/src/webapi/const.js +54 -0
- package/commonjs/src/webapi/create-api.js +265 -0
- package/commonjs/src/webapi/devcontainer/codebase-rag-mcp.js +164 -0
- package/commonjs/src/webapi/devcontainer/codebase-rag-mcp.ts +182 -0
- package/commonjs/src/webapi/devcontainer/host-scripts.js +50 -0
- package/commonjs/src/webapi/devcontainer/templates/codebase-rag.env.example +3 -0
- package/commonjs/src/webapi/devcontainer/templates/initialize.sh +169 -0
- package/commonjs/src/webapi/devcontainer/templates/post-create.sh +35 -0
- package/commonjs/src/webapi/devcontainer/templates/post-start.sh +65 -0
- package/commonjs/src/webapi/devcontainer/templates/tty-prompt.sh +38 -0
- package/commonjs/src/webapi/features/auth.feature.js +408 -0
- package/commonjs/src/webapi/features/auth0-cli.js +472 -0
- package/commonjs/src/webapi/features/biome-format.js +47 -0
- package/commonjs/src/webapi/features/database.feature.js +432 -0
- package/commonjs/src/webapi/features/finalize.feature.js +93 -0
- package/commonjs/src/webapi/features/postman.feature.js +322 -0
- package/commonjs/src/webapi/models/api-package-json.model.js +58 -0
- package/commonjs/src/webapi/models/auth-config.model.js +24 -0
- package/commonjs/src/webapi/models/controller-source-file.model.js +190 -0
- package/commonjs/src/webapi/models/github-ci.model.js +193 -0
- package/commonjs/src/webapi/models/main-source-file.model.js +165 -0
- package/commonjs/src/webapi/models/production-dockerfile.model.js +75 -0
- package/commonjs/src/webapi/models/sample-files.model.js +58 -0
- package/commonjs/src/webapi/models/webapi-image.model.js +25 -0
- package/commonjs/src/webapi/postman/hello-openapi.js +173 -0
- package/commonjs/src/webapi/postman/local-view.js +182 -0
- package/commonjs/src/webapi/postman/openapi-to-postman.js +200 -0
- package/commonjs/src/webapi/workspace-readme.js +109 -0
- package/commonjs/src/webapi.action.js +28 -0
- package/commonjs/src/webapi.command.js +43 -0
- package/es6/src/add-api.action.js +27 -0
- package/es6/src/add-api.command.js +29 -0
- package/es6/src/add.command.js +12 -0
- package/es6/src/add.module.js +14 -0
- package/es6/src/auth0-configure.action.js +18 -0
- package/es6/src/auth0-configure.command.js +14 -0
- package/es6/src/auth0-login.action.js +18 -0
- package/es6/src/auth0-login.command.js +13 -0
- package/es6/src/auth0.command.js +12 -0
- package/es6/src/auth0.module.js +18 -0
- package/es6/src/cli.js +3 -0
- package/es6/src/create.command.js +12 -0
- package/es6/src/create.module.js +14 -0
- package/es6/src/domain/prompt.js +41 -0
- package/es6/src/index.js +9 -0
- package/es6/src/models/compose.model.js +254 -0
- package/es6/src/models/config-yaml.model.js +74 -0
- package/es6/src/models/const.js +20 -0
- package/es6/src/models/dev-container.model.js +162 -0
- package/es6/src/models/docker-image.model.js +235 -0
- package/es6/src/models/env-file.model.js +44 -0
- package/es6/src/models/gitignore.model.js +38 -0
- package/es6/src/models/launch-json.model.js +60 -0
- package/es6/src/models/package-json.model.js +141 -0
- package/es6/src/models/project.model.js +117 -0
- package/es6/src/models/source-file.js +1 -0
- package/es6/src/models/tsconfig.model.js +22 -0
- package/es6/src/models/vitest-config.model.js +23 -0
- package/es6/src/models/vscode-settings.model.js +19 -0
- package/es6/src/program.js +46 -0
- package/es6/src/resolve-target-dir.js +7 -0
- package/es6/src/services/scaffold.service.js +50 -0
- package/es6/src/version.js +34 -0
- package/es6/src/webapi/api-name.js +57 -0
- package/es6/src/webapi/auth0-commands.js +185 -0
- package/es6/src/webapi/authorize-scopes.js +55 -0
- package/es6/src/webapi/cli-options.js +34 -0
- package/es6/src/webapi/const.js +21 -0
- package/es6/src/webapi/create-api.js +245 -0
- package/es6/src/webapi/devcontainer/codebase-rag-mcp.js +154 -0
- package/es6/src/webapi/devcontainer/codebase-rag-mcp.ts +182 -0
- package/es6/src/webapi/devcontainer/host-scripts.js +29 -0
- package/es6/src/webapi/devcontainer/templates/codebase-rag.env.example +3 -0
- package/es6/src/webapi/devcontainer/templates/initialize.sh +169 -0
- package/es6/src/webapi/devcontainer/templates/post-create.sh +35 -0
- package/es6/src/webapi/devcontainer/templates/post-start.sh +65 -0
- package/es6/src/webapi/devcontainer/templates/tty-prompt.sh +38 -0
- package/es6/src/webapi/features/auth.feature.js +357 -0
- package/es6/src/webapi/features/auth0-cli.js +406 -0
- package/es6/src/webapi/features/biome-format.js +40 -0
- package/es6/src/webapi/features/database.feature.js +422 -0
- package/es6/src/webapi/features/finalize.feature.js +83 -0
- package/es6/src/webapi/features/postman.feature.js +256 -0
- package/es6/src/webapi/models/api-package-json.model.js +53 -0
- package/es6/src/webapi/models/auth-config.model.js +20 -0
- package/es6/src/webapi/models/controller-source-file.model.js +181 -0
- package/es6/src/webapi/models/github-ci.model.js +186 -0
- package/es6/src/webapi/models/main-source-file.model.js +161 -0
- package/es6/src/webapi/models/production-dockerfile.model.js +66 -0
- package/es6/src/webapi/models/sample-files.model.js +40 -0
- package/es6/src/webapi/models/webapi-image.model.js +18 -0
- package/es6/src/webapi/postman/hello-openapi.js +166 -0
- package/es6/src/webapi/postman/local-view.js +167 -0
- package/es6/src/webapi/postman/openapi-to-postman.js +177 -0
- package/es6/src/webapi/workspace-readme.js +88 -0
- package/es6/src/webapi.action.js +18 -0
- package/es6/src/webapi.command.js +33 -0
- package/package.json +36 -0
- package/src/webapi/devcontainer/codebase-rag-mcp.ts +182 -0
- package/src/webapi/devcontainer/templates/codebase-rag.env.example +3 -0
- package/src/webapi/devcontainer/templates/initialize.sh +169 -0
- package/src/webapi/devcontainer/templates/post-create.sh +35 -0
- package/src/webapi/devcontainer/templates/post-start.sh +65 -0
- package/src/webapi/devcontainer/templates/tty-prompt.sh +38 -0
- package/types/src/add-api.action.d.ts +13 -0
- package/types/src/add-api.command.d.ts +7 -0
- package/types/src/add.command.d.ts +6 -0
- package/types/src/add.module.d.ts +14 -0
- package/types/src/auth0-configure.action.d.ts +7 -0
- package/types/src/auth0-configure.command.d.ts +6 -0
- package/types/src/auth0-login.action.d.ts +4 -0
- package/types/src/auth0-login.command.d.ts +6 -0
- package/types/src/auth0.command.d.ts +6 -0
- package/types/src/auth0.module.d.ts +18 -0
- package/types/src/cli.d.ts +2 -0
- package/types/src/create.command.d.ts +6 -0
- package/types/src/create.module.d.ts +14 -0
- package/types/src/domain/prompt.d.ts +4 -0
- package/types/src/index.d.ts +13 -0
- package/types/src/models/compose.model.d.ts +73 -0
- package/types/src/models/config-yaml.model.d.ts +27 -0
- package/types/src/models/const.d.ts +20 -0
- package/types/src/models/dev-container.model.d.ts +49 -0
- package/types/src/models/docker-image.model.d.ts +90 -0
- package/types/src/models/env-file.model.d.ts +16 -0
- package/types/src/models/gitignore.model.d.ts +9 -0
- package/types/src/models/launch-json.model.d.ts +7 -0
- package/types/src/models/package-json.model.d.ts +36 -0
- package/types/src/models/project.model.d.ts +60 -0
- package/types/src/models/source-file.d.ts +11 -0
- package/types/src/models/tsconfig.model.d.ts +5 -0
- package/types/src/models/vitest-config.model.d.ts +5 -0
- package/types/src/models/vscode-settings.model.d.ts +7 -0
- package/types/src/program.d.ts +3 -0
- package/types/src/resolve-target-dir.d.ts +5 -0
- package/types/src/services/scaffold.service.d.ts +22 -0
- package/types/src/version.d.ts +6 -0
- package/types/src/webapi/api-name.d.ts +14 -0
- package/types/src/webapi/auth0-commands.d.ts +11 -0
- package/types/src/webapi/authorize-scopes.d.ts +7 -0
- package/types/src/webapi/cli-options.d.ts +6 -0
- package/types/src/webapi/const.d.ts +19 -0
- package/types/src/webapi/create-api.d.ts +15 -0
- package/types/src/webapi/devcontainer/codebase-rag-mcp.d.ts +32 -0
- package/types/src/webapi/devcontainer/codebase-rag-mcp.ts +182 -0
- package/types/src/webapi/devcontainer/host-scripts.d.ts +7 -0
- package/types/src/webapi/devcontainer/templates/codebase-rag.env.example +3 -0
- package/types/src/webapi/devcontainer/templates/initialize.sh +169 -0
- package/types/src/webapi/devcontainer/templates/post-create.sh +35 -0
- package/types/src/webapi/devcontainer/templates/post-start.sh +65 -0
- package/types/src/webapi/devcontainer/templates/tty-prompt.sh +38 -0
- package/types/src/webapi/features/auth.feature.d.ts +10 -0
- package/types/src/webapi/features/auth0-cli.d.ts +84 -0
- package/types/src/webapi/features/biome-format.d.ts +5 -0
- package/types/src/webapi/features/database.feature.d.ts +7 -0
- package/types/src/webapi/features/finalize.feature.d.ts +2 -0
- package/types/src/webapi/features/postman.feature.d.ts +16 -0
- package/types/src/webapi/models/api-package-json.model.d.ts +18 -0
- package/types/src/webapi/models/auth-config.model.d.ts +26 -0
- package/types/src/webapi/models/controller-source-file.model.d.ts +46 -0
- package/types/src/webapi/models/github-ci.model.d.ts +9 -0
- package/types/src/webapi/models/main-source-file.model.d.ts +54 -0
- package/types/src/webapi/models/production-dockerfile.model.d.ts +18 -0
- package/types/src/webapi/models/sample-files.model.d.ts +7 -0
- package/types/src/webapi/models/webapi-image.model.d.ts +12 -0
- package/types/src/webapi/postman/hello-openapi.d.ts +19 -0
- package/types/src/webapi/postman/local-view.d.ts +17 -0
- package/types/src/webapi/postman/openapi-to-postman.d.ts +62 -0
- package/types/src/webapi/workspace-readme.d.ts +18 -0
- package/types/src/webapi.action.d.ts +14 -0
- package/types/src/webapi.command.d.ts +11 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { KeyedModel, SourceFile } from "./source-file.js";
|
|
2
|
+
export type LayerWriter = (dockerfile: DockerfileModel) => void;
|
|
3
|
+
export declare class DockerStep {
|
|
4
|
+
readonly key: string;
|
|
5
|
+
readonly content: string;
|
|
6
|
+
readonly order: number;
|
|
7
|
+
constructor(key: string, content: string, order?: number);
|
|
8
|
+
static run(key: string, command: string, order?: number): DockerStep;
|
|
9
|
+
static raw(key: string, content: string, order?: number): DockerStep;
|
|
10
|
+
static entrypoint(key: string, value: string | readonly string[], order?: number): DockerStep;
|
|
11
|
+
}
|
|
12
|
+
/** Named volume + paths for interactive bash history in app Dev Containers. */
|
|
13
|
+
export declare const commandHistory: {
|
|
14
|
+
readonly volumeName: "bashhistory";
|
|
15
|
+
readonly dir: "/commandhistory";
|
|
16
|
+
readonly fileName: ".bash_history";
|
|
17
|
+
readonly histFile: "/commandhistory/.bash_history";
|
|
18
|
+
};
|
|
19
|
+
export declare function withCommandHistory(options?: {
|
|
20
|
+
historyDir?: string;
|
|
21
|
+
historyFileName?: string;
|
|
22
|
+
username?: string;
|
|
23
|
+
order?: number;
|
|
24
|
+
}): LayerWriter;
|
|
25
|
+
export declare function withNodeUser(options?: {
|
|
26
|
+
username?: string;
|
|
27
|
+
includeUserInstruction?: boolean;
|
|
28
|
+
order?: number;
|
|
29
|
+
}): LayerWriter;
|
|
30
|
+
export declare function withPnpm(options?: {
|
|
31
|
+
version?: string;
|
|
32
|
+
usernameExpr?: string;
|
|
33
|
+
order?: number;
|
|
34
|
+
}): LayerWriter;
|
|
35
|
+
/**
|
|
36
|
+
* Client-only (`psql`, etc.). Escalates to root so this also works when layered on
|
|
37
|
+
* a published base image that already switched to `USER node`.
|
|
38
|
+
*/
|
|
39
|
+
export declare function withPostgresqlClient(options?: {
|
|
40
|
+
order?: number;
|
|
41
|
+
username?: string;
|
|
42
|
+
}): LayerWriter;
|
|
43
|
+
/** GitHub CLI — install before USER switches away from root. */
|
|
44
|
+
export declare function withGithubCli(options?: {
|
|
45
|
+
order?: number;
|
|
46
|
+
}): LayerWriter;
|
|
47
|
+
export declare function withWorkspaceNodeModulesOwnership(options?: {
|
|
48
|
+
workspaceDir?: string;
|
|
49
|
+
usernameExpr?: string;
|
|
50
|
+
order?: number;
|
|
51
|
+
}): LayerWriter;
|
|
52
|
+
export declare function withVsCodeJsDebugBootloaderFix(options?: {
|
|
53
|
+
bashrcPath?: string;
|
|
54
|
+
order?: number;
|
|
55
|
+
}): LayerWriter;
|
|
56
|
+
export declare class DockerfileModel implements KeyedModel {
|
|
57
|
+
readonly key: string;
|
|
58
|
+
private readonly _steps;
|
|
59
|
+
private readonly _layerWriters;
|
|
60
|
+
private _fromImage;
|
|
61
|
+
private _layerCounter;
|
|
62
|
+
private _existing;
|
|
63
|
+
constructor(baseImage: string);
|
|
64
|
+
/**
|
|
65
|
+
* Load an existing Dockerfile so `decohere add api` can append feature layers.
|
|
66
|
+
* The new steps are appended as one block, unless the file already contains it.
|
|
67
|
+
*/
|
|
68
|
+
static fromFile(absolutePath: string, filePath: string): DockerfileModel;
|
|
69
|
+
from(baseImage: string): this;
|
|
70
|
+
addLayer(layer: LayerWriter | string, order?: 5000): this;
|
|
71
|
+
addStep(step: DockerStep): this;
|
|
72
|
+
removeStep(key: string): this;
|
|
73
|
+
entrypoint(value: string | readonly string[], order?: 10000): this;
|
|
74
|
+
addRunStep(cmd: string): this;
|
|
75
|
+
build(): string;
|
|
76
|
+
protected registerBaseLayers(): void;
|
|
77
|
+
files(): SourceFile[];
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Shared layers for the published `ghcr.io/typesmiths/decohere/devcontainer` image.
|
|
81
|
+
* Checked in at `projects/devcontainer/Dockerfile` — keep in sync via the unit test.
|
|
82
|
+
*/
|
|
83
|
+
export declare class AppDevContainerBaseImage extends DockerfileModel {
|
|
84
|
+
protected registerBaseLayers(): void;
|
|
85
|
+
}
|
|
86
|
+
/** Generic Dev Container image helpers (history + bootloader) without webapi defaults. */
|
|
87
|
+
export declare class DevContainerImageModel extends DockerfileModel {
|
|
88
|
+
protected registerBaseLayers(): void;
|
|
89
|
+
files(): SourceFile[];
|
|
90
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { KeyedModel, SourceFile } from "./source-file.js";
|
|
2
|
+
/**
|
|
3
|
+
* Accumulates key=value pairs and renders them as a `.env` file.
|
|
4
|
+
*
|
|
5
|
+
* Register once in the workspace; features call `addEntry` during their
|
|
6
|
+
* scaffold phase to contribute environment variables. The final file is
|
|
7
|
+
* written at render time when `workspace.scaffold()` is called.
|
|
8
|
+
*/
|
|
9
|
+
export declare class EnvFile implements KeyedModel {
|
|
10
|
+
readonly key: string;
|
|
11
|
+
private readonly _entries;
|
|
12
|
+
addEntry(key: string, value: string): this;
|
|
13
|
+
hasEntry(key: string): boolean;
|
|
14
|
+
static fromFile(absolutePath: string): EnvFile;
|
|
15
|
+
files(): SourceFile[];
|
|
16
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { KeyedModel, SourceFile } from "./source-file.js";
|
|
2
|
+
export declare class Gitignore implements KeyedModel {
|
|
3
|
+
readonly key: string;
|
|
4
|
+
private ignoreList;
|
|
5
|
+
/** Load an existing .gitignore so `decohere add api` appends instead of replacing. */
|
|
6
|
+
static fromFile(absolutePath: string): Gitignore;
|
|
7
|
+
add(...patterns: string[]): this;
|
|
8
|
+
files(): SourceFile[];
|
|
9
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { KeyedModel, SourceFile } from "./source-file.js";
|
|
2
|
+
export type PackageJsonOptions = {
|
|
3
|
+
startEntry?: string;
|
|
4
|
+
/** API slugs in this workspace. Drives `start:<name>` / `dev:<name>`. */
|
|
5
|
+
apiNames?: readonly string[];
|
|
6
|
+
/** Host workspace name used in `@<workspace>/<api>` for flux `--project`. */
|
|
7
|
+
workspaceName?: string;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Builder for the root `package.json`.
|
|
11
|
+
*
|
|
12
|
+
* Starts with the core API dependencies. Features call `addDependency` /
|
|
13
|
+
* `addDevDependency` during their scaffold phase to inject their own deps
|
|
14
|
+
* before `files()` is called at render time.
|
|
15
|
+
*/
|
|
16
|
+
export declare class PackageJson implements KeyedModel {
|
|
17
|
+
private readonly name;
|
|
18
|
+
readonly key: string;
|
|
19
|
+
private _dependencies;
|
|
20
|
+
private _devDependencies;
|
|
21
|
+
private _scripts;
|
|
22
|
+
private _version;
|
|
23
|
+
private _type;
|
|
24
|
+
private _rest;
|
|
25
|
+
constructor(name: string, options?: PackageJsonOptions);
|
|
26
|
+
/** Load an existing root package.json so `webapi add` can merge scripts/deps. */
|
|
27
|
+
static fromFile(filePath: string): PackageJson;
|
|
28
|
+
addDependency(name: string, version: string): this;
|
|
29
|
+
addDevDependency(name: string, version: string): this;
|
|
30
|
+
addScript(name: string, command: string): this;
|
|
31
|
+
hasScript(name: string): boolean;
|
|
32
|
+
files(): SourceFile[];
|
|
33
|
+
}
|
|
34
|
+
/** Stable A→Z key order for package.json dependency maps. */
|
|
35
|
+
export declare function sortStringMap(map: Record<string, string>): Record<string, string>;
|
|
36
|
+
export declare function packageScript(workspaceName: string, apiName: string): string;
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface SourceFileProvider {
|
|
2
|
+
files(): SourceFile[];
|
|
3
|
+
}
|
|
4
|
+
/** A SourceFileProvider that knows its own registration key. */
|
|
5
|
+
export interface KeyedModel extends SourceFileProvider {
|
|
6
|
+
readonly key: string;
|
|
7
|
+
}
|
|
8
|
+
export type SourceFile = {
|
|
9
|
+
filePath: string;
|
|
10
|
+
content: string;
|
|
11
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,6 @@
|
|
|
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;
|
|
@@ -0,0 +1,14 @@
|
|
|
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;
|
|
@@ -0,0 +1,11 @@
|
|
|
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;
|
|
@@ -0,0 +1,7 @@
|
|
|
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;
|
|
@@ -0,0 +1,6 @@
|
|
|
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>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Default API project slug when `--name` is omitted. */
|
|
2
|
+
export declare const DEFAULT_WEBAPI_NAME = "api";
|
|
3
|
+
/** Relative path of an API project inside the monorepo. */
|
|
4
|
+
export declare function webapiProjectDir(name: string): string;
|
|
5
|
+
/**
|
|
6
|
+
* Forge release entry for a scaffolded API (`pack: true` → per-target outDir).
|
|
7
|
+
* Keep in sync with root `package.json` `"start"` / `"start:<name>"` and Dockerfiles.
|
|
8
|
+
*/
|
|
9
|
+
export declare function webapiReleaseEntry(name: string): string;
|
|
10
|
+
/** The same entry inside `.package/` (`forge package`), which is what the Dockerfile runs. */
|
|
11
|
+
export declare function webapiPackagedEntry(): string;
|
|
12
|
+
/** npm package name for a scaffolded API (`flux serve --project`). */
|
|
13
|
+
export declare function webapiPackageName(workspaceName: string, apiName: string): string;
|
|
14
|
+
/** Local listen port for the nth API (0-based). Production uses `PORT`. */
|
|
15
|
+
export declare function webapiPort(index: number): number;
|
|
16
|
+
/** @deprecated Use `webapiProjectDir(name)`. Default path for the first API. */
|
|
17
|
+
export declare const WEBAPI_PROJECT_DIR: string;
|
|
18
|
+
/** @deprecated Use `webapiReleaseEntry(name)`. Default start entry for the first API. */
|
|
19
|
+
export declare const WEBAPI_RELEASE_ENTRY: string;
|
|
@@ -0,0 +1,15 @@
|
|
|
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>;
|
|
@@ -0,0 +1,32 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,182 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
+
}
|