🚀 Socket Launch Week Day 4:Socket MCP Adds Org Alerts, Threat Feed Review, and Package Inspection.Learn more
Sign In

@agent-format/renderer

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@agent-format/renderer - npm Package Compare versions

Comparing version
0.1.1
to
0.1.2
+428
-30
dist/index.cjs

@@ -415,12 +415,408 @@ "use strict";

// src/sections/InheritanceDiagramSection.tsx
var import_jsx_runtime13 = require("react/jsx-runtime");
var MAX_GENERATIONS = 6;
var LINE_H = 22;
var NAME_SIZE = 16;
var NAME_LINE_H = 22;
var DBL_GAP = 4;
var HORIZ_Y_GAP = 90;
var CHILD_V_GAP = 30;
var GEN_X_STEP = 340;
var SPOUSE_GAP = 90;
var TEXT_X = 60;
var CHILD_TEXT_X = 480;
var TRUNK_X = CHILD_TEXT_X - 30;
var DBL_X = 80;
var DEC_TOP_Y = 20;
function InheritanceDiagramSectionView({ section }) {
const data = section.data;
const persons = data?.persons ?? [];
const rels = data?.relationships ?? [];
const variant = data?.variant ?? "jp-court";
if (persons.length === 0) {
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "af-empty", children: "No persons in diagram." });
}
if (variant !== "jp-court") {
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("p", { className: "af-empty", children: [
'Inheritance-diagram variant "',
variant,
'" is not yet implemented. Only "jp-court" is supported in v0.1.'
] });
}
const focused = data?.focusedPersonId ? persons.find((p) => p.id === data.focusedPersonId) : null;
const decedent = focused || persons.find((p) => Boolean(p.deathDate)) || persons[0];
if (!decedent) return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "af-empty", children: "No decedent." });
const findSpouseOfRoot = () => {
const rel = rels.find(
(r) => r.type === "spouse" && (r.person1Id === decedent.id || r.person2Id === decedent.id)
);
if (!rel) return null;
const sid = rel.person1Id === decedent.id ? rel.person2Id : rel.person1Id;
return persons.find((p) => p.id === sid) ?? null;
};
const findChildren = (parentId, spouseId) => {
const pids = /* @__PURE__ */ new Set([parentId]);
if (spouseId) pids.add(spouseId);
const kids = [];
const seen = /* @__PURE__ */ new Set();
for (const r of rels) {
if (r.type === "parent-child" && pids.has(r.person1Id)) {
if (seen.has(r.person2Id)) continue;
const c = persons.find((p) => p.id === r.person2Id);
if (c) {
seen.add(r.person2Id);
kids.push(c);
}
}
}
return kids;
};
const findSpouse = (personId) => {
const rel = rels.find(
(r) => r.type === "spouse" && r.person1Id !== decedent.id && r.person2Id !== decedent.id && (r.person1Id === personId || r.person2Id === personId)
);
if (!rel) return null;
const sid = rel.person1Id === personId ? rel.person2Id : rel.person1Id;
return persons.find((p) => p.id === sid) ?? null;
};
const blockHeight = (p) => {
let n = 0;
if (p.address) n++;
if (p.birthday) n++;
if (p.deathDate) n++;
n++;
return n * LINE_H + NAME_LINE_H;
};
let elementKey = 0;
const nextKey = () => `el-${++elementKey}`;
const renderBlock = (p, x, topY, roleLabel) => {
const elements = [];
let y = topY;
if (p.address) {
const lbl = roleLabel === "\u88AB\u76F8\u7D9A\u4EBA" ? "\u6700\u5F8C\u306E\u4F4F\u6240" : "\u4F4F\u6240";
elements.push(
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("text", { x, y, fontSize: "11pt", children: `${lbl}\u3000${p.address}` }, nextKey())
);
y += LINE_H;
}
if (p.birthday) {
elements.push(
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("text", { x, y, fontSize: "11pt", children: `\u51FA\u751F\u3000${p.birthday}` }, nextKey())
);
y += LINE_H;
}
if (p.deathDate) {
elements.push(
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("text", { x, y, fontSize: "11pt", children: `\u6B7B\u4EA1\u3000${p.deathDate}` }, nextKey())
);
y += LINE_H;
}
elements.push(
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("text", { x: x + 8, y, fontSize: "11pt", children: `\uFF08${roleLabel}\uFF09` }, nextKey())
);
y += LINE_H;
elements.push(
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
"text",
{
x,
y,
fontSize: `${NAME_SIZE}pt`,
fontWeight: "bold",
letterSpacing: "0.2em",
children: p.name
},
nextKey()
)
);
const nameBaseY = y;
y += NAME_LINE_H;
return { elements, nameBaseY, blockEndY: y };
};
const measureChildSlot = (c, depth) => {
if (depth > MAX_GENERATIONS) return blockHeight(c);
let h = blockHeight(c);
const sp = findSpouse(c.id);
if (sp) h += SPOUSE_GAP + blockHeight(sp);
const grandkids = findChildren(c.id, sp ? sp.id : null);
if (grandkids.length > 0) {
const subH = measureChildGroup(grandkids, depth + 1);
h = Math.max(h, subH);
}
return h;
};
const measureChildGroup = (childList, depth) => {
let total = 0;
childList.forEach((c, i) => {
if (i > 0) total += CHILD_V_GAP;
total += measureChildSlot(c, depth);
});
return total;
};
const lineProps = {
stroke: "#000",
strokeWidth: 1.2
};
const renderChildGroup = (childList, textX, startY, depth) => {
const elements = [];
const nameYs = [];
let cy = startY;
if (depth > MAX_GENERATIONS) {
elements.push(
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
"text",
{
x: textX,
y: cy,
fontSize: "11pt",
fill: "#999",
children: [
"\u2026 (tree truncated at generation ",
MAX_GENERATIONS,
")"
]
},
nextKey()
)
);
return { elements, nameYs, endY: cy + LINE_H };
}
childList.forEach((c, i) => {
if (i > 0) cy += CHILD_V_GAP;
const cb = renderBlock(c, textX, cy, c.role || "\u76F8\u7D9A\u4EBA");
elements.push(...cb.elements);
nameYs.push(cb.nameBaseY);
const childSpouse = findSpouse(c.id);
let connectorY = cb.nameBaseY;
if (childSpouse) {
const spTopY = cb.blockEndY + SPOUSE_GAP;
const spBlock2 = renderBlock(
childSpouse,
textX,
spTopY,
childSpouse.role || "\u914D\u5076\u8005"
);
elements.push(...spBlock2.elements);
const miniDblX = textX + 20;
const miniGapTop = cb.blockEndY + 5;
const miniGapBot = spTopY - 25;
elements.push(
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
"line",
{
x1: miniDblX - DBL_GAP,
y1: miniGapTop,
x2: miniDblX - DBL_GAP,
y2: miniGapBot,
...lineProps
},
nextKey()
)
);
elements.push(
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
"line",
{
x1: miniDblX + DBL_GAP,
y1: miniGapTop,
x2: miniDblX + DBL_GAP,
y2: miniGapBot,
...lineProps
},
nextKey()
)
);
connectorY = cb.blockEndY + SPOUSE_GAP / 2;
}
const grandkids = findChildren(c.id, childSpouse ? childSpouse.id : null);
if (grandkids.length > 0) {
const gcTextX = textX + GEN_X_STEP;
const gcTrunkX = gcTextX - 30;
const gcResult = renderChildGroup(grandkids, gcTextX, cy, depth + 1);
elements.push(...gcResult.elements);
elements.push(
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
"line",
{
x1: textX + 180,
y1: connectorY,
x2: gcTrunkX,
y2: connectorY,
...lineProps
},
nextKey()
)
);
if (gcResult.nameYs.length > 0) {
const gcTrunkTop = Math.min(connectorY, gcResult.nameYs[0]);
const gcTrunkBot = Math.max(
connectorY,
gcResult.nameYs[gcResult.nameYs.length - 1]
);
elements.push(
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
"line",
{
x1: gcTrunkX,
y1: gcTrunkTop,
x2: gcTrunkX,
y2: gcTrunkBot,
...lineProps
},
nextKey()
)
);
gcResult.nameYs.forEach((gny) => {
elements.push(
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
"line",
{
x1: gcTrunkX,
y1: gny,
x2: gcTextX - 5,
y2: gny,
...lineProps
},
nextKey()
)
);
});
}
}
cy += measureChildSlot(c, depth);
});
return { elements, nameYs, endY: cy };
};
const dec = renderBlock(decedent, TEXT_X, DEC_TOP_Y, "\u88AB\u76F8\u7D9A\u4EBA");
const spouse = findSpouseOfRoot();
const spouseTopY = dec.blockEndY + HORIZ_Y_GAP;
const spBlock = spouse ? renderBlock(spouse, TEXT_X, spouseTopY, spouse.role || "\u76F8\u7D9A\u4EBA") : null;
const dblMidY = dec.blockEndY + HORIZ_Y_GAP / 2;
const children = findChildren(decedent.id, spouse ? spouse.id : null);
const totalChildH = children.length > 0 ? measureChildGroup(children, 0) : 0;
let childGroupTopY = dblMidY - totalChildH / 2;
if (childGroupTopY < 10) childGroupTopY = 10;
const childResult = children.length > 0 ? renderChildGroup(children, CHILD_TEXT_X, childGroupTopY, 0) : { elements: [], nameYs: [], endY: childGroupTopY };
const svgH = Math.max(spBlock ? spBlock.blockEndY : dec.blockEndY, childResult.endY) + 30;
const svgParts = [];
svgParts.push(...dec.elements);
if (spBlock) svgParts.push(...spBlock.elements);
if (spouse) {
const gapTop = dec.blockEndY + 5;
const gapBot = spouseTopY - 25;
svgParts.push(
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
"line",
{
x1: DBL_X - DBL_GAP,
y1: gapTop,
x2: DBL_X - DBL_GAP,
y2: gapBot,
...lineProps
},
nextKey()
)
);
svgParts.push(
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
"line",
{
x1: DBL_X + DBL_GAP,
y1: gapTop,
x2: DBL_X + DBL_GAP,
y2: gapBot,
...lineProps
},
nextKey()
)
);
if (children.length > 0) {
svgParts.push(
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
"line",
{
x1: DBL_X + DBL_GAP,
y1: dblMidY,
x2: TRUNK_X,
y2: dblMidY,
...lineProps
},
nextKey()
)
);
}
} else if (children.length > 0) {
svgParts.push(
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
"line",
{
x1: TEXT_X + 200,
y1: dec.nameBaseY,
x2: TRUNK_X,
y2: dec.nameBaseY,
...lineProps
},
nextKey()
)
);
}
svgParts.push(...childResult.elements);
if (childResult.nameYs.length > 0) {
const trunkTop = Math.min(
spouse ? dblMidY : dec.nameBaseY,
childResult.nameYs[0]
);
const trunkBot = childResult.nameYs[childResult.nameYs.length - 1];
svgParts.push(
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
"line",
{
x1: TRUNK_X,
y1: trunkTop,
x2: TRUNK_X,
y2: trunkBot,
...lineProps
},
nextKey()
)
);
childResult.nameYs.forEach((cny) => {
svgParts.push(
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
"line",
{
x1: TRUNK_X,
y1: cny,
x2: CHILD_TEXT_X - 5,
y2: cny,
...lineProps
},
nextKey()
)
);
});
}
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "af-inheritance-diagram", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
"svg",
{
xmlns: "http://www.w3.org/2000/svg",
width: "100%",
viewBox: `0 0 1400 ${svgH}`,
style: { overflow: "visible" },
children: svgParts
}
) });
}
// src/sections/Fallback.tsx
var import_jsx_runtime13 = require("react/jsx-runtime");
var import_jsx_runtime14 = require("react/jsx-runtime");
function FallbackSectionView({ section }) {
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "af-fallback", children: [
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { children: [
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "af-fallback", children: [
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { children: [
"Renderer for section type ",
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("strong", { children: section.type }),
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("strong", { children: section.type }),
" is not yet implemented in this viewer."
] }),
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("pre", { children: JSON.stringify(section.data, null, 2) })
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("pre", { children: JSON.stringify(section.data, null, 2) })
] });

@@ -430,19 +826,19 @@ }

// src/index.tsx
var import_jsx_runtime14 = require("react/jsx-runtime");
var import_jsx_runtime15 = require("react/jsx-runtime");
function AgentRenderer({ data, className }) {
const sections = [...data.sections].sort((a, b) => a.order - b.order);
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: `af-root ${className ?? ""}`, children: [
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("header", { className: "af-header", children: [
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("h1", { className: "af-title", children: [
data.icon && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { children: data.icon }),
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { children: data.name })
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: `af-root ${className ?? ""}`, children: [
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("header", { className: "af-header", children: [
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("h1", { className: "af-title", children: [
data.icon && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { children: data.icon }),
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { children: data.name })
] }),
data.description && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "af-description", children: data.description })
data.description && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { className: "af-description", children: data.description })
] }),
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "af-sections", children: sections.map((section) => /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("section", { className: "af-section", children: [
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("header", { className: "af-section-header", children: [
section.icon && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { children: section.icon }),
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { children: section.label })
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "af-sections", children: sections.map((section) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("section", { className: "af-section", children: [
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("header", { className: "af-section-header", children: [
section.icon && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { children: section.icon }),
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { children: section.label })
] }),
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "af-section-body", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SectionRenderer, { section }) })
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "af-section-body", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(SectionRenderer, { section }) })
] }, section.id)) })

@@ -454,27 +850,29 @@ ] });

case "kanban":
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(KanbanSectionView, { section });
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(KanbanSectionView, { section });
case "checklist":
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ChecklistSectionView, { section });
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ChecklistSectionView, { section });
case "notes":
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(NotesSectionView, { section });
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(NotesSectionView, { section });
case "timeline":
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(TimelineSectionView, { section });
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(TimelineSectionView, { section });
case "table":
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(TableSectionView, { section });
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(TableSectionView, { section });
case "log":
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(LogSectionView, { section });
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(LogSectionView, { section });
case "metrics":
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(MetricsSectionView, { section });
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(MetricsSectionView, { section });
case "diagram":
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(DiagramSectionView, { section });
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(DiagramSectionView, { section });
case "report":
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ReportSectionView, { section });
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ReportSectionView, { section });
case "form":
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(FormSectionView, { section });
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(FormSectionView, { section });
case "links":
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(LinksSectionView, { section });
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(LinksSectionView, { section });
case "references":
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ReferencesSectionView, { section });
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ReferencesSectionView, { section });
case "inheritance-diagram":
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(InheritanceDiagramSectionView, { section });
default:
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(FallbackSectionView, { section });
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(FallbackSectionView, { section });
}

@@ -481,0 +879,0 @@ }

import * as react_jsx_runtime from 'react/jsx-runtime';
type SectionType = 'kanban' | 'checklist' | 'notes' | 'timeline' | 'table' | 'log' | 'metrics' | 'diagram' | 'report' | 'form' | 'links' | 'references';
type SectionType = 'kanban' | 'checklist' | 'notes' | 'timeline' | 'table' | 'log' | 'metrics' | 'diagram' | 'report' | 'form' | 'links' | 'references' | 'inheritance-diagram';
interface SectionBase {

@@ -232,3 +232,29 @@ id: string;

}
type Section = KanbanSection | ChecklistSection | NotesSection | TimelineSection | TableSection | LogSection | MetricsSection | DiagramSection | ReportSection | FormSection | LinksSection | ReferencesSection;
interface InheritanceDiagramPerson {
id: string;
name: string;
role?: string;
birthday?: string;
address?: string;
deathDate?: string;
aliases?: string[];
}
interface InheritanceDiagramRelationship {
type: 'spouse' | 'parent-child';
person1Id: string;
person2Id: string;
details?: string;
dissolved?: boolean;
}
interface InheritanceDiagramData {
variant: string;
persons: InheritanceDiagramPerson[];
relationships: InheritanceDiagramRelationship[];
focusedPersonId?: string;
}
interface InheritanceDiagramSection extends SectionBase {
type: 'inheritance-diagram';
data: InheritanceDiagramData;
}
type Section = KanbanSection | ChecklistSection | NotesSection | TimelineSection | TableSection | LogSection | MetricsSection | DiagramSection | ReportSection | FormSection | LinksSection | ReferencesSection | InheritanceDiagramSection;
type AgentTaskTrigger = 'manual' | 'daily' | 'weekly';

@@ -271,2 +297,2 @@ interface AgentTask {

export { type AgentConfig, type AgentFile, type AgentMemory, AgentRenderer, type AgentTask, type AgentTaskTrigger, type ChecklistGroup, type ChecklistItem, type ChecklistSection, type DiagramNode, type DiagramSection, type FormField, type FormSection, type FormSubmission, type KanbanColumn, type KanbanData, type KanbanItem, type KanbanItemComment, type KanbanLabel, type KanbanSection, type KanbanTeamMember, type LinkItem, type LinksSection, type LogEntry, type LogSection, type MetricCard, type MetricsSection, type NoteBlock, type NotesSection, type ReferenceFileItem, type ReferencesSection, type ReportEntry, type ReportSection, type Section, type SectionBase, type SectionType, type TableColumn, type TableColumnType, type TableSection, type TimelineItem, type TimelineMilestone, type TimelineSection };
export { type AgentConfig, type AgentFile, type AgentMemory, AgentRenderer, type AgentTask, type AgentTaskTrigger, type ChecklistGroup, type ChecklistItem, type ChecklistSection, type DiagramNode, type DiagramSection, type FormField, type FormSection, type FormSubmission, type InheritanceDiagramData, type InheritanceDiagramPerson, type InheritanceDiagramRelationship, type InheritanceDiagramSection, type KanbanColumn, type KanbanData, type KanbanItem, type KanbanItemComment, type KanbanLabel, type KanbanSection, type KanbanTeamMember, type LinkItem, type LinksSection, type LogEntry, type LogSection, type MetricCard, type MetricsSection, type NoteBlock, type NotesSection, type ReferenceFileItem, type ReferencesSection, type ReportEntry, type ReportSection, type Section, type SectionBase, type SectionType, type TableColumn, type TableColumnType, type TableSection, type TimelineItem, type TimelineMilestone, type TimelineSection };
import * as react_jsx_runtime from 'react/jsx-runtime';
type SectionType = 'kanban' | 'checklist' | 'notes' | 'timeline' | 'table' | 'log' | 'metrics' | 'diagram' | 'report' | 'form' | 'links' | 'references';
type SectionType = 'kanban' | 'checklist' | 'notes' | 'timeline' | 'table' | 'log' | 'metrics' | 'diagram' | 'report' | 'form' | 'links' | 'references' | 'inheritance-diagram';
interface SectionBase {

@@ -232,3 +232,29 @@ id: string;

}
type Section = KanbanSection | ChecklistSection | NotesSection | TimelineSection | TableSection | LogSection | MetricsSection | DiagramSection | ReportSection | FormSection | LinksSection | ReferencesSection;
interface InheritanceDiagramPerson {
id: string;
name: string;
role?: string;
birthday?: string;
address?: string;
deathDate?: string;
aliases?: string[];
}
interface InheritanceDiagramRelationship {
type: 'spouse' | 'parent-child';
person1Id: string;
person2Id: string;
details?: string;
dissolved?: boolean;
}
interface InheritanceDiagramData {
variant: string;
persons: InheritanceDiagramPerson[];
relationships: InheritanceDiagramRelationship[];
focusedPersonId?: string;
}
interface InheritanceDiagramSection extends SectionBase {
type: 'inheritance-diagram';
data: InheritanceDiagramData;
}
type Section = KanbanSection | ChecklistSection | NotesSection | TimelineSection | TableSection | LogSection | MetricsSection | DiagramSection | ReportSection | FormSection | LinksSection | ReferencesSection | InheritanceDiagramSection;
type AgentTaskTrigger = 'manual' | 'daily' | 'weekly';

@@ -271,2 +297,2 @@ interface AgentTask {

export { type AgentConfig, type AgentFile, type AgentMemory, AgentRenderer, type AgentTask, type AgentTaskTrigger, type ChecklistGroup, type ChecklistItem, type ChecklistSection, type DiagramNode, type DiagramSection, type FormField, type FormSection, type FormSubmission, type KanbanColumn, type KanbanData, type KanbanItem, type KanbanItemComment, type KanbanLabel, type KanbanSection, type KanbanTeamMember, type LinkItem, type LinksSection, type LogEntry, type LogSection, type MetricCard, type MetricsSection, type NoteBlock, type NotesSection, type ReferenceFileItem, type ReferencesSection, type ReportEntry, type ReportSection, type Section, type SectionBase, type SectionType, type TableColumn, type TableColumnType, type TableSection, type TimelineItem, type TimelineMilestone, type TimelineSection };
export { type AgentConfig, type AgentFile, type AgentMemory, AgentRenderer, type AgentTask, type AgentTaskTrigger, type ChecklistGroup, type ChecklistItem, type ChecklistSection, type DiagramNode, type DiagramSection, type FormField, type FormSection, type FormSubmission, type InheritanceDiagramData, type InheritanceDiagramPerson, type InheritanceDiagramRelationship, type InheritanceDiagramSection, type KanbanColumn, type KanbanData, type KanbanItem, type KanbanItemComment, type KanbanLabel, type KanbanSection, type KanbanTeamMember, type LinkItem, type LinksSection, type LogEntry, type LogSection, type MetricCard, type MetricsSection, type NoteBlock, type NotesSection, type ReferenceFileItem, type ReferencesSection, type ReportEntry, type ReportSection, type Section, type SectionBase, type SectionType, type TableColumn, type TableColumnType, type TableSection, type TimelineItem, type TimelineMilestone, type TimelineSection };

@@ -389,12 +389,408 @@ // src/sections/KanbanSection.tsx

// src/sections/InheritanceDiagramSection.tsx
import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
var MAX_GENERATIONS = 6;
var LINE_H = 22;
var NAME_SIZE = 16;
var NAME_LINE_H = 22;
var DBL_GAP = 4;
var HORIZ_Y_GAP = 90;
var CHILD_V_GAP = 30;
var GEN_X_STEP = 340;
var SPOUSE_GAP = 90;
var TEXT_X = 60;
var CHILD_TEXT_X = 480;
var TRUNK_X = CHILD_TEXT_X - 30;
var DBL_X = 80;
var DEC_TOP_Y = 20;
function InheritanceDiagramSectionView({ section }) {
const data = section.data;
const persons = data?.persons ?? [];
const rels = data?.relationships ?? [];
const variant = data?.variant ?? "jp-court";
if (persons.length === 0) {
return /* @__PURE__ */ jsx13("p", { className: "af-empty", children: "No persons in diagram." });
}
if (variant !== "jp-court") {
return /* @__PURE__ */ jsxs12("p", { className: "af-empty", children: [
'Inheritance-diagram variant "',
variant,
'" is not yet implemented. Only "jp-court" is supported in v0.1.'
] });
}
const focused = data?.focusedPersonId ? persons.find((p) => p.id === data.focusedPersonId) : null;
const decedent = focused || persons.find((p) => Boolean(p.deathDate)) || persons[0];
if (!decedent) return /* @__PURE__ */ jsx13("p", { className: "af-empty", children: "No decedent." });
const findSpouseOfRoot = () => {
const rel = rels.find(
(r) => r.type === "spouse" && (r.person1Id === decedent.id || r.person2Id === decedent.id)
);
if (!rel) return null;
const sid = rel.person1Id === decedent.id ? rel.person2Id : rel.person1Id;
return persons.find((p) => p.id === sid) ?? null;
};
const findChildren = (parentId, spouseId) => {
const pids = /* @__PURE__ */ new Set([parentId]);
if (spouseId) pids.add(spouseId);
const kids = [];
const seen = /* @__PURE__ */ new Set();
for (const r of rels) {
if (r.type === "parent-child" && pids.has(r.person1Id)) {
if (seen.has(r.person2Id)) continue;
const c = persons.find((p) => p.id === r.person2Id);
if (c) {
seen.add(r.person2Id);
kids.push(c);
}
}
}
return kids;
};
const findSpouse = (personId) => {
const rel = rels.find(
(r) => r.type === "spouse" && r.person1Id !== decedent.id && r.person2Id !== decedent.id && (r.person1Id === personId || r.person2Id === personId)
);
if (!rel) return null;
const sid = rel.person1Id === personId ? rel.person2Id : rel.person1Id;
return persons.find((p) => p.id === sid) ?? null;
};
const blockHeight = (p) => {
let n = 0;
if (p.address) n++;
if (p.birthday) n++;
if (p.deathDate) n++;
n++;
return n * LINE_H + NAME_LINE_H;
};
let elementKey = 0;
const nextKey = () => `el-${++elementKey}`;
const renderBlock = (p, x, topY, roleLabel) => {
const elements = [];
let y = topY;
if (p.address) {
const lbl = roleLabel === "\u88AB\u76F8\u7D9A\u4EBA" ? "\u6700\u5F8C\u306E\u4F4F\u6240" : "\u4F4F\u6240";
elements.push(
/* @__PURE__ */ jsx13("text", { x, y, fontSize: "11pt", children: `${lbl}\u3000${p.address}` }, nextKey())
);
y += LINE_H;
}
if (p.birthday) {
elements.push(
/* @__PURE__ */ jsx13("text", { x, y, fontSize: "11pt", children: `\u51FA\u751F\u3000${p.birthday}` }, nextKey())
);
y += LINE_H;
}
if (p.deathDate) {
elements.push(
/* @__PURE__ */ jsx13("text", { x, y, fontSize: "11pt", children: `\u6B7B\u4EA1\u3000${p.deathDate}` }, nextKey())
);
y += LINE_H;
}
elements.push(
/* @__PURE__ */ jsx13("text", { x: x + 8, y, fontSize: "11pt", children: `\uFF08${roleLabel}\uFF09` }, nextKey())
);
y += LINE_H;
elements.push(
/* @__PURE__ */ jsx13(
"text",
{
x,
y,
fontSize: `${NAME_SIZE}pt`,
fontWeight: "bold",
letterSpacing: "0.2em",
children: p.name
},
nextKey()
)
);
const nameBaseY = y;
y += NAME_LINE_H;
return { elements, nameBaseY, blockEndY: y };
};
const measureChildSlot = (c, depth) => {
if (depth > MAX_GENERATIONS) return blockHeight(c);
let h = blockHeight(c);
const sp = findSpouse(c.id);
if (sp) h += SPOUSE_GAP + blockHeight(sp);
const grandkids = findChildren(c.id, sp ? sp.id : null);
if (grandkids.length > 0) {
const subH = measureChildGroup(grandkids, depth + 1);
h = Math.max(h, subH);
}
return h;
};
const measureChildGroup = (childList, depth) => {
let total = 0;
childList.forEach((c, i) => {
if (i > 0) total += CHILD_V_GAP;
total += measureChildSlot(c, depth);
});
return total;
};
const lineProps = {
stroke: "#000",
strokeWidth: 1.2
};
const renderChildGroup = (childList, textX, startY, depth) => {
const elements = [];
const nameYs = [];
let cy = startY;
if (depth > MAX_GENERATIONS) {
elements.push(
/* @__PURE__ */ jsxs12(
"text",
{
x: textX,
y: cy,
fontSize: "11pt",
fill: "#999",
children: [
"\u2026 (tree truncated at generation ",
MAX_GENERATIONS,
")"
]
},
nextKey()
)
);
return { elements, nameYs, endY: cy + LINE_H };
}
childList.forEach((c, i) => {
if (i > 0) cy += CHILD_V_GAP;
const cb = renderBlock(c, textX, cy, c.role || "\u76F8\u7D9A\u4EBA");
elements.push(...cb.elements);
nameYs.push(cb.nameBaseY);
const childSpouse = findSpouse(c.id);
let connectorY = cb.nameBaseY;
if (childSpouse) {
const spTopY = cb.blockEndY + SPOUSE_GAP;
const spBlock2 = renderBlock(
childSpouse,
textX,
spTopY,
childSpouse.role || "\u914D\u5076\u8005"
);
elements.push(...spBlock2.elements);
const miniDblX = textX + 20;
const miniGapTop = cb.blockEndY + 5;
const miniGapBot = spTopY - 25;
elements.push(
/* @__PURE__ */ jsx13(
"line",
{
x1: miniDblX - DBL_GAP,
y1: miniGapTop,
x2: miniDblX - DBL_GAP,
y2: miniGapBot,
...lineProps
},
nextKey()
)
);
elements.push(
/* @__PURE__ */ jsx13(
"line",
{
x1: miniDblX + DBL_GAP,
y1: miniGapTop,
x2: miniDblX + DBL_GAP,
y2: miniGapBot,
...lineProps
},
nextKey()
)
);
connectorY = cb.blockEndY + SPOUSE_GAP / 2;
}
const grandkids = findChildren(c.id, childSpouse ? childSpouse.id : null);
if (grandkids.length > 0) {
const gcTextX = textX + GEN_X_STEP;
const gcTrunkX = gcTextX - 30;
const gcResult = renderChildGroup(grandkids, gcTextX, cy, depth + 1);
elements.push(...gcResult.elements);
elements.push(
/* @__PURE__ */ jsx13(
"line",
{
x1: textX + 180,
y1: connectorY,
x2: gcTrunkX,
y2: connectorY,
...lineProps
},
nextKey()
)
);
if (gcResult.nameYs.length > 0) {
const gcTrunkTop = Math.min(connectorY, gcResult.nameYs[0]);
const gcTrunkBot = Math.max(
connectorY,
gcResult.nameYs[gcResult.nameYs.length - 1]
);
elements.push(
/* @__PURE__ */ jsx13(
"line",
{
x1: gcTrunkX,
y1: gcTrunkTop,
x2: gcTrunkX,
y2: gcTrunkBot,
...lineProps
},
nextKey()
)
);
gcResult.nameYs.forEach((gny) => {
elements.push(
/* @__PURE__ */ jsx13(
"line",
{
x1: gcTrunkX,
y1: gny,
x2: gcTextX - 5,
y2: gny,
...lineProps
},
nextKey()
)
);
});
}
}
cy += measureChildSlot(c, depth);
});
return { elements, nameYs, endY: cy };
};
const dec = renderBlock(decedent, TEXT_X, DEC_TOP_Y, "\u88AB\u76F8\u7D9A\u4EBA");
const spouse = findSpouseOfRoot();
const spouseTopY = dec.blockEndY + HORIZ_Y_GAP;
const spBlock = spouse ? renderBlock(spouse, TEXT_X, spouseTopY, spouse.role || "\u76F8\u7D9A\u4EBA") : null;
const dblMidY = dec.blockEndY + HORIZ_Y_GAP / 2;
const children = findChildren(decedent.id, spouse ? spouse.id : null);
const totalChildH = children.length > 0 ? measureChildGroup(children, 0) : 0;
let childGroupTopY = dblMidY - totalChildH / 2;
if (childGroupTopY < 10) childGroupTopY = 10;
const childResult = children.length > 0 ? renderChildGroup(children, CHILD_TEXT_X, childGroupTopY, 0) : { elements: [], nameYs: [], endY: childGroupTopY };
const svgH = Math.max(spBlock ? spBlock.blockEndY : dec.blockEndY, childResult.endY) + 30;
const svgParts = [];
svgParts.push(...dec.elements);
if (spBlock) svgParts.push(...spBlock.elements);
if (spouse) {
const gapTop = dec.blockEndY + 5;
const gapBot = spouseTopY - 25;
svgParts.push(
/* @__PURE__ */ jsx13(
"line",
{
x1: DBL_X - DBL_GAP,
y1: gapTop,
x2: DBL_X - DBL_GAP,
y2: gapBot,
...lineProps
},
nextKey()
)
);
svgParts.push(
/* @__PURE__ */ jsx13(
"line",
{
x1: DBL_X + DBL_GAP,
y1: gapTop,
x2: DBL_X + DBL_GAP,
y2: gapBot,
...lineProps
},
nextKey()
)
);
if (children.length > 0) {
svgParts.push(
/* @__PURE__ */ jsx13(
"line",
{
x1: DBL_X + DBL_GAP,
y1: dblMidY,
x2: TRUNK_X,
y2: dblMidY,
...lineProps
},
nextKey()
)
);
}
} else if (children.length > 0) {
svgParts.push(
/* @__PURE__ */ jsx13(
"line",
{
x1: TEXT_X + 200,
y1: dec.nameBaseY,
x2: TRUNK_X,
y2: dec.nameBaseY,
...lineProps
},
nextKey()
)
);
}
svgParts.push(...childResult.elements);
if (childResult.nameYs.length > 0) {
const trunkTop = Math.min(
spouse ? dblMidY : dec.nameBaseY,
childResult.nameYs[0]
);
const trunkBot = childResult.nameYs[childResult.nameYs.length - 1];
svgParts.push(
/* @__PURE__ */ jsx13(
"line",
{
x1: TRUNK_X,
y1: trunkTop,
x2: TRUNK_X,
y2: trunkBot,
...lineProps
},
nextKey()
)
);
childResult.nameYs.forEach((cny) => {
svgParts.push(
/* @__PURE__ */ jsx13(
"line",
{
x1: TRUNK_X,
y1: cny,
x2: CHILD_TEXT_X - 5,
y2: cny,
...lineProps
},
nextKey()
)
);
});
}
return /* @__PURE__ */ jsx13("div", { className: "af-inheritance-diagram", children: /* @__PURE__ */ jsx13(
"svg",
{
xmlns: "http://www.w3.org/2000/svg",
width: "100%",
viewBox: `0 0 1400 ${svgH}`,
style: { overflow: "visible" },
children: svgParts
}
) });
}
// src/sections/Fallback.tsx
import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
import { jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
function FallbackSectionView({ section }) {
return /* @__PURE__ */ jsxs12("div", { className: "af-fallback", children: [
/* @__PURE__ */ jsxs12("div", { children: [
return /* @__PURE__ */ jsxs13("div", { className: "af-fallback", children: [
/* @__PURE__ */ jsxs13("div", { children: [
"Renderer for section type ",
/* @__PURE__ */ jsx13("strong", { children: section.type }),
/* @__PURE__ */ jsx14("strong", { children: section.type }),
" is not yet implemented in this viewer."
] }),
/* @__PURE__ */ jsx13("pre", { children: JSON.stringify(section.data, null, 2) })
/* @__PURE__ */ jsx14("pre", { children: JSON.stringify(section.data, null, 2) })
] });

@@ -404,19 +800,19 @@ }

// src/index.tsx
import { jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
import { jsx as jsx15, jsxs as jsxs14 } from "react/jsx-runtime";
function AgentRenderer({ data, className }) {
const sections = [...data.sections].sort((a, b) => a.order - b.order);
return /* @__PURE__ */ jsxs13("div", { className: `af-root ${className ?? ""}`, children: [
/* @__PURE__ */ jsxs13("header", { className: "af-header", children: [
/* @__PURE__ */ jsxs13("h1", { className: "af-title", children: [
data.icon && /* @__PURE__ */ jsx14("span", { children: data.icon }),
/* @__PURE__ */ jsx14("span", { children: data.name })
return /* @__PURE__ */ jsxs14("div", { className: `af-root ${className ?? ""}`, children: [
/* @__PURE__ */ jsxs14("header", { className: "af-header", children: [
/* @__PURE__ */ jsxs14("h1", { className: "af-title", children: [
data.icon && /* @__PURE__ */ jsx15("span", { children: data.icon }),
/* @__PURE__ */ jsx15("span", { children: data.name })
] }),
data.description && /* @__PURE__ */ jsx14("p", { className: "af-description", children: data.description })
data.description && /* @__PURE__ */ jsx15("p", { className: "af-description", children: data.description })
] }),
/* @__PURE__ */ jsx14("div", { className: "af-sections", children: sections.map((section) => /* @__PURE__ */ jsxs13("section", { className: "af-section", children: [
/* @__PURE__ */ jsxs13("header", { className: "af-section-header", children: [
section.icon && /* @__PURE__ */ jsx14("span", { children: section.icon }),
/* @__PURE__ */ jsx14("span", { children: section.label })
/* @__PURE__ */ jsx15("div", { className: "af-sections", children: sections.map((section) => /* @__PURE__ */ jsxs14("section", { className: "af-section", children: [
/* @__PURE__ */ jsxs14("header", { className: "af-section-header", children: [
section.icon && /* @__PURE__ */ jsx15("span", { children: section.icon }),
/* @__PURE__ */ jsx15("span", { children: section.label })
] }),
/* @__PURE__ */ jsx14("div", { className: "af-section-body", children: /* @__PURE__ */ jsx14(SectionRenderer, { section }) })
/* @__PURE__ */ jsx15("div", { className: "af-section-body", children: /* @__PURE__ */ jsx15(SectionRenderer, { section }) })
] }, section.id)) })

@@ -428,27 +824,29 @@ ] });

case "kanban":
return /* @__PURE__ */ jsx14(KanbanSectionView, { section });
return /* @__PURE__ */ jsx15(KanbanSectionView, { section });
case "checklist":
return /* @__PURE__ */ jsx14(ChecklistSectionView, { section });
return /* @__PURE__ */ jsx15(ChecklistSectionView, { section });
case "notes":
return /* @__PURE__ */ jsx14(NotesSectionView, { section });
return /* @__PURE__ */ jsx15(NotesSectionView, { section });
case "timeline":
return /* @__PURE__ */ jsx14(TimelineSectionView, { section });
return /* @__PURE__ */ jsx15(TimelineSectionView, { section });
case "table":
return /* @__PURE__ */ jsx14(TableSectionView, { section });
return /* @__PURE__ */ jsx15(TableSectionView, { section });
case "log":
return /* @__PURE__ */ jsx14(LogSectionView, { section });
return /* @__PURE__ */ jsx15(LogSectionView, { section });
case "metrics":
return /* @__PURE__ */ jsx14(MetricsSectionView, { section });
return /* @__PURE__ */ jsx15(MetricsSectionView, { section });
case "diagram":
return /* @__PURE__ */ jsx14(DiagramSectionView, { section });
return /* @__PURE__ */ jsx15(DiagramSectionView, { section });
case "report":
return /* @__PURE__ */ jsx14(ReportSectionView, { section });
return /* @__PURE__ */ jsx15(ReportSectionView, { section });
case "form":
return /* @__PURE__ */ jsx14(FormSectionView, { section });
return /* @__PURE__ */ jsx15(FormSectionView, { section });
case "links":
return /* @__PURE__ */ jsx14(LinksSectionView, { section });
return /* @__PURE__ */ jsx15(LinksSectionView, { section });
case "references":
return /* @__PURE__ */ jsx14(ReferencesSectionView, { section });
return /* @__PURE__ */ jsx15(ReferencesSectionView, { section });
case "inheritance-diagram":
return /* @__PURE__ */ jsx15(InheritanceDiagramSectionView, { section });
default:
return /* @__PURE__ */ jsx14(FallbackSectionView, { section });
return /* @__PURE__ */ jsx15(FallbackSectionView, { section });
}

@@ -455,0 +853,0 @@ }

@@ -681,1 +681,47 @@ :root {

}
/* Inheritance diagram (jp-court: 相続関係説明図).
Uses Japanese 明朝 font stack so legal documents render with the
convention expected by 法務省 / 裁判所. Print target is A3 landscape. */
.af-inheritance-diagram {
background: #fff;
color: #000;
padding: 16px 24px;
overflow-x: auto;
font-family: 'Yu Mincho', 'Hiragino Mincho ProN', 'MS PMincho', serif;
}
.af-inheritance-diagram svg {
display: block;
min-width: 900px;
max-width: 100%;
}
.af-inheritance-diagram svg text {
font-family: 'Yu Mincho', 'Hiragino Mincho ProN', 'MS PMincho', serif;
fill: #000;
}
@media print {
@page {
size: A3 landscape;
margin: 15mm;
}
.af-inheritance-diagram {
padding: 0;
}
}
/* Dark-mode guard: keep the diagram readable by forcing a white canvas
even if the host viewer switches to a dark theme. Legal documents are
always black-on-white when submitted. */
@media (prefers-color-scheme: dark) {
.af-inheritance-diagram {
background: #fff;
color: #000;
}
.af-inheritance-diagram svg text {
fill: #000;
}
}
+1
-1
{
"name": "@agent-format/renderer",
"version": "0.1.1",
"version": "0.1.2",
"description": "React renderer for the agent file format (.agent).",

@@ -5,0 +5,0 @@ "license": "MIT",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display