@adityum/studio 0.0.0-stage → 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.
- package/README.md +21 -2
- package/bin/adi-studio.js +2 -0
- package/dist/bin/adi-studio.d.ts +1 -0
- package/dist/bin/adi-studio.js +140 -0
- package/dist/engines/blueprints.d.ts +24 -0
- package/dist/engines/blueprints.js +724 -0
- package/dist/engines/codegen.d.ts +32 -0
- package/dist/engines/codegen.js +427 -0
- package/dist/engines/types.d.ts +114 -0
- package/dist/engines/types.js +1 -0
- package/dist/engines/validator.d.ts +7 -0
- package/dist/engines/validator.js +311 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/package.json +32 -4
package/README.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @adityum/studio — Platform 02 (Adityum Studio)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Sovereign microservice topology graph engine, zero-dependency security auditor, and declarative infrastructure generator (`docker-compose.yml`, `adityum.yaml`, CIS-hardened multi-stage `Dockerfile`s, hardened `/etc/cloudflared/config.yml`, and `.env.example`).
|
|
4
|
+
|
|
5
|
+
- **Visual Workbench:** [https://adi-console.vercel.app/studio](https://adi-console.vercel.app/studio)
|
|
6
|
+
- **Zero Runtime Dependencies:** Pure ESM TypeScript built solely on Node.js standard library APIs.
|
|
7
|
+
|
|
8
|
+
## Quick Start
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
# List built-in sovereign architecture blueprints
|
|
12
|
+
adi-studio list
|
|
13
|
+
|
|
14
|
+
# Initialize a new topology blueprint file locally
|
|
15
|
+
adi-studio init saas-nextjs-postgres --out adityum-topology.json
|
|
16
|
+
|
|
17
|
+
# Audit a topology file against Contract #2 (Data Plane Isolation), Contract #3 (AAD Vault), and cycle checks
|
|
18
|
+
adi-studio validate adityum-topology.json
|
|
19
|
+
|
|
20
|
+
# Generate docker-compose.yml, adityum.yaml, cloudflared/config.yml, .env.example & Dockerfiles
|
|
21
|
+
adi-studio generate adityum-topology.json --out ./generated-stack
|
|
22
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function runStudioCli(args: string[]): Promise<number>;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { STUDIO_BLUEPRINTS, getDefaultStudioTopology } from "../engines/blueprints.js";
|
|
4
|
+
import { validateStudioTopology } from "../engines/validator.js";
|
|
5
|
+
import { generateStudioBundle } from "../engines/codegen.js";
|
|
6
|
+
const VERSION = "0.1.0";
|
|
7
|
+
const HELP_TEXT = `
|
|
8
|
+
\x1b[35m╔═══════════════════════════════════════════════════════════════════╗
|
|
9
|
+
║ ADI-STUDIO // VISUAL TOPOLOGY & DECLARATIVE IAC CLI (v${VERSION}) ║
|
|
10
|
+
║ Platform 02 — Adityum Studio ║
|
|
11
|
+
╚═══════════════════════════════════════════════════════════════════╝\x1b[0m
|
|
12
|
+
|
|
13
|
+
\x1b[1mUSAGE:\x1b[0m
|
|
14
|
+
adi-studio <command> [options]
|
|
15
|
+
|
|
16
|
+
\x1b[1mCOMMANDS:\x1b[0m
|
|
17
|
+
\x1b[35mlist\x1b[0m List built-in sovereign architecture blueprints
|
|
18
|
+
\x1b[35minit\x1b[0m [blueprint-id] [--out file] Scaffold a Studio topology JSON file
|
|
19
|
+
\x1b[35mvalidate\x1b[0m <file> [--json] Audit topology against Contract #2/#3 & cycles
|
|
20
|
+
(Exits with code 1 on critical violations)
|
|
21
|
+
\x1b[35mgenerate\x1b[0m <file> [--out dir] Compile docker-compose.yml, adityum.yaml,
|
|
22
|
+
cloudflared/config.yml, .env.example & Dockerfiles
|
|
23
|
+
\x1b[35mversion\x1b[0m Display CLI version
|
|
24
|
+
\x1b[35mhelp\x1b[0m Display this help message
|
|
25
|
+
`;
|
|
26
|
+
function getFlagValue(args, flag) {
|
|
27
|
+
const idx = args.indexOf(flag);
|
|
28
|
+
if (idx !== -1 && args[idx + 1] && !args[idx + 1].startsWith("-")) {
|
|
29
|
+
return args[idx + 1];
|
|
30
|
+
}
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
export async function runStudioCli(args) {
|
|
34
|
+
const cmd = args[0] || "help";
|
|
35
|
+
if (cmd === "--version" || cmd === "-v" || cmd === "version") {
|
|
36
|
+
console.log(`adi-studio version ${VERSION}`);
|
|
37
|
+
return 0;
|
|
38
|
+
}
|
|
39
|
+
if (cmd === "--help" || cmd === "-h" || cmd === "help") {
|
|
40
|
+
console.log(HELP_TEXT);
|
|
41
|
+
return 0;
|
|
42
|
+
}
|
|
43
|
+
if (cmd === "list") {
|
|
44
|
+
console.log(`\n\x1b[35m==> Adityum Studio Sovereign Blueprints\x1b[0m\n`);
|
|
45
|
+
for (const bp of STUDIO_BLUEPRINTS) {
|
|
46
|
+
const sample = bp.create();
|
|
47
|
+
const audit = validateStudioTopology(sample);
|
|
48
|
+
console.log(` \x1b[1m${bp.id}\x1b[0m [\x1b[35m${bp.badge}\x1b[0m] (~₹${audit.resources.estimatedMonthlyInr}/mo BYOC · Score ${audit.score}/100)`);
|
|
49
|
+
console.log(` ${bp.tagline}\n`);
|
|
50
|
+
}
|
|
51
|
+
return 0;
|
|
52
|
+
}
|
|
53
|
+
if (cmd === "init") {
|
|
54
|
+
const bpArg = args[1] && !args[1].startsWith("-") ? args[1] : STUDIO_BLUEPRINTS[0].id;
|
|
55
|
+
const outFile = getFlagValue(args, "--out") || "adityum-topology.json";
|
|
56
|
+
const bp = STUDIO_BLUEPRINTS.find((b) => b.id === bpArg);
|
|
57
|
+
const topology = bp ? bp.create() : getDefaultStudioTopology();
|
|
58
|
+
if (!bp && bpArg !== STUDIO_BLUEPRINTS[0].id) {
|
|
59
|
+
console.error(`\x1b[31mError:\x1b[0m Unknown blueprint '${bpArg}'. Run 'adi-studio list' to view available blueprints.`);
|
|
60
|
+
return 1;
|
|
61
|
+
}
|
|
62
|
+
const resolved = path.resolve(process.cwd(), outFile);
|
|
63
|
+
fs.writeFileSync(resolved, JSON.stringify(topology, null, 2) + "\n", "utf-8");
|
|
64
|
+
console.log(`\x1b[32m✔ Initialized blueprint '${bpArg}'\x1b[0m → ${resolved} (${topology.nodes.length} services)`);
|
|
65
|
+
return 0;
|
|
66
|
+
}
|
|
67
|
+
if (cmd === "validate") {
|
|
68
|
+
const filePath = args[1];
|
|
69
|
+
if (!filePath || filePath.startsWith("-")) {
|
|
70
|
+
console.error("\x1b[31mError:\x1b[0m Missing topology JSON path. Usage: adi-studio validate <file> [--json]");
|
|
71
|
+
return 1;
|
|
72
|
+
}
|
|
73
|
+
const resolved = path.resolve(process.cwd(), filePath);
|
|
74
|
+
if (!fs.existsSync(resolved)) {
|
|
75
|
+
console.error(`\x1b[31mError:\x1b[0m File not found: ${resolved}`);
|
|
76
|
+
return 1;
|
|
77
|
+
}
|
|
78
|
+
const topology = JSON.parse(fs.readFileSync(resolved, "utf-8"));
|
|
79
|
+
const audit = validateStudioTopology(topology);
|
|
80
|
+
const isJson = args.includes("--json");
|
|
81
|
+
if (isJson) {
|
|
82
|
+
console.log(JSON.stringify(audit, null, 2));
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
console.log(`\n\x1b[35m==> Adityum Studio Topology Audit: ${topology.name}\x1b[0m`);
|
|
86
|
+
console.log(`Score: ${audit.score}/100 (\x1b[1m${audit.grade}\x1b[0m) | Deploy Ready: ${audit.isDeployReady ? "\x1b[32mYES\x1b[0m" : "\x1b[31mNO\x1b[0m"}`);
|
|
87
|
+
console.log(`BYOC Sizing: ${audit.resources.recommendedTierName} (~₹${audit.resources.estimatedMonthlyInr}/mo · Save ${audit.resources.monthlySavingsPercent}% vs AWS)`);
|
|
88
|
+
console.log(`Startup Order: ${audit.deployOrder.join(" → ")}\n`);
|
|
89
|
+
if (audit.findings.length === 0) {
|
|
90
|
+
console.log("\x1b[32m✔ ZERO VIOLATIONS:\x1b[0m Topology satisfies Contract #2, Contract #3, and CIS hardening.\n");
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
for (const f of audit.findings) {
|
|
94
|
+
console.log(`[${f.severity.toUpperCase()}] ${f.code} — ${f.title}`);
|
|
95
|
+
console.log(` ${f.message}`);
|
|
96
|
+
console.log(` Remediation: ${f.remediation}\n`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return audit.isDeployReady ? 0 : 1;
|
|
101
|
+
}
|
|
102
|
+
if (cmd === "generate") {
|
|
103
|
+
const filePath = args[1];
|
|
104
|
+
if (!filePath || filePath.startsWith("-")) {
|
|
105
|
+
console.error("\x1b[31mError:\x1b[0m Missing topology JSON path. Usage: adi-studio generate <file> [--out dir]");
|
|
106
|
+
return 1;
|
|
107
|
+
}
|
|
108
|
+
const resolved = path.resolve(process.cwd(), filePath);
|
|
109
|
+
if (!fs.existsSync(resolved)) {
|
|
110
|
+
console.error(`\x1b[31mError:\x1b[0m File not found: ${resolved}`);
|
|
111
|
+
return 1;
|
|
112
|
+
}
|
|
113
|
+
const outDir = path.resolve(process.cwd(), getFlagValue(args, "--out") || "./adityum-generated");
|
|
114
|
+
const topology = JSON.parse(fs.readFileSync(resolved, "utf-8"));
|
|
115
|
+
const bundle = generateStudioBundle(topology);
|
|
116
|
+
fs.mkdirSync(path.join(outDir, "cloudflared"), { recursive: true });
|
|
117
|
+
fs.writeFileSync(path.join(outDir, "docker-compose.yml"), bundle.dockerComposeYaml, "utf-8");
|
|
118
|
+
fs.writeFileSync(path.join(outDir, "adityum.yaml"), bundle.adityumManifestYaml, "utf-8");
|
|
119
|
+
fs.writeFileSync(path.join(outDir, "cloudflared/config.yml"), bundle.tunnelConfigYaml, "utf-8");
|
|
120
|
+
fs.writeFileSync(path.join(outDir, ".env.example"), bundle.envExample, "utf-8");
|
|
121
|
+
for (const [slug, df] of Object.entries(bundle.dockerfiles)) {
|
|
122
|
+
const svcDir = path.join(outDir, "services", slug);
|
|
123
|
+
fs.mkdirSync(svcDir, { recursive: true });
|
|
124
|
+
fs.writeFileSync(path.join(svcDir, "Dockerfile"), df, "utf-8");
|
|
125
|
+
}
|
|
126
|
+
console.log(`\x1b[32m✔ Generated declarative sovereign stack\x1b[0m → ${outDir} (${Object.keys(bundle.dockerfiles).length} hardened Dockerfiles + Compose + Tunnel)`);
|
|
127
|
+
return 0;
|
|
128
|
+
}
|
|
129
|
+
console.error(`Unknown command '${cmd}'. Run 'adi-studio --help' for available commands.`);
|
|
130
|
+
return 1;
|
|
131
|
+
}
|
|
132
|
+
const isMain = process.argv[1] &&
|
|
133
|
+
(process.argv[1].endsWith("/adi-studio.js") ||
|
|
134
|
+
process.argv[1].endsWith("/adi-studio.ts") ||
|
|
135
|
+
process.argv[1].endsWith("/adi-studio"));
|
|
136
|
+
if (isMain) {
|
|
137
|
+
runStudioCli(process.argv.slice(2)).then((code) => {
|
|
138
|
+
process.exit(code);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { StudioBlueprintMeta, StudioEdgeProtocol, StudioNode, StudioRuntime, StudioServiceKind, StudioTopology } from "./types.js";
|
|
2
|
+
export declare const SERVICE_KIND_META: Record<StudioServiceKind, {
|
|
3
|
+
label: string;
|
|
4
|
+
shortTag: string;
|
|
5
|
+
accent: string;
|
|
6
|
+
defaultRuntime: StudioRuntime;
|
|
7
|
+
defaultPort: number;
|
|
8
|
+
defaultCpu: number;
|
|
9
|
+
defaultMemoryMb: number;
|
|
10
|
+
defaultPublic: boolean;
|
|
11
|
+
tier: number;
|
|
12
|
+
}>;
|
|
13
|
+
export declare function inferEdgeProtocol(source: StudioNode, target: StudioNode): {
|
|
14
|
+
protocol: StudioEdgeProtocol;
|
|
15
|
+
label: string;
|
|
16
|
+
encrypted: boolean;
|
|
17
|
+
};
|
|
18
|
+
export declare function createServiceNode(kind: StudioServiceKind, existingNodes: StudioNode[]): StudioNode;
|
|
19
|
+
/**
|
|
20
|
+
* Deterministic left-to-right architectural tier layout (20px grid snapped).
|
|
21
|
+
*/
|
|
22
|
+
export declare function autoLayoutTopology(topology: StudioTopology): StudioTopology;
|
|
23
|
+
export declare const STUDIO_BLUEPRINTS: StudioBlueprintMeta[];
|
|
24
|
+
export declare function getDefaultStudioTopology(): StudioTopology;
|