@uibot/design-md 0.0.0-stage → 0.2.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.
@@ -0,0 +1,30 @@
1
+ import type { DesignMd } from "@uibot/contracts";
2
+ /** Consumer-owned project DESIGN.md, loaded as the user-layer generate source. */
3
+ export declare const PROJECT_DESIGN_MD_ID = "project";
4
+ export declare function projectDesignMdPath(rootDir: string): string;
5
+ export declare function projectDesignMdTemplate(projectName: string): string;
6
+ /**
7
+ * Load the consumer root DESIGN.md as a user-layer design-md entry.
8
+ * AUTA 7-section files without YAML frontmatter are wrapped; files that
9
+ * already have design-md frontmatter keep their body and are stamped
10
+ * \`id: project\` / \`layer: user\` so generate can force-include them.
11
+ */
12
+ export declare function loadProjectDesignMd(rootDir: string): DesignMd | undefined;
13
+ export interface ProjectDesignLoad {
14
+ /** Loaded entry when a DESIGN.md was found. */
15
+ entry?: DesignMd;
16
+ /** Absolute path that was consumed, or null when none of the roots had a file. */
17
+ path: string | null;
18
+ /** Absolute roots that were tried, first existing DESIGN.md wins. */
19
+ tried: string[];
20
+ }
21
+ /** Deduped absolute roots; first existing DESIGN.md wins. */
22
+ export declare function loadProjectDesignMdFromRoots(roots: readonly string[]): ProjectDesignLoad;
23
+ export declare function defaultProjectDesignRoots(options: {
24
+ projectRoot?: string;
25
+ linkedConsumerRoot?: string;
26
+ cwd?: string;
27
+ agentRootDir?: string;
28
+ }): string[];
29
+ /** Read `.uibot/link.json` `consumerRoot` without throwing on a missing or stale file. */
30
+ export declare function readLinkedConsumerRoot(cwd: string): string | undefined;
@@ -0,0 +1,23 @@
1
+ import type { DesignMd, DesignMdLayer } from "@uibot/contracts";
2
+ export interface DesignMdRegistryAddOptions {
3
+ /** Registry merge layer. Defaults to `"user"`. */
4
+ layer?: DesignMdLayer;
5
+ }
6
+ /** In-memory registry of loaded DesignMd entries, keyed by id. */
7
+ export declare class DesignMdRegistry {
8
+ private readonly entries;
9
+ /**
10
+ * Add a single DesignMd entry, optionally stamping a registry layer.
11
+ *
12
+ * When no `options.layer` is provided, defaults to `"user"`, which
13
+ * preserves pre-v2.13 behaviour. If an entry with the same id already
14
+ * exists, the new entry only wins when its layer priority is greater
15
+ * than or equal to the existing one (same layer → last-write-wins).
16
+ */
17
+ add(entry: DesignMd, options?: DesignMdRegistryAddOptions): void;
18
+ addAll(entries: DesignMd[], options?: DesignMdRegistryAddOptions): void;
19
+ get(id: string): DesignMd | undefined;
20
+ list(): DesignMd[];
21
+ size(): number;
22
+ remove(id: string): boolean;
23
+ }
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Remote design-md sync (v2.27 SC-2).
3
+ *
4
+ * Resolve `github:owner/repo[/path]` or a raw HTTPS URL, fetch `*.design.md`
5
+ * (and `*.md` under design-md trees), validate frontmatter, inject attribution
6
+ * fields, and write into a target directory. Never executes remote code.
7
+ */
8
+ export declare const MAX_DESIGN_MD_BYTES: number;
9
+ export type FetchLike = (input: string, init?: {
10
+ headers?: Record<string, string>;
11
+ }) => Promise<{
12
+ ok: boolean;
13
+ status: number;
14
+ text(): Promise<string>;
15
+ json(): Promise<unknown>;
16
+ }>;
17
+ export interface RemoteSyncOptions {
18
+ /** `github:owner/repo[/subdir]` or absolute https URL to a file/dir listing. */
19
+ from: string;
20
+ /** Destination directory (usually `<cwd>/.uibot/design-md`). */
21
+ outDir: string;
22
+ /** Default license stamp when remote frontmatter omits one. */
23
+ defaultLicense?: string;
24
+ fetchImpl?: FetchLike;
25
+ /** Dry-run: validate + report without writing. */
26
+ dryRun?: boolean;
27
+ }
28
+ export interface RemoteSyncFileResult {
29
+ id: string;
30
+ path: string;
31
+ sourceUrl: string;
32
+ status: "written" | "skipped" | "dry-run";
33
+ reason?: string;
34
+ }
35
+ export interface RemoteSyncResult {
36
+ ok: boolean;
37
+ written: number;
38
+ skipped: number;
39
+ files: RemoteSyncFileResult[];
40
+ error?: string;
41
+ }
42
+ export interface ResolvedRemoteSource {
43
+ kind: "github" | "url";
44
+ /** Human label */
45
+ label: string;
46
+ /** List of absolute raw file URLs to fetch */
47
+ fileUrls: string[];
48
+ }
49
+ /**
50
+ * Expand a `from` locator into concrete raw file URLs.
51
+ * GitHub sources use the public Contents API (no auth) then map to raw.githubusercontent.com.
52
+ */
53
+ export declare function resolveRemoteSource(from: string, fetchImpl?: FetchLike): Promise<ResolvedRemoteSource>;
54
+ export declare function isDesignMdName(name: string): boolean;
55
+ /**
56
+ * Inject/overwrite attribution keys into YAML frontmatter without re-serializing body.
57
+ */
58
+ export declare function injectAttribution(raw: string, attrs: {
59
+ sourceUrl: string;
60
+ license: string;
61
+ }): string;
62
+ export declare function syncDesignMdFromRemote(options: RemoteSyncOptions): Promise<RemoteSyncResult>;
@@ -0,0 +1,34 @@
1
+ import type { DesignMdCategory, DesignMdLayer, DesignMdOrigin, DesignToken } from "@uibot/contracts";
2
+ /** Raw shape of the YAML frontmatter block. */
3
+ export interface DesignMdFrontmatter {
4
+ id: string;
5
+ title: string;
6
+ category: DesignMdCategory;
7
+ tags?: string[];
8
+ origin?: DesignMdOrigin;
9
+ sourceUrl?: string;
10
+ extractedTokens?: DesignToken[];
11
+ /** Design-quality rule ids this guide exempts (advisory rules only). */
12
+ exemptRules?: string[];
13
+ /**
14
+ * Optional registry merge layer declared in the file (v2.24+). The registry
15
+ * still stamps the authoritative layer on `add`/`addAll`; seed files (e.g. the
16
+ * bundled 9-section brand systems) self-declare `layer: auto` so a content
17
+ * loader can honour it. Previously this key was silently dropped.
18
+ */
19
+ layer?: DesignMdLayer;
20
+ /**
21
+ * Optional display name. When `title` is omitted, `name` is accepted as the
22
+ * title so starter files that follow docs/18 (`id` / `name` / `version`)
23
+ * still parse.
24
+ */
25
+ name?: string;
26
+ /** Optional semver / document version from frontmatter. */
27
+ version?: string;
28
+ }
29
+ /** Split a markdown file into frontmatter YAML + body text. */
30
+ export declare function splitFrontmatter(raw: string): {
31
+ meta: string;
32
+ body: string;
33
+ };
34
+ export declare function parseFrontmatter(raw: string): DesignMdFrontmatter;
@@ -0,0 +1,7 @@
1
+ import type { DesignMd, DesignMdSelectOptions, DesignMdSelector } from "@uibot/contracts";
2
+ import type { DesignMdRegistry } from "./registry.js";
3
+ export declare class DesignMdSelectorImpl implements DesignMdSelector {
4
+ private readonly registry;
5
+ constructor(registry: DesignMdRegistry);
6
+ select(options: DesignMdSelectOptions): DesignMd[];
7
+ }
@@ -0,0 +1,6 @@
1
+ import type { DesignToken } from "@uibot/contracts";
2
+ /**
3
+ * Scan a design-md body for inline design tokens.
4
+ * Returns extracted tokens; does not replace the body.
5
+ */
6
+ export declare function extractTokensFromBody(body: string): DesignToken[];
package/package.json CHANGED
@@ -1,6 +1,43 @@
1
1
  {
2
2
  "name": "@uibot/design-md",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "license": "MIT",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/Foundj/uibot.git",
8
+ "directory": "packages/design-md"
9
+ },
10
+ "type": "module",
11
+ "main": "./dist/index.js",
12
+ "module": "./dist/index.js",
13
+ "types": "./dist/index.d.ts",
14
+ "exports": {
15
+ ".": {
16
+ "types": "./dist/index.d.ts",
17
+ "default": "./dist/index.js"
18
+ }
19
+ },
20
+ "files": [
21
+ "content",
22
+ "dist",
23
+ "!dist/**/*.map",
24
+ "!dist/**/*.test.d.ts",
25
+ "!dist/**/*.spec.d.ts"
26
+ ],
27
+ "publishConfig": {
28
+ "access": "public"
29
+ },
30
+ "dependencies": {
31
+ "@uibot/contracts": "^0.2.0",
32
+ "@uibot/plugin-sdk": "^0.2.0",
33
+ "yaml": "2.9.1"
34
+ },
35
+ "devDependencies": {
36
+ "@uibot/design-md-importer": "^0.2.0"
37
+ },
38
+ "scripts": {
39
+ "build": "rm -rf dist && bun build --minify ./src/index.ts --outdir ./dist --format esm --target bun && bun x tsc -p tsconfig.json",
40
+ "typecheck": "bun x tsc -p tsconfig.json --noEmit",
41
+ "test": "bun test"
42
+ }
43
+ }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.