@nebutra/generation-context 0.1.2 → 0.1.4
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/CHANGELOG.md +7 -0
- package/package.json +16 -5
- package/.turbo/turbo-build.log +0 -17
- package/.turbo/turbo-test.log +0 -14
- package/.turbo/turbo-typecheck.log +0 -4
- package/src/index.test.ts +0 -14
- package/src/index.ts +0 -135
- package/tsconfig.json +0 -12
- package/tsup.config.ts +0 -11
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nebutra/generation-context",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Shared BrandContext and generated-asset metadata contracts for multimodal pipelines",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"nebutra": {
|
|
9
|
+
"graph": "labs",
|
|
9
10
|
"status": "wip",
|
|
10
11
|
"productionReady": false,
|
|
11
12
|
"surface": "support-contract",
|
|
@@ -21,13 +22,17 @@
|
|
|
21
22
|
"category": "ai",
|
|
22
23
|
"summary": "Single shared BrandContext contract for Layer 4 multimodal generation"
|
|
23
24
|
},
|
|
24
|
-
"main": "./
|
|
25
|
-
"types": "./
|
|
25
|
+
"main": "./dist/index.js",
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
26
27
|
"exports": {
|
|
27
|
-
".":
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"import": "./dist/index.js",
|
|
31
|
+
"default": "./dist/index.js"
|
|
32
|
+
}
|
|
28
33
|
},
|
|
29
34
|
"dependencies": {
|
|
30
|
-
"@nebutra/errors": "0.
|
|
35
|
+
"@nebutra/errors": "2.0.0"
|
|
31
36
|
},
|
|
32
37
|
"devDependencies": {
|
|
33
38
|
"@types/node": "^25.9.1",
|
|
@@ -47,6 +52,12 @@
|
|
|
47
52
|
"publishConfig": {
|
|
48
53
|
"access": "public"
|
|
49
54
|
},
|
|
55
|
+
"files": [
|
|
56
|
+
"dist",
|
|
57
|
+
"README.md",
|
|
58
|
+
"LICENSE",
|
|
59
|
+
"CHANGELOG.md"
|
|
60
|
+
],
|
|
50
61
|
"scripts": {
|
|
51
62
|
"build": "tsup",
|
|
52
63
|
"test": "vitest run",
|
package/.turbo/turbo-build.log
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
> @nebutra/generation-context@0.1.2 build /Users/tseka_luk/Documents/Nebutra-SaaS-Lab/Nebutra-Sailor/packages/ai/generation-context
|
|
3
|
-
> tsup
|
|
4
|
-
|
|
5
|
-
CLI Building entry: src/index.ts
|
|
6
|
-
CLI Using tsconfig: tsconfig.json
|
|
7
|
-
CLI tsup v8.5.1
|
|
8
|
-
CLI Using tsup config: /Users/tseka_luk/Documents/Nebutra-SaaS-Lab/Nebutra-Sailor/packages/ai/generation-context/tsup.config.ts
|
|
9
|
-
CLI Target: es2022
|
|
10
|
-
CLI Cleaning output folder
|
|
11
|
-
ESM Build start
|
|
12
|
-
ESM dist/index.js 2.43 KB
|
|
13
|
-
ESM dist/index.js.map 6.03 KB
|
|
14
|
-
ESM ⚡️ Build success in 15ms
|
|
15
|
-
DTS Build start
|
|
16
|
-
DTS ⚡️ Build success in 1373ms
|
|
17
|
-
DTS dist/index.d.ts 2.07 KB
|
package/.turbo/turbo-test.log
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
> @nebutra/generation-context@0.1.1 test /Users/tseka_luk/Documents/Nebutra-SaaS-Lab/Nebutra-Sailor/packages/ai/generation-context
|
|
3
|
-
> vitest run
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
RUN v4.1.4 /Users/tseka_luk/Documents/Nebutra-SaaS-Lab/Nebutra-Sailor/packages/ai/generation-context
|
|
7
|
-
|
|
8
|
-
✓ src/index.test.ts (2 tests) 9ms
|
|
9
|
-
|
|
10
|
-
Test Files 1 passed (1)
|
|
11
|
-
Tests 2 passed (2)
|
|
12
|
-
Start at 09:38:31
|
|
13
|
-
Duration 322ms (transform 50ms, setup 0ms, import 73ms, tests 9ms, environment 0ms)
|
|
14
|
-
|
package/src/index.test.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { createDemoBrandContext, requireBrandContext, summarizeBrandContext } from "./index";
|
|
3
|
-
|
|
4
|
-
describe("generation-context", () => {
|
|
5
|
-
it("requires BrandContext for every generation capability", () => {
|
|
6
|
-
expect(() => requireBrandContext(undefined, "image-pipeline")).toThrow(/BrandContext/);
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
it("summarizes the shared brand contract without owning generation", () => {
|
|
10
|
-
const brand = createDemoBrandContext();
|
|
11
|
-
expect(summarizeBrandContext(brand)).toContain("Loop");
|
|
12
|
-
expect(summarizeBrandContext(brand)).toContain("palette=");
|
|
13
|
-
});
|
|
14
|
-
});
|
package/src/index.ts
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { CapabilityError } from "@nebutra/errors";
|
|
2
|
-
|
|
3
|
-
export interface PathRef {
|
|
4
|
-
readonly path: string;
|
|
5
|
-
readonly tenantId?: string;
|
|
6
|
-
readonly mediaType?: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface BrandColor {
|
|
10
|
-
readonly name: string;
|
|
11
|
-
readonly hex: string;
|
|
12
|
-
readonly role?: "primary" | "secondary" | "accent" | "neutral" | "background";
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface TypographySpec {
|
|
16
|
-
readonly heading: string;
|
|
17
|
-
readonly body: string;
|
|
18
|
-
readonly accent?: string;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface VisualStyle {
|
|
22
|
-
readonly name: string;
|
|
23
|
-
readonly keywords: readonly string[];
|
|
24
|
-
readonly avoid?: readonly string[];
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface BrandContext {
|
|
28
|
-
readonly tenantId: string;
|
|
29
|
-
readonly brandId: string;
|
|
30
|
-
readonly name: string;
|
|
31
|
-
readonly palette: readonly BrandColor[];
|
|
32
|
-
readonly typography: TypographySpec;
|
|
33
|
-
readonly visualStyle: VisualStyle;
|
|
34
|
-
readonly referenceImages: readonly PathRef[];
|
|
35
|
-
readonly forbidden: readonly string[];
|
|
36
|
-
readonly toneKeywords: readonly string[];
|
|
37
|
-
readonly sourcePath: string;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export type LicenseStatus = "commercial-ok" | "non-commercial" | "requires-attribution" | "unknown";
|
|
41
|
-
|
|
42
|
-
export interface LicenseMetadata {
|
|
43
|
-
readonly status: LicenseStatus;
|
|
44
|
-
readonly source: string;
|
|
45
|
-
readonly suggestion?: string;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export interface GeneratedAsset {
|
|
49
|
-
readonly id: string;
|
|
50
|
-
readonly tenantId: string;
|
|
51
|
-
readonly kind: "image" | "video" | "audio" | "voice" | "mesh";
|
|
52
|
-
readonly path: string;
|
|
53
|
-
readonly brandId: string;
|
|
54
|
-
readonly provider: string;
|
|
55
|
-
readonly model: string;
|
|
56
|
-
readonly createdAt: string;
|
|
57
|
-
readonly license: LicenseMetadata;
|
|
58
|
-
readonly metadata?: Record<string, unknown>;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export function requireBrandContext(
|
|
62
|
-
brand: BrandContext | undefined,
|
|
63
|
-
capability: string,
|
|
64
|
-
): BrandContext {
|
|
65
|
-
if (!brand) {
|
|
66
|
-
throw new CapabilityError(capability, "BrandContext is required for generation", {
|
|
67
|
-
suggestion:
|
|
68
|
-
"Load company/BRAND.md through content-store and pass the parsed BrandContext into this call.",
|
|
69
|
-
statusCode: 400,
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const missing: string[] = [];
|
|
74
|
-
if (!brand.tenantId) missing.push("tenantId");
|
|
75
|
-
if (!brand.brandId) missing.push("brandId");
|
|
76
|
-
if (!brand.name) missing.push("name");
|
|
77
|
-
if (brand.palette.length === 0) missing.push("palette");
|
|
78
|
-
if (!brand.typography.heading || !brand.typography.body) missing.push("typography");
|
|
79
|
-
if (!brand.visualStyle.name || brand.visualStyle.keywords.length === 0) {
|
|
80
|
-
missing.push("visualStyle");
|
|
81
|
-
}
|
|
82
|
-
if (brand.toneKeywords.length === 0) missing.push("toneKeywords");
|
|
83
|
-
if (!brand.sourcePath) missing.push("sourcePath");
|
|
84
|
-
|
|
85
|
-
if (missing.length > 0) {
|
|
86
|
-
throw new CapabilityError(capability, "BrandContext is incomplete", {
|
|
87
|
-
suggestion: `Fill these BrandContext fields before generation: ${missing.join(", ")}.`,
|
|
88
|
-
metadata: { missing },
|
|
89
|
-
statusCode: 400,
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return brand;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export function summarizeBrandContext(brand: BrandContext): string {
|
|
97
|
-
return [
|
|
98
|
-
brand.name,
|
|
99
|
-
`style=${brand.visualStyle.name}`,
|
|
100
|
-
`tone=${brand.toneKeywords.join(", ")}`,
|
|
101
|
-
`palette=${brand.palette.map((color) => `${color.name}:${color.hex}`).join(", ")}`,
|
|
102
|
-
].join("; ");
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export function createDemoBrandContext(overrides: Partial<BrandContext> = {}): BrandContext {
|
|
106
|
-
return {
|
|
107
|
-
tenantId: "demo_tenant",
|
|
108
|
-
brandId: "loop",
|
|
109
|
-
name: "Loop",
|
|
110
|
-
palette: [
|
|
111
|
-
{ name: "signal", hex: "#00A693", role: "primary" },
|
|
112
|
-
{ name: "ink", hex: "#151719", role: "neutral" },
|
|
113
|
-
{ name: "spark", hex: "#F3C14B", role: "accent" },
|
|
114
|
-
],
|
|
115
|
-
typography: { heading: "Geist Sans", body: "Geist Sans Mono" },
|
|
116
|
-
visualStyle: {
|
|
117
|
-
name: "focused technical optimism",
|
|
118
|
-
keywords: ["precise", "calm", "developer-native"],
|
|
119
|
-
avoid: ["dark horror", "generic stock"],
|
|
120
|
-
},
|
|
121
|
-
referenceImages: [],
|
|
122
|
-
forbidden: ["dark horror", "skeletal imagery"],
|
|
123
|
-
toneKeywords: ["technical", "warm", "direct"],
|
|
124
|
-
sourcePath: "company/BRAND.md",
|
|
125
|
-
...overrides,
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export function assetId(prefix: string, seed: string): string {
|
|
130
|
-
return `${prefix}_${seed
|
|
131
|
-
.toLowerCase()
|
|
132
|
-
.replace(/[^a-z0-9]+/g, "_")
|
|
133
|
-
.replace(/^_+|_+$/g, "")
|
|
134
|
-
.slice(0, 40)}_${Date.now().toString(36)}`;
|
|
135
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../../tsconfig.base.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"module": "ESNext",
|
|
5
|
-
"moduleResolution": "bundler",
|
|
6
|
-
"target": "esnext",
|
|
7
|
-
"types": ["node"],
|
|
8
|
-
"incremental": false
|
|
9
|
-
},
|
|
10
|
-
"include": ["src"],
|
|
11
|
-
"exclude": ["node_modules", "dist"]
|
|
12
|
-
}
|