archidocs 1.4.0-beta.2 → 1.4.0-beta.3

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,2 @@
1
+ import{n as e,r as t,t as n}from"./index-Oy0Hpoqy.js";import{codeTile as r,opening as i,sourceLine as a}from"./svg-Cboa7QX_.js";import{c as o,l as s,n as c,s as l,t as u,u as d}from"./teams-N-WbqOXA.js";var f=24,p=72,m=44,h={sync:{dash:null,head:`filled`},async:{dash:null,head:`open`},return:{dash:`6 4`,head:`open`}};function g({bundle:t,view:r,source:l,brokers:h=!1,theme:g=`light`,label:S}){let C=c[g],w=new Map(t.elements.map(e=>[e.id,e])),T=e=>w.get(e)?.name??e,E=e(r,{name:T,brokers:h}),D=u(t),O=a(l,S),k=x(C),A=Math.ceil(Math.max(E.width,k.width,d(r.title,20,700),d(O,12))+48),j=Math.ceil(p+E.height+m);return[...i(A,j,C.ground,_(C.ink)),s(f,34,r.title,{size:20,fill:C.ink,weight:700}),s(f,56,O,{size:12,fill:C.muted}),`<g transform="translate(${f},${p})">`,...E.columns.map(e=>v(C,e.x,E)),...E.activations.map(e=>{let t=E.columns.find(t=>t.id===e.participant).x-n.bar/2+e.depth*n.bar/2;return`<rect x="${o(t)}" y="${o(e.top-6)}" width="${n.bar}" height="${o(e.bottom-e.top+12)}" fill="${C.tint}" stroke="${C.faint}"/>`}),...E.columns.map(e=>y(C,e.id,e.x,e.width,w.get(e.id),D.get(w.get(e.id)?.owner??``))),...E.rows.map(e=>b(C,e,T)),`</g>`,`<g transform="translate(${f},${o(p+E.height)})">`,...k.parts,`</g>`,`</svg>`,``].join(`
2
+ `)}var _=e=>`<marker id="head-filled" viewBox="0 0 10 10" refX="10" refY="5" markerWidth="8" markerHeight="8" orient="auto"><path d="M0,0 L10,5 L0,10 z" fill="${e}"/></marker><marker id="head-open" viewBox="0 0 10 10" refX="10" refY="5" markerWidth="8" markerHeight="8" orient="auto"><path d="M0,0 L10,5 L0,10" fill="none" stroke="${e}" stroke-width="1.5"/></marker>`,v=(e,t,n)=>`<path d="M${o(t)},44 L${o(t)},${o(n.height-10)}" fill="none" stroke="${e.faint}" stroke-dasharray="3 4"/>`;function y(e,t,i,a,c,u){let f=i-a/2,p=c?.name??t,m=c!==void 0&&`external`in c&&c.external,h=u?d(u.code,10,700)+16+4:0;return[`<g>`,`<rect x="${o(f)}" y="0" width="${o(a)}" height="44" fill="${m?e.ground:e.paper}" stroke="${e.ink}" stroke-width="1.5"${m?` stroke-dasharray="6 4"`:``}/>`,s(f+14,27,l(p,n.nameSize,a-20-h,700),{size:n.nameSize,fill:e.ink,weight:700}),...u?[r(e,u,f+a-6,14)]:[],`</g>`].join(``)}function b(e,r,i){let{dash:a,head:c}=h[r.style],l=r.x2>=r.x1?1:-1,u=r.x1+l*14,d=r.x1+l*28,f=l>0?void 0:`end`,p=[t(r,i),r.note].filter(e=>e!==void 0);return[`<path data-step="${r.key}" d="M${o(r.x1)},${o(r.y)} L${o(r.x2)},${o(r.y)}" fill="none" stroke="${e.ink}" stroke-width="1.5"${a?` stroke-dasharray="${a}"`:``} marker-end="url(#head-${c})"/>`,`<circle cx="${o(u)}" cy="${o(r.y)}" r="9" fill="${e.ink}"/>`,s(u,r.y+3.5,r.key,{size:r.key.length>2?8:10,fill:e.paper,anchor:`middle`,weight:700}),s(d,r.y-7,r.label,{size:n.labelSize,fill:e.ink,...f?{anchor:f}:{}}),...p.map((t,i)=>s(d,r.y+16+i*n.lineHeight,t,{size:n.subSize,fill:e.muted,...f?{anchor:f}:{}}))].join(``)}function x(e){let t=[],n=0;for(let[r,i]of[[`Sync call`,`sync`],[`Async`,`async`],[`Return`,`return`]]){let{dash:a,head:o}=h[i];t.push(`<path d="M${n},12 L${n+32},12" fill="none" stroke="${e.ink}" stroke-width="1.5"${a?` stroke-dasharray="${a}"`:``} marker-end="url(#head-${o})"/>`),n+=40,t.push(s(n,16,r,{size:11,fill:e.muted})),n+=d(r,11)+24}return{parts:t,width:n-24}}export{g as renderSequenceSvg};
@@ -0,0 +1,2 @@
1
+ import{c as e,g as t,i as n,l as r,n as i,o as a,r as o,s,t as c,u as l,y as u}from"./teams-N-WbqOXA.js";import{n as d,t as f}from"./font-BEgf3E5J.js";var p=24,m=72,h=44,g=1.5,_=6,v=(e,t)=>t??[e.workspace,e.commit?.slice(0,7)??`uncommitted`,...e.date?[e.date.slice(0,10)]:[]].join(` · `),y=(e,t,n,r)=>[`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${t}" viewBox="0 0 ${e} ${t}" font-family="${d}, sans-serif">`,`<style>${f.map(e=>`@font-face{font-family:"${d}";font-weight:${e.weight};src:url(data:font/ttf;base64,${e.base64}) format("truetype")}`).join(``)}</style>`,`<defs>${r}</defs>`,`<rect width="${e}" height="${t}" fill="${n}"/>`];function b({bundle:t,view:a,layout:o,source:s,theme:u=`light`,label:d}){let f=i[u],g=new Map(t.elements.map(e=>[e.id,e])),_=new Map(t.targets.map(e=>[e.id,e])),b=c(t),C=new Map(o.nodes.map(e=>[e.id,e])),w=new Set(a.nodes.map(e=>e.parent).filter(e=>e!==null)),T=a.title,E=v(s,d),O=N(f,t,a.lens,a.nodes.some(e=>e.instances!==void 0)),k=Math.ceil(Math.max(o.width,O.width,l(T,20,700),l(E,12))+48),A=Math.ceil(m+o.height+p+h),P=e=>e.parent===null?0:1+P(a.nodes.find(t=>t.id===e.parent)),F=a.nodes.map(e=>({n:e,d:P(e)})).sort((e,t)=>e.d-t.d).map(({n:e})=>e),I=a.lens!==void 0&&`team`in a.lens,L=new Map(a.nodes.map(e=>[e.id,e])),R=e=>e.kind===`target`?1+(e.parent===null?0:R(L.get(e.parent))):0,z=e=>{let t=e.parent===null?void 0:L.get(e.parent);return t===void 0?f.ground:t.kind===`target`?f[`target-${n(R(t))}`]:z(t)},B=e=>f[`target-${n(R(e))}`],V=0,H=e=>{let t=C.get(e.id),n=g.get(e.element??e.id),r=e.kind===`target`?_.get(e.id):void 0,i=b.get(n?.owner??r?.owner??``);return w.has(e.id)?j(f,e,t,i,z(e),e.kind===`target`?B(e):void 0,r?.kind):D(f,e,t,n,i,I,`clip-${V++}`)};return[...y(k,A,f.ground,`${x(`arrow`,f.edge)}${a.lens?x(`arrow-faint`,f[`edge-faint`])+x(`arrow-lit`,f.ink):``}${S(f)}`),r(p,34,T,{size:20,fill:f.ink,weight:700}),r(p,56,E,{size:12,fill:f.muted}),`<g transform="translate(${p},${m})">`,...F.filter(e=>w.has(e.id)).map(H),...o.edges.map(e=>M(f,e.points,a.edges.find(t=>t.from===e.from&&t.to===e.to))),...F.filter(e=>!w.has(e.id)).map(H),`</g>`,`<g transform="translate(${p},${e(m+o.height+p)})">`,...O.parts,`</g>`,`</svg>`,``].join(`
2
+ `)}var x=(e,t)=>`<marker id="${e}" viewBox="0 0 10 10" refX="10" refY="5" markerWidth="8" markerHeight="8" orient="auto"><path d="M0,0 L10,5 L0,10 z" fill="${t}"/></marker>`,S=e=>`<pattern id="broker" width="12" height="12" patternUnits="userSpaceOnUse"><rect x="8" width="4" height="12" fill="${e.rule}"/></pattern>`;function C(t,n,r,i,[a,o,s,c]){let l=(t,n,r)=>t?`A${e(t)},${e(t)} 0 0 1 ${e(n)},${e(r)} `:``;return`M${e(t+a)},${e(n)} L${e(t+r-o)},${e(n)} ${l(o,t+r,n+o)}L${e(t+r)},${e(n+i-s)} ${l(s,t+r-s,n+i)}L${e(t+c)},${e(n+i)} ${l(c,t,n+i-c)}L${e(t)},${e(n+a)} ${l(a,t+a,n)}Z`}function w(t,n,i,a){let o=l(n.code,10,700)+16,s=i-o;return[`<rect x="${e(s)}" y="${e(a)}" width="${e(o)}" height="16" fill="${t[`code-bg`]}"/>`,`<rect x="${e(s)}" y="${e(a)}" width="5" height="16" fill="${n.color}"/>`,r(s+10,a+12,n.code,{size:10,fill:t[`code-fg`],weight:700})].join(``)}function T(e,t,n,r,i){let a={frame:e.ink,fill:n,name:e.ink,sub:e.muted,edge:r?.color??e.ink},o=t.mark;return o?o.hit?i?{...a,fill:e.paper,ring:r?.color??e.ink}:o.side===`origin`?{...a,fill:e.herebg,edge:e.ink,ring:e.here}:o.side===`upstream`?{...a,frame:e.up,fill:e.upbg,edge:e.up}:o.side===`downstream`?{...a,frame:e.down,fill:e.downbg,edge:e.down,double:!0}:{...a,frame:e.path,fill:e.pathbg,edge:e.path}:{frame:e.line,fill:e.ground,name:e.faint,sub:e.faint,edge:e.line}:a}function E(t,n,i){let a=n.mark;if(a?.distance===void 0)return[];let o=a.side===`origin`?`ORIGIN`:a.side?`${a.side.toUpperCase()} ${a.distance}`:String(a.distance),s=l(o,10,700)+12,c=i.x+i.width-36-s,u=i.y-10,[d,f,p]=a.side===`origin`?[t.here,t[`on-here`],t.ink]:a.side===`upstream`?[t.up,t.paper,void 0]:a.side===`downstream`?[t.down,t.paper,void 0]:[t.paper,t.ink,t.ink];return[`<rect x="${e(c)}" y="${e(u)}" width="${e(s)}" height="16" fill="${d}"${p?` stroke="${p}" stroke-width="${g}"`:``}/>`,r(c+6,u+12,o,{size:10,fill:f,weight:700})]}function D(t,n,i,o,c,d,f){let{x:p,y:m,width:h,height:v}=i,y=o?.kind===`service`?o.type:void 0,b=n.kind===`system`,x=T(t,n,b?t.tint:t.paper,c,d),S=n.kind===`person`?Math.min(36,v/2):0,D=C(p,m,h,v,n.kind===`person`?[S,S,S,S]:y===`datastore`?[0,0,12,12]:[0,0,0,0]),O=n.external?` stroke-dasharray="6 4"`:``,j=b?2:g,M=c?l(c.code,10,700)+16+8:0,N=n.instances===void 0?void 0:u(n.instances),P=N===void 0?0:a(N)+8,I=p+_+(n.kind===`person`?12:8),L=n.kind===`person`?p+h-16:p+h-10;return[`<g>`,...N===void 0?[]:k(x,p,m,h,v),...x.ring?[`<path d="${C(p-4,m-4,h+8,v+8,S?[S+4,S+4,S+4,S+4]:y===`datastore`?[0,0,16,16]:[0,0,0,0])}" fill="${x.ring}"/>`]:[],`<clipPath id="${f}"><path d="${D}"/></clipPath>`,`<path d="${D}" fill="${x.fill}"/>`,...y===`broker`?[`<path d="${D}" fill="url(#broker)"/>`]:[],`<path d="${D}" fill="none" stroke="${x.frame}" stroke-width="${j}"${O}/>`,...x.double?[`<path d="${C(p+3,m+3,h-6,v-6,[0,0,y===`datastore`?9:0,y===`datastore`?9:0])}" fill="none" stroke="${x.frame}" stroke-width="${g}"/>`]:[],`<rect x="${e(p-1)}" y="${e(m-1)}" width="7" height="${e(v+2)}" fill="${x.edge}" clip-path="url(#${f})"/>`,r(I,m+v/2-4,s(n.name,13,L-I-M-P,700),{size:13,fill:x.name,weight:700}),r(I,m+v/2+13,s(F(n,o),11,L-I),{size:11,fill:x.sub}),...c?[w(t,c,L,m+8)]:[],...N===void 0?[]:[A(t,x,N,L-M,m+8)],...E(t,n,i),...n.mark?.hit&&n.collapsed?[`<rect x="${e(p+h-42)}" y="${e(m+v-18)}" width="10" height="10" fill="${t.ink}" stroke="${t.paper}" stroke-width="2"/>`]:[],`</g>`].join(``)}var O=5;function k(t,n,r,i,a){return[2,1].map(o=>`<rect x="${e(n+o*5)}" y="${e(r+o*5)}" width="${e(i)}" height="${e(a)}" fill="${t.fill}" stroke="${t.frame}" stroke-width="${g}"/>`)}function A(t,n,i,o,s){let c=a(i),l=o-c;return[`<rect x="${e(l)}" y="${e(s)}" width="${e(c)}" height="16" fill="${t.paper}" stroke="${n.frame}" stroke-width="1"/>`,r(l+6,s+12,i,{size:10,fill:n.name,weight:700})].join(``)}function j(t,n,i,a,c,u,d){let{x:f,y:p,width:m,height:h}=i,v=n.kind===`target`,y=n.mark&&!n.mark.hit,b=n.external?t.ink:t.line,x=u??(y?`none`:o(t.container,c)),S=n.external?` stroke-dasharray="6 4"`:``,C=a?l(a.code,10,700)+16+8:0,T=f+(v?12:16);return[`<g>`,`<rect x="${e(f)}" y="${e(p)}" width="${e(m)}" height="${e(h)}" fill="${x}" stroke="${b}" stroke-width="${g}"${S}/>`,...v?[]:[`<rect x="${e(f-g/2)}" y="${e(p-g/2)}" width="${_}" height="${e(h+g)}" fill="${b}"/>`],r(T,p+22,s(`${n.name} · ${d??P(n)}`,13,f+m-10-T-C,700),{size:13,fill:y?t.faint:t.ink,weight:700}),...a?[w(t,a,f+m-10,p+9)]:[],...E(t,n,i),`</g>`].join(``)}function M(t,n,r){let i=n.map((t,n)=>`${n===0?`M`:`L`}${e(t.x)},${e(t.y)}`).join(` `);return r.lit?`<path d="${i}" fill="none" stroke="${t.ink}" stroke-width="2.5" marker-end="url(#arrow-lit)"/>`:r.lit===!1?`<path d="${i}" fill="none" stroke="${t[`edge-faint`]}" stroke-width="${g}" marker-end="url(#arrow-faint)"/>`:`<path d="${i}" fill="none" stroke="${t.edge}" stroke-width="${g}" marker-end="url(#arrow)"/>`}function N(n,i,a,o){let s=[],c=0,u=e=>{s.push(r(c,16,e,{size:11,fill:n.muted})),c+=l(e,11)+24},d=t=>{s.push(`<rect x="${e(c)}" y="4" width="28" height="16" ${t}/>`),c+=36};if(s.push(w(n,{code:`ABC`,color:n.muted},c+l(`ABC`,10,700)+16,4)),c+=l(`ABC`,10,700)+24,u(`Team (stripe and code)`),d(`fill="${n.paper}" stroke="${n.ink}" stroke-width="${g}" stroke-dasharray="6 4"`),u(`External`),s.push(`<rect x="${e(c)}" y="4" width="28" height="16" fill="${n.paper}"/><rect x="${e(c)}" y="4" width="28" height="16" fill="url(#broker)" stroke="${n.ink}" stroke-width="${g}"/>`),c+=36,u(`Broker`),o){for(let t of[2,1,0])s.push(`<rect x="${e(c+t*3)}" y="${e(1+t*3)}" width="22" height="12" fill="${n.paper}" stroke="${n.ink}" stroke-width="${g}"/>`);c+=36,u(`Stacked: scaled (×3 fixed, 2–10 autoscale)`)}return a&&(`impact`in a?(d(`fill="${n.herebg}" stroke="${n.here}" stroke-width="2.5"`),u(`Origin`),d(`fill="${n.up}"`),u(`Upstream`),d(`fill="${n.down}"`),u(`Downstream`)):`team`in a?d(`fill="${n.paper}" stroke="${n.muted}" stroke-width="3"`):d(`fill="${n.pathbg}" stroke="${n.path}" stroke-width="${g}"`),u(`Lens: ${t(i,a)}`)),{parts:s,width:c-24}}var P=e=>({person:`Person`,system:`System`,service:`Service`,component:`Component`,target:`Deployment Target`,deployment:`Deployment`})[e.kind];function F(e,t){let n=e.kind!==`deployment`&&t?.kind===`service`&&t.type!==`app`?{datastore:`Datastore`,broker:`Broker`}[t.type]:P(e),r=t&&`technology`in t?t.technology:null;return[`${e.external?`External `:``}${n}`,...r?[r]:[]].join(` · `)}export{O as STACK_OFFSET,w as codeTile,y as opening,b as renderSvg,v as sourceLine};
@@ -44,11 +44,11 @@
44
44
  });
45
45
  })();
46
46
  </script>
47
- <script type="module" crossorigin src="./assets/index-DmVLe9LK.js"></script>
47
+ <script type="module" crossorigin src="./assets/index-Oy0Hpoqy.js"></script>
48
48
  <link rel="modulepreload" crossorigin href="./assets/rolldown-runtime-pP25SEvz.js">
49
49
  <link rel="modulepreload" crossorigin href="./assets/font-BEgf3E5J.js">
50
50
  <link rel="modulepreload" crossorigin href="./assets/teams-N-WbqOXA.js">
51
- <link rel="stylesheet" crossorigin href="./assets/index-CzXU8F_3.css">
51
+ <link rel="stylesheet" crossorigin href="./assets/index-BL2vQQ6T.css">
52
52
  </head>
53
53
  <body>
54
54
  <div id="root"></div>
@@ -50,8 +50,29 @@ export class YamlFile {
50
50
  return text === "{}\n" ? "" : text;
51
51
  }
52
52
  }
53
+ /** Matches a line that opens a block scalar (`key: |`, `- >-`, …), whose more-indented lines are text, not YAML. */
54
+ const BLOCK_SCALAR = /(^|[:-])\s*[|>][+-]?\d*[+-]?\s*(#.*)?$/;
55
+ /** The file's lines that are YAML structure: no blank lines, comments or block scalar text (such as a Markdown `description: |`). */
56
+ function structuralLines(text) {
57
+ const out = [];
58
+ let blockAt = -1;
59
+ for (const line of text.split("\n")) {
60
+ if (line.trim() === "")
61
+ continue;
62
+ const own = line.length - line.trimStart().length;
63
+ if (blockAt >= 0 && own > blockAt)
64
+ continue;
65
+ blockAt = -1;
66
+ if (line.trim().startsWith("#"))
67
+ continue;
68
+ out.push(line);
69
+ if (BLOCK_SCALAR.test(line))
70
+ blockAt = own;
71
+ }
72
+ return out;
73
+ }
53
74
  function detectStyle(text) {
54
- const lines = text.split("\n").filter((l) => l.trim() !== "" && !l.trim().startsWith("#"));
75
+ const lines = structuralLines(text);
55
76
  let indent = 2;
56
77
  let indentFound = false;
57
78
  let indentSeq = true;
package/guide/SKILL.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: archidocs-authoring
3
- description: Edit the Archidocs architecture Model. Use when bootstrapping a Project from code, adding or changing Services, Relationships, Deployments or Views, or proposing an ADR.
3
+ description: Edit the Archidocs architecture Model. Use when bootstrapping a Project from code, adding or changing Services, Relationships, Deployments or Views, proposing an ADR, or finding and filling documentation gaps.
4
4
  ---
5
5
 
6
6
  # Archidocs authoring
@@ -13,8 +13,8 @@ The CLI commands in this guide, such as `archidocs check`, assume a global insta
13
13
 
14
14
  ## The Model
15
15
 
16
- - **Elements**: Person, System, Service, Component. Nesting is strict: System › Service › Component; a Service may sit outside any System; Persons are top-level. Every Element has `name`, and optionally `description`, `owner`, `tags`, `links`.
17
- - Service adds `type` (`app` by default, `datastore`, `broker`), `technology`, `external`. System adds `external`. Component adds `technology`.
16
+ - **Elements**: Person, System, Service, Component. Nesting is strict: System › Service › Component; a Service may sit outside any System; Persons are top-level. Every Element has `name`, and optionally `description` (Markdown), `owner`, `tags`, `links`, `metadata` (a free-form `key: value` map for facts the Model has no field for, such as `tier: 1`).
17
+ - Service adds `type` (`app` by default, `datastore`, `broker`), `technology`, `external`, `repository`. System adds `external`, `repository`. Component adds `technology`, `repository`. `repository` is the source code URL; use it rather than a `Repository` link.
18
18
  - An External System or Service runs outside the organization and has no declared Components.
19
19
  - **Relationships** sit under their consumer and point `to` the provider it depends on. Edges between higher-level Elements are derived, never declared.
20
20
  - **Ownership**: one Owner Team per Element, defaulting to the Project's `owner`. Set `owner` only when it differs.
@@ -6,7 +6,7 @@ Add one Service with its Components, Relationships and Deployments.
6
6
 
7
7
  1. **Place it.** Find the Project (`get_workspace_info`, `search_elements`) and, if it belongs to one, its System. Confirm the id: a lowercase slug unique in the Project across Elements and Deployment Targets.
8
8
  2. **Service.** `upsert_element(project, kind: "service", id, fields, parent?)`:
9
- - `fields`: `name`, `description`, `technology`, `type` (`app` by default, `datastore`, `broker`), `external`, `tags`, `links`; `owner` only when it differs from the Project's.
9
+ - `fields`: `name`, `description` (Markdown), `technology`, `type` (`app` by default, `datastore`, `broker`), `external`, `repository` (the source code URL), `tags`, `links`, `metadata` (free-form `key: value` facts); `owner` only when it differs from the Project's.
10
10
  - `parent` names the System. A new Element goes into its parent's file; with `file` as well it goes top-level in that file and attaches with `in:`. A top-level Service goes into `file`, else `model.yaml`.
11
11
  - `fields` never sets `relationships`, `components` or `in`; each has its own tool or parameter.
12
12
  3. **Components.** For each, `upsert_element(kind: "component", parent: <service>)`. An External Service has no Components.
@@ -24,6 +24,7 @@ systems:
24
24
  cart:
25
25
  name: Cart
26
26
  technology: Go
27
+ repository: https://github.com/acme/cart
27
28
  components:
28
29
  pricing:
29
30
  name: Pricing
@@ -0,0 +1,87 @@
1
+ # Fill gaps
2
+
3
+ Interview the user about what the Model leaves empty, one Element at a time. You do the legwork before every question: dig the value out of the code the Workspace describes and put it forward with its source, so the user mostly confirms or corrects. Each confirmed answer is written straight away, so stopping halfway still leaves real progress.
4
+
5
+ ## Steps
6
+
7
+ 1. **Check.** Run `check` (or `archidocs check`) and fix its errors first: the gap scan reads the Bundle, which a failing Workspace doesn't build.
8
+ 2. **Gap scan.** Build the Bundle with `archidocs build --bundle-only --out <tmp>` and run the query under Gap query over `<tmp>/workspace.bundle.json`. It prints every gap, grouped by Project and Owner Team. Over MCP alone, walk `list_owned` for each Team from `list_teams` and `get_element` each item, applying the same tests. Show the scan and agree with the user which Projects or Teams to work through.
9
+ 3. **Codebases.** For each Project, find the checkout behind each Service: an existing `repository`, a `links` entry, the Workspace's own repo, or a path the user names. Ask once for any you can't find.
10
+ 4. **Interview**, one round per Element, Services that others call first, then the rest of the Services, then Components. Within a round, ask that Element's gaps in this order: `repository`, API docs, `technology` and version, `description`, Owner, then its Relationships and Deployments. For each round:
11
+ - **Legwork first.** Look where the table under Evidence points before you ask anything. Finding facts is your job; deciding them is the user's.
12
+ - **Ask** the round as numbered questions, each with your proposed value and its source, worded so "yes" accepts it: "`Publishing.csproj:4` targets `Microsoft.AspNetCore.App` 8.0. Set `technology: ASP.NET Core 8`?" With no evidence, say where you looked and ask an open question.
13
+ - **Push** on vague answers until a value fits the field: "it's the payments thing" is not a `description`; ask what it does for whom. Two sources that disagree (two Dockerfiles, two remotes) go to the user as a choice.
14
+ - **Accept** `skip` and `unknown`: record the gap as open and move on.
15
+ - **Write** the round's confirmed answers at once (see Writing), then run `check`. The round is done when every gap of the Element is written, skipped or unknown, and `check` passes.
16
+ 5. **Metadata.** Once per Project, ask whether its Teams record facts the Model has no field for (`tier`, `on-call`, `pci-scope`). If they do, fill them Element by Element in the same way.
17
+ 6. **Decisions.** An answer that is a decision rather than a fact ("it's External because a vendor runs it", "we deploy only to prod on purpose") goes to the user as a proposed ADR, following the `propose-adr` topic.
18
+ 7. **Summary.** End with two lists: what was filled, each with its source, and what is still open, grouped by Owner Team so each list can go to its Team. Then the edit loop's finish: `check`, a branch name, a PR title, and a PR body that carries both lists.
19
+
20
+ ## Writing
21
+
22
+ Write with `upsert_element`, `upsert_relationship` and `upsert_deployment`, passing only the fields you fill; fields not given are left as they are. A list field (`links`, `endpoints`) is set whole, so pass its existing entries with the new one, and `metadata` likewise with its existing keys. Without an MCP server, edit the YAML with your file tools.
23
+
24
+ Sources belong in the summary and the PR body, never in the Model: no evidence fields, no `inferred` tags, no source comments in the YAML.
25
+
26
+ ## What counts as a gap
27
+
28
+ | Where | Field | A gap when |
29
+ | --- | --- | --- |
30
+ | Every Element | `description` | empty |
31
+ | Service, Component | `technology` | empty |
32
+ | Service you run (`type: app`, not `external`) | `repository` | empty |
33
+ | Service you run | Deployments | it has none in any Environment |
34
+ | Service you run that another Element calls | API docs | no `links` label and no Deployment `endpoints` name mentions api, openapi or swagger |
35
+ | Relationship | `description`, `technology` | empty |
36
+ | async Relationship | `channel` | empty |
37
+ | Deployment of a Service you run | `url` | empty |
38
+
39
+ Fields such as `tags`, `links`, `metadata` and `instances` are left out on purpose: they are optional by design, and an empty one says nothing is missing. An Owner is never a gap in the scan, because every Element inherits the Project's; ask about it only when evidence names another Team (a CODEOWNERS line, a team label in a Helm chart).
40
+
41
+ ## Evidence
42
+
43
+ | Gap | Where to look | What to write |
44
+ | --- | --- | --- |
45
+ | `repository` | `git remote get-url origin` in the Service's checkout; the repo's URL plus `/tree/<branch>/<path>` when a monorepo holds several Services | the HTTPS URL, with `git@host:org/repo.git` rewritten to `https://host/org/repo` |
46
+ | `technology` | `package.json` with its lockfile, `*.csproj`, `pom.xml` / `build.gradle`, `go.mod`, `pyproject.toml`, `Gemfile`, the Dockerfile's `FROM` | the language or framework and its major version as pinned, such as `Node.js 22`, `Spring Boot 3.3`, `.NET 8`; for a datastore, the engine and version from compose, Helm values or IaC (`PostgreSQL 16`) |
47
+ | API docs | an OpenAPI or Swagger file (`openapi.yaml`, `swagger.json`), a springdoc / Swashbuckle / FastAPI setup, a route serving `/swagger`, `/docs` or `/openapi.json` | a served spec: a Deployment `endpoints` entry `{name: openapi, url}` per Environment; a spec file in the repo: an Element `links` entry `{label: OpenAPI, url}` pointing at it |
48
+ | Deployments, `url` | Terraform, Bicep, Pulumi, Helm values, Kubernetes ingress hosts, CI deploy jobs, per-Environment config files | Targets and Deployments, following the `deployments` topic |
49
+ | Relationship `technology`, `channel` | HTTP and gRPC clients, database drivers, broker producers and consumers, their topic and queue names | `JSON/HTTPS`, `gRPC`, `SQL`; the topic or queue as `channel` |
50
+ | `description` | a README's first paragraph, the OpenAPI `info.description` | a sentence or two in the user's words; offer the README text as a draft for them to confirm |
51
+
52
+ Versions finer than `technology` carries (a pinned patch version, a runtime image tag) go in `metadata`, keyed by what they are: `node: 22.11.0`. Other facts without a field, such as an API style or a spec version, go there too.
53
+
54
+ ## Gap query
55
+
56
+ Needs `jq`. Prints Markdown: a `##` heading per Project, a `###` heading per Owner Team, and one line per Element, Relationship or Deployment naming its empty fields.
57
+
58
+ ```jq
59
+ . as $b
60
+ | (reduce $b.elements[] as $e ({}; .[$e.id] = $e)) as $by
61
+ | def app: .kind == "service" and .external == false and .type == "app";
62
+ def runs($id): [$b.deployments[] | select(.service == $id)];
63
+ def called($id): [$b.relationships[] | select(.to == $id and $by[.from].kind != "person")] | length > 0;
64
+ def gap($p; $o; $item; $m): select($m | length > 0) | {project: $p, owner: $o, item: $item, missing: $m};
65
+ [ ( $b.elements[] as $e
66
+ | gap($e.id | split(":")[0]; $e.owner; "\($e.kind) \($e.id)";
67
+ [ if $e.description == null then "description" else empty end,
68
+ if ($e.kind == "service" or $e.kind == "component") and $e.technology == null then "technology" else empty end,
69
+ if ($e | app) and $e.repository == null then "repository" else empty end,
70
+ if $e.kind == "service" and $e.external == false and (runs($e.id) | length) == 0 then "deployments" else empty end,
71
+ if ($e | app) and called($e.id)
72
+ and ([$e.links[].label, runs($e.id)[].endpoints[].name] | map(select(test("api|openapi|swagger"; "i"))) | length) == 0
73
+ then "api-docs" else empty end ]) ),
74
+ ( $b.relationships[] as $r
75
+ | gap($r.from | split(":")[0]; $by[$r.from].owner; "relationship \($r.from) -> \($r.to)";
76
+ [ if $r.description == null then "description" else empty end,
77
+ if $r.technology == null then "technology" else empty end,
78
+ if $r.interaction == "async" and $r.channel == null then "channel" else empty end ]) ),
79
+ ( $b.deployments[] as $d
80
+ | select($by[$d.service] | app)
81
+ | gap($d.service | split(":")[0]; $d.owner; "deployment \($d.service) in \($d.environment) on \($d.target)";
82
+ [ if $d.url == null then "url" else empty end ]) ) ]
83
+ | group_by(.project)[]
84
+ | "## \(.[0].project)", (group_by(.owner)[] | "### \(.[0].owner)", (.[] | "- \(.item): \(.missing | join(", "))"))
85
+ ```
86
+
87
+ Save it as `gaps.jq` outside the Workspace and run `jq -r -f gaps.jq <tmp>/workspace.bundle.json`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "archidocs",
3
- "version": "1.4.0-beta.2",
3
+ "version": "1.4.0-beta.3",
4
4
  "description": "Git-native architecture as code: check and bundle a Workspace of Projects.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -381,6 +381,21 @@
381
381
  "$ref": "#/$defs/Link"
382
382
  }
383
383
  },
384
+ "metadata": {
385
+ "type": "object",
386
+ "propertyNames": {
387
+ "type": "string",
388
+ "minLength": 1
389
+ },
390
+ "additionalProperties": {
391
+ "type": [
392
+ "string",
393
+ "number",
394
+ "boolean"
395
+ ]
396
+ },
397
+ "description": "Free-form facts about the Element that the Model has no field for, such as `tier: 1` or `on-call: payments-oncall`. Keys are labels, shown as written; values are strings, numbers or booleans. Nothing in the Model reads them: they are shown in the viewer and returned by the MCP server."
398
+ },
384
399
  "relationships": {
385
400
  "description": "The Relationships this Element is the consumer of: what it depends on. A Relationship is never declared under its provider.",
386
401
  "type": "array",
@@ -500,6 +515,21 @@
500
515
  "$ref": "#/$defs/Link"
501
516
  }
502
517
  },
518
+ "metadata": {
519
+ "type": "object",
520
+ "propertyNames": {
521
+ "type": "string",
522
+ "minLength": 1
523
+ },
524
+ "additionalProperties": {
525
+ "type": [
526
+ "string",
527
+ "number",
528
+ "boolean"
529
+ ]
530
+ },
531
+ "description": "Free-form facts about the Element that the Model has no field for, such as `tier: 1` or `on-call: payments-oncall`. Keys are labels, shown as written; values are strings, numbers or booleans. Nothing in the Model reads them: they are shown in the viewer and returned by the MCP server."
532
+ },
503
533
  "relationships": {
504
534
  "description": "The Relationships this Element is the consumer of: what it depends on. A Relationship is never declared under its provider.",
505
535
  "type": "array",
@@ -511,6 +541,11 @@
511
541
  "description": "`true` for a System run outside the organization, such as a payment provider. Nothing inside an External System can declare Components. Default: `false`.",
512
542
  "type": "boolean"
513
543
  },
544
+ "repository": {
545
+ "type": "string",
546
+ "format": "uri",
547
+ "description": "The full URL of the source code repository the Element is built from. Shown as a link in the viewer."
548
+ },
514
549
  "services": {
515
550
  "description": "The Services in the System, keyed by id.",
516
551
  "type": "object",
@@ -560,6 +595,21 @@
560
595
  "$ref": "#/$defs/Link"
561
596
  }
562
597
  },
598
+ "metadata": {
599
+ "type": "object",
600
+ "propertyNames": {
601
+ "type": "string",
602
+ "minLength": 1
603
+ },
604
+ "additionalProperties": {
605
+ "type": [
606
+ "string",
607
+ "number",
608
+ "boolean"
609
+ ]
610
+ },
611
+ "description": "Free-form facts about the Element that the Model has no field for, such as `tier: 1` or `on-call: payments-oncall`. Keys are labels, shown as written; values are strings, numbers or booleans. Nothing in the Model reads them: they are shown in the viewer and returned by the MCP server."
612
+ },
563
613
  "relationships": {
564
614
  "description": "The Relationships this Element is the consumer of: what it depends on. A Relationship is never declared under its provider.",
565
615
  "type": "array",
@@ -580,6 +630,11 @@
580
630
  "description": "What the Service is built with, such as `Go` or `PostgreSQL`. Shown under its name.",
581
631
  "type": "string"
582
632
  },
633
+ "repository": {
634
+ "type": "string",
635
+ "format": "uri",
636
+ "description": "The full URL of the source code repository the Element is built from. Shown as a link in the viewer."
637
+ },
583
638
  "external": {
584
639
  "description": "`true` for a Service run outside the organization, such as a payment provider's API. An External Service can't declare Components. Default: `false`.",
585
640
  "type": "boolean"
@@ -638,6 +693,21 @@
638
693
  "$ref": "#/$defs/Link"
639
694
  }
640
695
  },
696
+ "metadata": {
697
+ "type": "object",
698
+ "propertyNames": {
699
+ "type": "string",
700
+ "minLength": 1
701
+ },
702
+ "additionalProperties": {
703
+ "type": [
704
+ "string",
705
+ "number",
706
+ "boolean"
707
+ ]
708
+ },
709
+ "description": "Free-form facts about the Element that the Model has no field for, such as `tier: 1` or `on-call: payments-oncall`. Keys are labels, shown as written; values are strings, numbers or booleans. Nothing in the Model reads them: they are shown in the viewer and returned by the MCP server."
710
+ },
641
711
  "relationships": {
642
712
  "description": "The Relationships this Element is the consumer of: what it depends on. A Relationship is never declared under its provider.",
643
713
  "type": "array",
@@ -649,6 +719,11 @@
649
719
  "description": "What the Component is built with, such as `TypeScript module`. Shown under its name.",
650
720
  "type": "string"
651
721
  },
722
+ "repository": {
723
+ "type": "string",
724
+ "format": "uri",
725
+ "description": "The full URL of the source code repository the Element is built from. Shown as a link in the viewer."
726
+ },
652
727
  "in": {
653
728
  "description": "The Service this Component belongs to, as an id in this Project. Required for a Component under the top-level `components` key, and not allowed for one nested under a Service's `components`.",
654
729
  "type": "string",
@@ -1,2 +0,0 @@
1
- import{n as e,r as t,t as n}from"./index-DmVLe9LK.js";import{codeTile as r,opening as i,sourceLine as a}from"./svg-DXIkkkSu.js";import{c as o,l as s,n as c,s as l,t as u,u as d}from"./teams-N-WbqOXA.js";var f=24,p=72,m=44,h={sync:{dash:null,head:`filled`},async:{dash:null,head:`open`},return:{dash:`6 4`,head:`open`}};function g({bundle:t,view:r,source:l,brokers:h=!1,theme:g=`light`,label:S}){let C=c[g],w=new Map(t.elements.map(e=>[e.id,e])),T=e=>w.get(e)?.name??e,E=e(r,{name:T,brokers:h}),D=u(t),O=a(l,S),k=x(C),A=Math.ceil(Math.max(E.width,k.width,d(r.title,20,700),d(O,12))+48),j=Math.ceil(p+E.height+m);return[...i(A,j,C.ground,_(C.ink)),s(f,34,r.title,{size:20,fill:C.ink,weight:700}),s(f,56,O,{size:12,fill:C.muted}),`<g transform="translate(${f},${p})">`,...E.columns.map(e=>v(C,e.x,E)),...E.activations.map(e=>{let t=E.columns.find(t=>t.id===e.participant).x-n.bar/2+e.depth*n.bar/2;return`<rect x="${o(t)}" y="${o(e.top-6)}" width="${n.bar}" height="${o(e.bottom-e.top+12)}" fill="${C.tint}" stroke="${C.faint}"/>`}),...E.columns.map(e=>y(C,e.id,e.x,e.width,w.get(e.id),D.get(w.get(e.id)?.owner??``))),...E.rows.map(e=>b(C,e,T)),`</g>`,`<g transform="translate(${f},${o(p+E.height)})">`,...k.parts,`</g>`,`</svg>`,``].join(`
2
- `)}var _=e=>`<marker id="head-filled" viewBox="0 0 10 10" refX="10" refY="5" markerWidth="8" markerHeight="8" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z" fill="${e}"/></marker><marker id="head-open" viewBox="0 0 10 10" refX="10" refY="5" markerWidth="8" markerHeight="8" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10" fill="none" stroke="${e}" stroke-width="1.5"/></marker>`,v=(e,t,n)=>`<path d="M${o(t)},44 L${o(t)},${o(n.height-10)}" fill="none" stroke="${e.faint}" stroke-dasharray="3 4"/>`;function y(e,t,i,a,c,u){let f=i-a/2,p=c?.name??t,m=c!==void 0&&`external`in c&&c.external,h=u?d(u.code,10,700)+16+4:0;return[`<g>`,`<rect x="${o(f)}" y="0" width="${o(a)}" height="44" fill="${m?e.ground:e.paper}" stroke="${e.ink}" stroke-width="1.5"${m?` stroke-dasharray="6 4"`:``}/>`,s(f+14,27,l(p,n.nameSize,a-20-h,700),{size:n.nameSize,fill:e.ink,weight:700}),...u?[r(e,u,f+a-6,14)]:[],`</g>`].join(``)}function b(e,r,i){let{dash:a,head:c}=h[r.style],l=r.x2>=r.x1?1:-1,u=r.x1+l*14,d=r.x1+l*28,f=l>0?void 0:`end`,p=[t(r,i),r.note].filter(e=>e!==void 0);return[`<path data-step="${r.key}" d="M${o(r.x1)},${o(r.y)} L${o(r.x2)},${o(r.y)}" fill="none" stroke="${e.ink}" stroke-width="1.5"${a?` stroke-dasharray="${a}"`:``} marker-end="url(#head-${c})"/>`,`<circle cx="${o(u)}" cy="${o(r.y)}" r="9" fill="${e.ink}"/>`,s(u,r.y+3.5,r.key,{size:r.key.length>2?8:10,fill:e.paper,anchor:`middle`,weight:700}),s(d,r.y-7,r.label,{size:n.labelSize,fill:e.ink,...f?{anchor:f}:{}}),...p.map((t,i)=>s(d,r.y+16+i*n.lineHeight,t,{size:n.subSize,fill:e.muted,...f?{anchor:f}:{}}))].join(``)}function x(e){let t=[],n=0;for(let[r,i]of[[`Sync call`,`sync`],[`Async`,`async`],[`Return`,`return`]]){let{dash:a,head:o}=h[i];t.push(`<path d="M${n},12 L${n+32},12" fill="none" stroke="${e.ink}" stroke-width="1.5"${a?` stroke-dasharray="${a}"`:``} marker-end="url(#head-${o})"/>`),n+=40,t.push(s(n,16,r,{size:11,fill:e.muted})),n+=d(r,11)+24}return{parts:t,width:n-24}}export{g as renderSequenceSvg};
@@ -1,2 +0,0 @@
1
- import{c as e,g as t,i as n,l as r,n as i,o as a,r as o,s,t as c,u as l,y as u}from"./teams-N-WbqOXA.js";import{n as d,t as f}from"./font-BEgf3E5J.js";var p=24,m=72,h=44,g=1.5,_=6,v=(e,t)=>t??[e.workspace,e.commit?.slice(0,7)??`uncommitted`,...e.date?[e.date.slice(0,10)]:[]].join(` · `),y=(e,t,n,r)=>[`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${t}" viewBox="0 0 ${e} ${t}" font-family="${d}, sans-serif">`,`<style>${f.map(e=>`@font-face{font-family:"${d}";font-weight:${e.weight};src:url(data:font/ttf;base64,${e.base64}) format("truetype")}`).join(``)}</style>`,`<defs>${r}</defs>`,`<rect width="${e}" height="${t}" fill="${n}"/>`];function b({bundle:t,view:a,layout:o,source:s,theme:u=`light`,label:d}){let f=i[u],g=new Map(t.elements.map(e=>[e.id,e])),_=new Map(t.targets.map(e=>[e.id,e])),b=c(t),C=new Map(o.nodes.map(e=>[e.id,e])),w=new Set(a.nodes.map(e=>e.parent).filter(e=>e!==null)),T=a.title,E=v(s,d),O=N(f,t,a.lens,a.nodes.some(e=>e.instances!==void 0)),k=Math.ceil(Math.max(o.width,O.width,l(T,20,700),l(E,12))+48),A=Math.ceil(m+o.height+p+h),P=e=>e.parent===null?0:1+P(a.nodes.find(t=>t.id===e.parent)),F=a.nodes.map(e=>({n:e,d:P(e)})).sort((e,t)=>e.d-t.d).map(({n:e})=>e),I=a.lens!==void 0&&`team`in a.lens,L=new Map(a.nodes.map(e=>[e.id,e])),R=e=>e.kind===`target`?1+(e.parent===null?0:R(L.get(e.parent))):0,z=e=>{let t=e.parent===null?void 0:L.get(e.parent);return t===void 0?f.ground:t.kind===`target`?f[`target-${n(R(t))}`]:z(t)},B=e=>f[`target-${n(R(e))}`],V=0,H=e=>{let t=C.get(e.id),n=g.get(e.element??e.id),r=e.kind===`target`?_.get(e.id):void 0,i=b.get(n?.owner??r?.owner??``);return w.has(e.id)?j(f,e,t,i,z(e),e.kind===`target`?B(e):void 0,r?.kind):D(f,e,t,n,i,I,`clip-${V++}`)};return[...y(k,A,f.ground,`${x(`arrow`,f.edge)}${a.lens?x(`arrow-faint`,f[`edge-faint`])+x(`arrow-lit`,f.ink):``}${S(f)}`),r(p,34,T,{size:20,fill:f.ink,weight:700}),r(p,56,E,{size:12,fill:f.muted}),`<g transform="translate(${p},${m})">`,...F.filter(e=>w.has(e.id)).map(H),...o.edges.map(e=>M(f,e.points,a.edges.find(t=>t.from===e.from&&t.to===e.to))),...F.filter(e=>!w.has(e.id)).map(H),`</g>`,`<g transform="translate(${p},${e(m+o.height+p)})">`,...O.parts,`</g>`,`</svg>`,``].join(`
2
- `)}var x=(e,t)=>`<marker id="${e}" viewBox="0 0 10 10" refX="10" refY="5" markerWidth="8" markerHeight="8" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z" fill="${t}"/></marker>`,S=e=>`<pattern id="broker" width="12" height="12" patternUnits="userSpaceOnUse"><rect x="8" width="4" height="12" fill="${e.rule}"/></pattern>`;function C(t,n,r,i,[a,o,s,c]){let l=(t,n,r)=>t?`A${e(t)},${e(t)} 0 0 1 ${e(n)},${e(r)} `:``;return`M${e(t+a)},${e(n)} L${e(t+r-o)},${e(n)} ${l(o,t+r,n+o)}L${e(t+r)},${e(n+i-s)} ${l(s,t+r-s,n+i)}L${e(t+c)},${e(n+i)} ${l(c,t,n+i-c)}L${e(t)},${e(n+a)} ${l(a,t+a,n)}Z`}function w(t,n,i,a){let o=l(n.code,10,700)+16,s=i-o;return[`<rect x="${e(s)}" y="${e(a)}" width="${e(o)}" height="16" fill="${t[`code-bg`]}"/>`,`<rect x="${e(s)}" y="${e(a)}" width="5" height="16" fill="${n.color}"/>`,r(s+10,a+12,n.code,{size:10,fill:t[`code-fg`],weight:700})].join(``)}function T(e,t,n,r,i){let a={frame:e.ink,fill:n,name:e.ink,sub:e.muted,edge:r?.color??e.ink},o=t.mark;return o?o.hit?i?{...a,fill:e.paper,ring:r?.color??e.ink}:o.side===`origin`?{...a,fill:e.herebg,edge:e.ink,ring:e.here}:o.side===`upstream`?{...a,frame:e.up,fill:e.upbg,edge:e.up}:o.side===`downstream`?{...a,frame:e.down,fill:e.downbg,edge:e.down,double:!0}:{...a,frame:e.path,fill:e.pathbg,edge:e.path}:{frame:e.line,fill:e.ground,name:e.faint,sub:e.faint,edge:e.line}:a}function E(t,n,i){let a=n.mark;if(a?.distance===void 0)return[];let o=a.side===`origin`?`ORIGIN`:a.side?`${a.side.toUpperCase()} ${a.distance}`:String(a.distance),s=l(o,10,700)+12,c=i.x+i.width-36-s,u=i.y-10,[d,f,p]=a.side===`origin`?[t.here,t[`on-here`],t.ink]:a.side===`upstream`?[t.up,t.paper,void 0]:a.side===`downstream`?[t.down,t.paper,void 0]:[t.paper,t.ink,t.ink];return[`<rect x="${e(c)}" y="${e(u)}" width="${e(s)}" height="16" fill="${d}"${p?` stroke="${p}" stroke-width="${g}"`:``}/>`,r(c+6,u+12,o,{size:10,fill:f,weight:700})]}function D(t,n,i,o,c,d,f){let{x:p,y:m,width:h,height:v}=i,y=o?.kind===`service`?o.type:void 0,b=n.kind===`system`,x=T(t,n,b?t.tint:t.paper,c,d),S=n.kind===`person`?Math.min(36,v/2):0,D=C(p,m,h,v,n.kind===`person`?[S,S,S,S]:y===`datastore`?[0,0,12,12]:[0,0,0,0]),O=n.external?` stroke-dasharray="6 4"`:``,j=b?2:g,M=c?l(c.code,10,700)+16+8:0,N=n.instances===void 0?void 0:u(n.instances),P=N===void 0?0:a(N)+8,I=p+_+(n.kind===`person`?12:8),L=n.kind===`person`?p+h-16:p+h-10;return[`<g>`,...N===void 0?[]:k(x,p,m,h,v),...x.ring?[`<path d="${C(p-4,m-4,h+8,v+8,S?[S+4,S+4,S+4,S+4]:y===`datastore`?[0,0,16,16]:[0,0,0,0])}" fill="${x.ring}"/>`]:[],`<clipPath id="${f}"><path d="${D}"/></clipPath>`,`<path d="${D}" fill="${x.fill}"/>`,...y===`broker`?[`<path d="${D}" fill="url(#broker)"/>`]:[],`<path d="${D}" fill="none" stroke="${x.frame}" stroke-width="${j}"${O}/>`,...x.double?[`<path d="${C(p+3,m+3,h-6,v-6,[0,0,y===`datastore`?9:0,y===`datastore`?9:0])}" fill="none" stroke="${x.frame}" stroke-width="${g}"/>`]:[],`<rect x="${e(p-1)}" y="${e(m-1)}" width="7" height="${e(v+2)}" fill="${x.edge}" clip-path="url(#${f})"/>`,r(I,m+v/2-4,s(n.name,13,L-I-M-P,700),{size:13,fill:x.name,weight:700}),r(I,m+v/2+13,s(F(n,o),11,L-I),{size:11,fill:x.sub}),...c?[w(t,c,L,m+8)]:[],...N===void 0?[]:[A(t,x,N,L-M,m+8)],...E(t,n,i),...n.mark?.hit&&n.collapsed?[`<rect x="${e(p+h-42)}" y="${e(m+v-18)}" width="10" height="10" fill="${t.ink}" stroke="${t.paper}" stroke-width="2"/>`]:[],`</g>`].join(``)}var O=5;function k(t,n,r,i,a){return[2,1].map(o=>`<rect x="${e(n+o*5)}" y="${e(r+o*5)}" width="${e(i)}" height="${e(a)}" fill="${t.fill}" stroke="${t.frame}" stroke-width="${g}"/>`)}function A(t,n,i,o,s){let c=a(i),l=o-c;return[`<rect x="${e(l)}" y="${e(s)}" width="${e(c)}" height="16" fill="${t.paper}" stroke="${n.frame}" stroke-width="1"/>`,r(l+6,s+12,i,{size:10,fill:n.name,weight:700})].join(``)}function j(t,n,i,a,c,u,d){let{x:f,y:p,width:m,height:h}=i,v=n.kind===`target`,y=n.mark&&!n.mark.hit,b=n.external?t.ink:t.line,x=u??(y?`none`:o(t.container,c)),S=n.external?` stroke-dasharray="6 4"`:``,C=a?l(a.code,10,700)+16+8:0,T=f+(v?12:16);return[`<g>`,`<rect x="${e(f)}" y="${e(p)}" width="${e(m)}" height="${e(h)}" fill="${x}" stroke="${b}" stroke-width="${g}"${S}/>`,...v?[]:[`<rect x="${e(f-g/2)}" y="${e(p-g/2)}" width="${_}" height="${e(h+g)}" fill="${b}"/>`],r(T,p+22,s(`${n.name} · ${d??P(n)}`,13,f+m-10-T-C,700),{size:13,fill:y?t.faint:t.ink,weight:700}),...a?[w(t,a,f+m-10,p+9)]:[],...E(t,n,i),`</g>`].join(``)}function M(t,n,r){let i=n.map((t,n)=>`${n===0?`M`:`L`}${e(t.x)},${e(t.y)}`).join(` `);return r.lit?`<path d="${i}" fill="none" stroke="${t.ink}" stroke-width="2.5" marker-end="url(#arrow-lit)"/>`:r.lit===!1?`<path d="${i}" fill="none" stroke="${t[`edge-faint`]}" stroke-width="${g}" marker-end="url(#arrow-faint)"/>`:`<path d="${i}" fill="none" stroke="${t.edge}" stroke-width="${g}" marker-end="url(#arrow)"/>`}function N(n,i,a,o){let s=[],c=0,u=e=>{s.push(r(c,16,e,{size:11,fill:n.muted})),c+=l(e,11)+24},d=t=>{s.push(`<rect x="${e(c)}" y="4" width="28" height="16" ${t}/>`),c+=36};if(s.push(w(n,{code:`ABC`,color:n.muted},c+l(`ABC`,10,700)+16,4)),c+=l(`ABC`,10,700)+24,u(`Team (stripe and code)`),d(`fill="${n.paper}" stroke="${n.ink}" stroke-width="${g}" stroke-dasharray="6 4"`),u(`External`),s.push(`<rect x="${e(c)}" y="4" width="28" height="16" fill="${n.paper}"/><rect x="${e(c)}" y="4" width="28" height="16" fill="url(#broker)" stroke="${n.ink}" stroke-width="${g}"/>`),c+=36,u(`Broker`),o){for(let t of[2,1,0])s.push(`<rect x="${e(c+t*3)}" y="${e(1+t*3)}" width="22" height="12" fill="${n.paper}" stroke="${n.ink}" stroke-width="${g}"/>`);c+=36,u(`Stacked: scaled (×3 fixed, 2–10 autoscale)`)}return a&&(`impact`in a?(d(`fill="${n.herebg}" stroke="${n.here}" stroke-width="2.5"`),u(`Origin`),d(`fill="${n.up}"`),u(`Upstream`),d(`fill="${n.down}"`),u(`Downstream`)):`team`in a?d(`fill="${n.paper}" stroke="${n.muted}" stroke-width="3"`):d(`fill="${n.pathbg}" stroke="${n.path}" stroke-width="${g}"`),u(`Lens: ${t(i,a)}`)),{parts:s,width:c-24}}var P=e=>({person:`Person`,system:`System`,service:`Service`,component:`Component`,target:`Deployment Target`,deployment:`Deployment`})[e.kind];function F(e,t){let n=e.kind!==`deployment`&&t?.kind===`service`&&t.type!==`app`?{datastore:`Datastore`,broker:`Broker`}[t.type]:P(e),r=t&&`technology`in t?t.technology:null;return[`${e.external?`External `:``}${n}`,...r?[r]:[]].join(` · `)}export{O as STACK_OFFSET,w as codeTile,y as opening,b as renderSvg,v as sourceLine};