--- install scripts ---
### postinstall
bun ./scripts/postinstall-lock.ts
--- package/package.json (excerpt) ---
{
"name": "@mandujs/core",
"version": "0.54.10",
"description": "Mandu Framework Core - Spec, Generator, Guard, Runtime",
"type": "module",
"main": "./src/index.ts",
"types": "./src/index.ts",
"exports": {
".": "./src/index.ts",
"./a11y": "./src/a11y/index.ts",
"./agent": "./src/agent/index.ts",
"./auth": "./src/auth/index.ts",
"./auth/login": "./src/auth/login.ts",
"./auth/password": "./src/auth/password.ts",
"./auth/reset": "./src/auth/reset.ts",
"./auth/verification": "./src/auth/verification.ts",
"./client": "./src/client/index.ts",
"./client/rpc": "./src/client/rpc.ts",
"./contract": "./src/contract/index.ts",
"./contract/rpc": "./src/contract/rpc.ts",
"./content": "./src/content/index.ts",
"./content/prebuild": "./src/content/prebuild.ts",
"./content/collection": "./src/content/collection.ts",
"./content/sidebar": "./src/content/sidebar.ts",
"./content/slug": "./src/content/slug.ts",
"./content/llms-txt": "./src/content/llms-txt.ts",
"./content/schema": "./src/content/schema.ts",
"./config": "./src/config/index.ts",
"./config/mandu": "./src/config/mandu.ts",
"./config/validate": "./src/config/validate.ts",
"./db": "./src/db/index.ts",
"./db/migrations": "./src/db/migrations/index.ts",
"./db/migrations/history-table": "./src/db/migrations/history-table.ts",
"./db/migrations/runner": "./src/db/migrations/runner.ts",
"./deploy": "./src/deploy/index.ts",
--- package/src/watcher/reporter.ts (excerpt) ---
/**
* Brain v0.1 - Watch Reporter
*
* Formats and outputs watch warnings to the console.
* Warnings only - never blocks operations.
*/
import type { WatchWarning, WatchStatus } from "../brain/types";
import { getRule } from "./rules";
/**
* ANSI color codes for terminal output
*/
const colors = {
reset: "\x1b[0m",
bright: "\x1b[1m",
dim: "\x1b[2m",
red: "\x1b[31m",
green: "\x1b[32m",
yellow: "\x1b[33m",
blue: "\x1b[34m",
magenta: "\x1b[35m",
cyan: "\x1b[36m",
};
/**
* Check if colors should be used
*/
function useColors(): boolean {
if (process.env.NO_COLOR) return false;
if (typeof process?.stdout?.isTTY === "boolean") {
return process.stdout.isTTY;
}
return true;
}
/**
* Apply color if enabled
*/
function color(text: string, colorCode: string): string {
if (!useColors()) return text;
return `${colorCode}${text}${colors.reset}`;
}
/**
* Format a warning for terminal output
*/
export function formatWarning(warning: WatchWarning): string {
const rule = getRule(warning.ruleId);
// Event icons
const eventIcons: Record<string, string> = {
create: "��",
modify: "✏️",
delete: "��️",
};
const eventIcon = eventIcons[warning.event] || "��";
const ruleIcon = rule?.action === "error" ? "❌" : "⚠️";
const ruleColor = rule?.action === "error" ? colors.red : colors.yellow;
const lines: string[] = [];
lines.push(
`${eventIcon} ${ruleIcon} $
--- package/src/watcher/rules.ts (excerpt) ---
/**
* Brain v0.1 - Watch Architecture Rules
*
* 5 MVP rules that catch the most common mistakes.
* Rules only warn - they never block operations.
*/
import type { ArchRule, WatchWarning } from "../brain/types";
import path from "path";
import fs from "fs/promises";
/**
* The 5 MVP Architecture Rules
*
* These rules cover the most frequent mistakes in Mandu projects:
* 1. Direct modification of generated files
* 2. Slot files in wrong locations
* 3. Slot file naming convention
* 4. Contract file naming convention
* 5. Forbidden imports in generated files
*/
export const MVP_RULES: ArchRule[] = [
{
id: "GENERATED_DIRECT_EDIT",
name: "Generated Direct Edit",
description: "Generated 파일은 직접 수정하면 안 됩니다",
pattern: "**/generated/**",
action: "warn",
message: "Generated 파일이 직접 수정되었습니다. 이 파일은 `mandu generate`로 재생성됩니다.",
agentAction: "regenerate",
agentCommand: "mandu_generate",
},
{
id: "WRONG_SLOT_LOCATION",
name: "Wrong Slot Location",
description: "Slot 파일은 spec/slots/ 디렉토리에 있어야 합니다",
pattern: "**/*.slot.ts",
action: "warn",
message: "Slot 파일이 잘못된 위치에 있습니다. spec/slots/ 디렉토리로 이동하세요.",
excludePattern: "spec/slots/**",
agentAction: "move",
agentCommand: "mandu_check_location",
},
{
id: "SLOT_NAMING",
name: "Slot Naming Convention",
description: "Slot 파일은 .slot.ts로 끝나야 합니다",
pattern: "spec/slots/*.ts",
action: "warn",
mess{
"name": "@mandujs/core",
"version": "0.54.10",
"description": "Mandu Framework Core - Spec, Generator, Guard, Runtime",
"type": "module",
"main": "./src/index.ts",
"types": "./src/index.ts",
"exports": {
".": "./src/index.ts",
"./a11y": "./src/a11y/index.ts",
"./agent": "./src/agent/index.ts",
"./auth": "./src/auth/index.ts",
"./auth/login": "./src/auth/login.ts",
"./auth/password": "./src/auth/password.ts",
"./auth/reset": "./src/auth/reset.ts",
"./auth/verification": "./src/auth/verification.ts",
"./client": "./src/client/index.ts",
"./client/rpc": "./src/client/rpc.ts",
"./contract": "./src/contract/index.ts",
"./contract/rpc": "./src/contract/rpc.ts",
"./content": "./src/content/index.ts",
"./content/prebuild": "./src/content/prebuild.ts",
"./content/collection": "./src/content/collection.ts",
"./content/sidebar": "./src/content/sidebar.ts",
"./content/slug": "./src/content/slug.ts",
"./content/llms-txt": "./src/content/llms-txt.ts",
"./content/schema": "./src/content/schema.ts",
"./config": "./src/config/index.ts",
"./config/mandu": "./src/config/mandu.ts",
"./config/validate": "./src/config/validate.ts",
"./db": "./src/db/index.ts",
"./db/migrations": "./src/db/migrations/index.ts",
"./db/migrations/history-table": "./src/db/migrations/history-table.ts",
"./db/migrations/runner": "./src/db/migrations/runner.ts",
"./deploy": "./src/deploy/index.ts",
/**
* Brain v0.1 - Watch Architecture Rules
*
* 5 MVP rules that catch the most common mistakes.
* Rules only warn - they never block operations.
*/
import type { ArchRule, WatchWarning } from "../brain/types";
import path from "path";
import fs from "fs/promises";
/**
* The 5 MVP Architecture Rules
*
* These rules cover the most frequent mistakes in Mandu projects:
* 1. Direct modification of generated files
* 2. Slot files in wrong locations
* 3. Slot file naming convention
* 4. Contract file naming convention
* 5. Forbidden imports in generated files
*/
export const MVP_RULES: ArchRule[] = [
{
id: "GENERATED_DIRECT_EDIT",
name: "Generated Direct Edit",
description: "Generated 파일은 직접 수정하면 안 됩니다",
pattern: "**/generated/**",
action: "warn",
message: "Generated 파일이 직접 수정되었습니다. 이 파일은 `mandu generate`로 재생성됩니다.",
agentAction: "regenerate",
agentCommand: "mandu_generate",
},
{
id: "WRONG_SLOT_LOCATION",
name: "Wrong Slot Location",
description: "Slot 파일은 spec/slots/ 디렉토리에 있어야 합니다",
pattern: "**/*.slot.ts",
action: "warn",
message: "Slot 파일이 잘못된 위치에 있습니다. spec/slots/ 디렉토리로 이동하세요.",
excludePattern: "spec/slots/**",
agentAction: "move",
agentCommand: "mandu_check_location",
},
{
id: "SLOT_NAMING",
name: "Slot Naming Convention",
description: "Slot 파일은 .slot.ts로 끝나야 합니다",
pattern: "spec/slots/*.ts",
action: "warn",
mess