tenhaw 0.0.0-bootstrap

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.
Files changed (123) hide show
  1. package/LICENSE +21 -0
  2. package/LICENSE-CONTENT +15 -0
  3. package/README.md +52 -0
  4. package/dist/chunk-BKPOQVTM.js +74 -0
  5. package/dist/chunk-ZIEK7SCN.js +73 -0
  6. package/dist/index.d.ts +24 -0
  7. package/dist/index.js +319 -0
  8. package/dist/scaffold.d.ts +14 -0
  9. package/dist/scaffold.js +8 -0
  10. package/instructions/ai-readiness-assessment/AGENTS.md +9 -0
  11. package/instructions/ai-roi-business-case/AGENTS.md +9 -0
  12. package/instructions/ai-usecase-register/AGENTS.md +9 -0
  13. package/instructions/build-ai-adoption-dashboard/AGENTS.md +9 -0
  14. package/instructions/delivery-metrics-dora/AGENTS.md +9 -0
  15. package/instructions/portfolio-tracking/AGENTS.md +9 -0
  16. package/instructions/product-operating-model/AGENTS.md +9 -0
  17. package/package.json +58 -0
  18. package/templates/ai-adoption-dashboard/AGENTS.md +22 -0
  19. package/templates/ai-adoption-dashboard/CLAUDE.md +22 -0
  20. package/templates/ai-adoption-dashboard/LICENSE +21 -0
  21. package/templates/ai-adoption-dashboard/LICENSE-CONTENT +15 -0
  22. package/templates/ai-adoption-dashboard/README.md +56 -0
  23. package/templates/ai-adoption-dashboard/app/globals.css +2 -0
  24. package/templates/ai-adoption-dashboard/app/layout.tsx +4 -0
  25. package/templates/ai-adoption-dashboard/app/page.tsx +14 -0
  26. package/templates/ai-adoption-dashboard/e2e/app.spec.ts +27 -0
  27. package/templates/ai-adoption-dashboard/lib/io.ts +42 -0
  28. package/templates/ai-adoption-dashboard/lib/model.test.ts +4 -0
  29. package/templates/ai-adoption-dashboard/lib/model.ts +9 -0
  30. package/templates/ai-adoption-dashboard/lib/workspace.tsx +49 -0
  31. package/templates/ai-adoption-dashboard/next-env.d.ts +7 -0
  32. package/templates/ai-adoption-dashboard/next.config.mjs +2 -0
  33. package/templates/ai-adoption-dashboard/package.json +31 -0
  34. package/templates/ai-adoption-dashboard/playwright.config.ts +2 -0
  35. package/templates/ai-adoption-dashboard/public/example.csv +5 -0
  36. package/templates/ai-adoption-dashboard/public/example.json +34 -0
  37. package/templates/ai-adoption-dashboard/public/llms.txt +6 -0
  38. package/templates/ai-adoption-dashboard/tsconfig.json +36 -0
  39. package/templates/ai-adoption-dashboard/vitest.config.ts +2 -0
  40. package/templates/ai-readiness-assessment/AGENTS.md +22 -0
  41. package/templates/ai-readiness-assessment/CLAUDE.md +22 -0
  42. package/templates/ai-readiness-assessment/LICENSE +21 -0
  43. package/templates/ai-readiness-assessment/LICENSE-CONTENT +15 -0
  44. package/templates/ai-readiness-assessment/README.md +56 -0
  45. package/templates/ai-readiness-assessment/app/globals.css +2 -0
  46. package/templates/ai-readiness-assessment/app/layout.tsx +4 -0
  47. package/templates/ai-readiness-assessment/app/page.tsx +11 -0
  48. package/templates/ai-readiness-assessment/e2e/app.spec.ts +27 -0
  49. package/templates/ai-readiness-assessment/lib/io.ts +42 -0
  50. package/templates/ai-readiness-assessment/lib/model.test.ts +5 -0
  51. package/templates/ai-readiness-assessment/lib/model.ts +5 -0
  52. package/templates/ai-readiness-assessment/lib/workspace.tsx +49 -0
  53. package/templates/ai-readiness-assessment/next-env.d.ts +7 -0
  54. package/templates/ai-readiness-assessment/next.config.mjs +2 -0
  55. package/templates/ai-readiness-assessment/package.json +32 -0
  56. package/templates/ai-readiness-assessment/playwright.config.ts +2 -0
  57. package/templates/ai-readiness-assessment/public/example.json +154 -0
  58. package/templates/ai-readiness-assessment/public/llms.txt +6 -0
  59. package/templates/ai-readiness-assessment/tsconfig.json +36 -0
  60. package/templates/ai-readiness-assessment/vitest.config.ts +2 -0
  61. package/templates/ai-usecase-register/AGENTS.md +22 -0
  62. package/templates/ai-usecase-register/CLAUDE.md +22 -0
  63. package/templates/ai-usecase-register/LICENSE +21 -0
  64. package/templates/ai-usecase-register/LICENSE-CONTENT +15 -0
  65. package/templates/ai-usecase-register/README.md +56 -0
  66. package/templates/ai-usecase-register/app/globals.css +2 -0
  67. package/templates/ai-usecase-register/app/layout.tsx +4 -0
  68. package/templates/ai-usecase-register/app/page.tsx +16 -0
  69. package/templates/ai-usecase-register/e2e/app.spec.ts +27 -0
  70. package/templates/ai-usecase-register/lib/io.ts +42 -0
  71. package/templates/ai-usecase-register/lib/model.test.ts +7 -0
  72. package/templates/ai-usecase-register/lib/model.ts +9 -0
  73. package/templates/ai-usecase-register/lib/workspace.tsx +49 -0
  74. package/templates/ai-usecase-register/next-env.d.ts +7 -0
  75. package/templates/ai-usecase-register/next.config.mjs +2 -0
  76. package/templates/ai-usecase-register/package.json +33 -0
  77. package/templates/ai-usecase-register/playwright.config.ts +2 -0
  78. package/templates/ai-usecase-register/public/example.json +41 -0
  79. package/templates/ai-usecase-register/public/llms.txt +6 -0
  80. package/templates/ai-usecase-register/tsconfig.json +36 -0
  81. package/templates/ai-usecase-register/vitest.config.ts +2 -0
  82. package/templates/delivery-metrics-dashboard/AGENTS.md +22 -0
  83. package/templates/delivery-metrics-dashboard/CLAUDE.md +22 -0
  84. package/templates/delivery-metrics-dashboard/LICENSE +21 -0
  85. package/templates/delivery-metrics-dashboard/LICENSE-CONTENT +15 -0
  86. package/templates/delivery-metrics-dashboard/README.md +56 -0
  87. package/templates/delivery-metrics-dashboard/app/globals.css +2 -0
  88. package/templates/delivery-metrics-dashboard/app/layout.tsx +4 -0
  89. package/templates/delivery-metrics-dashboard/app/page.tsx +13 -0
  90. package/templates/delivery-metrics-dashboard/e2e/app.spec.ts +27 -0
  91. package/templates/delivery-metrics-dashboard/lib/io.ts +42 -0
  92. package/templates/delivery-metrics-dashboard/lib/model.test.ts +5 -0
  93. package/templates/delivery-metrics-dashboard/lib/model.ts +19 -0
  94. package/templates/delivery-metrics-dashboard/lib/workspace.tsx +49 -0
  95. package/templates/delivery-metrics-dashboard/next-env.d.ts +7 -0
  96. package/templates/delivery-metrics-dashboard/next.config.mjs +2 -0
  97. package/templates/delivery-metrics-dashboard/package.json +32 -0
  98. package/templates/delivery-metrics-dashboard/playwright.config.ts +2 -0
  99. package/templates/delivery-metrics-dashboard/public/example.json +98 -0
  100. package/templates/delivery-metrics-dashboard/public/llms.txt +6 -0
  101. package/templates/delivery-metrics-dashboard/tsconfig.json +36 -0
  102. package/templates/delivery-metrics-dashboard/vitest.config.ts +2 -0
  103. package/templates/product-operating-model/AGENTS.md +22 -0
  104. package/templates/product-operating-model/CLAUDE.md +22 -0
  105. package/templates/product-operating-model/LICENSE +21 -0
  106. package/templates/product-operating-model/LICENSE-CONTENT +15 -0
  107. package/templates/product-operating-model/README.md +56 -0
  108. package/templates/product-operating-model/app/globals.css +2 -0
  109. package/templates/product-operating-model/app/layout.tsx +4 -0
  110. package/templates/product-operating-model/app/page.tsx +11 -0
  111. package/templates/product-operating-model/e2e/app.spec.ts +27 -0
  112. package/templates/product-operating-model/lib/io.ts +42 -0
  113. package/templates/product-operating-model/lib/model.test.ts +6 -0
  114. package/templates/product-operating-model/lib/model.ts +4 -0
  115. package/templates/product-operating-model/lib/workspace.tsx +49 -0
  116. package/templates/product-operating-model/next-env.d.ts +7 -0
  117. package/templates/product-operating-model/next.config.mjs +2 -0
  118. package/templates/product-operating-model/package.json +32 -0
  119. package/templates/product-operating-model/playwright.config.ts +2 -0
  120. package/templates/product-operating-model/public/example.json +119 -0
  121. package/templates/product-operating-model/public/llms.txt +6 -0
  122. package/templates/product-operating-model/tsconfig.json +36 -0
  123. package/templates/product-operating-model/vitest.config.ts +2 -0
@@ -0,0 +1,13 @@
1
+ "use client";
2
+ import { useState } from "react";
3
+ import { scoreDeliveryHealth } from "@tenhaw/delivery-metrics";
4
+ import { calculate, example, samplePeriod, validateEvents } from "../lib/model";
5
+ import { Workspace, Stats, Panel, Table, FileActions, useWorkspace, number, JsonReport } from "../lib/workspace";
6
+ const names:Record<string,string>={deploymentFrequency:"Deployment frequency",changeLeadTime:"Change lead time",changeFailRate:"Change fail rate",failedDeploymentRecoveryTime:"Failed deployment recovery time",deploymentReworkRate:"Deployment rework rate",cycleTime:"Cycle time",throughput:"Throughput",wip:"Work in progress",flowEfficiency:"Flow efficiency",prReviewTime:"PR review time",prSize:"PR size"};
7
+ export default function Page(){const [section,setSection]=useState("Overview");const state=useWorkspace("tenhaw-delivery-v1",example,validateEvents);const ready=state.ready;const [since,setSince]=useState(samplePeriod.since.slice(0,10)),[until,setUntil]=useState(samplePeriod.until.slice(0,10)),[selectedService,setSelectedService]=useState("");const services=[...new Set(state.data.map(event=>event.service))];const service=services.includes(selectedService)?selectedService:services[0];let report:ReturnType<typeof calculate>|null=null,error="";try{report=calculate(state.data,`${since}T00:00:00Z`,`${until}T00:00:00Z`,service);}catch(caught){error=caught instanceof Error?caught.message:"Check event timestamps and the reporting window.";}const health=report?scoreDeliveryHealth(report):null;const selectedEvents=state.data.filter(event=>!service||event.service===service);const completed=selectedEvents.filter(event=>event.type==="work-item"&&event.completedAt&&event.completedAt>=since&&event.completedAt<until).map(event=>({id:event.id,start:event.type==="work-item"?event.startedAt:"",end:event.type==="work-item"?event.completedAt!:""}));const maxHours=Math.max(1,...completed.map(event=>(Date.parse(event.end)-Date.parse(event.start))/3600000));
8
+ return <Workspace ready={ready} title="Delivery metrics" description="Inspect delivery and flow for one service, with sample sizes and missing data made visible." section={section} setSection={setSection} sections={["Overview","DORA metrics","Flow","Events","Methodology"]} notice={state.notice} actions={<FileActions ready={ready} name="delivery-events" data={state.data} reset={state.reset} onError={state.setNotice} onImport={source=>{state.setData(validateEvents(JSON.parse(source)));state.setNotice("Events imported locally. Choose their service and date range.");}}/>}>
9
+ <div className="form-grid"><label className="field">Service<select disabled={!ready} value={service??""} onChange={event=>setSelectedService(event.target.value)}>{services.length?services.map(name=><option key={name}>{name}</option>):<option value="">No services</option>}</select></label><div className="form-grid"><label className="field">Since (inclusive, UTC)<input disabled={!ready} type="date" value={since} onChange={event=>setSince(event.target.value)}/></label><label className="field">Until (exclusive, UTC)<input disabled={!ready} type="date" value={until} onChange={event=>setUntil(event.target.value)}/></label></div></div>
10
+ {error?<p role="alert">{error}</p>:report&&<><Stats items={[{label:"Deployments / day",value:number(report.metrics.deploymentFrequency.value,3),note:`n = ${report.metrics.deploymentFrequency.sampleSize}`},{label:"Change lead time",value:number(report.metrics.changeLeadTime.value),note:"Hours from linked commit to production"},{label:"Change fail rate",value:report.metrics.changeFailRate.value===null?"Unavailable":`${number(report.metrics.changeFailRate.value)}%`,note:"Failed changes / observed deployments"},{label:"Throughput",value:number(report.metrics.throughput.value,2),note:"Items completed / week"}]}/>
11
+ {section==="Events"?<Panel title="Imported events" aside={`${selectedEvents.length} records for this service`}><Table headers={["ID","Type","Timestamp","Service"]} rows={selectedEvents.map(event=>[event.id,event.type,"timestamp" in event?event.timestamp:"startedAt" in event?event.startedAt:event.createdAt,event.service])}/></Panel>:section==="Methodology"?<Panel title="Definitions and limits"><ul className="notes"><li>Five DORA delivery metrics describe one service. These are observations, not a composite score or a ranking between teams.</li><li>Production deployment records need explicit commit links. Tags and branch merges are proxies and are excluded from DORA calculations.</li><li>Failure and recovery require incidents linked to a deployment and an observed restoration timestamp. Unavailable measurements remain null.</li><li>The period is half-open [since, until), using UTC. Import events before the start when needed to link commits or started work.</li><li>Compute collectors locally with your tokens. Import the resulting events JSON here. There are no scheduled hosted collectors.</li></ul><a href="https://dora.dev/guides/dora-metrics/">DORA delivery performance definitions</a><JsonReport value={report}/></Panel>:section==="Flow"?<><Panel title="Cycle time by completed item" aside="Hours, one point per completed item"><svg role="img" aria-label="Cycle time scatter chart showing hours for completed work items" viewBox="0 0 600 220" style={{width:"100%",maxHeight:250}}><line x1="42" y1="10" x2="42" y2="180" stroke="#a8b4c2"/><line x1="42" y1="180" x2="580" y2="180" stroke="#a8b4c2"/>{completed.map((item,i)=>{const hours=(Date.parse(item.end)-Date.parse(item.start))/3600000;return <g key={item.id}><circle cx={70+i*(480/Math.max(1,completed.length-1))} cy={175-hours/maxHours*145} r="5" fill="#ffd400"><title>{item.id}: {number(hours)} hours</title></circle><text x={70+i*(480/Math.max(1,completed.length-1))} y="205" fill="#a8b4c2" textAnchor="middle" fontSize="11">{item.id}</text></g>})}<text x="4" y="20" fill="#a8b4c2" fontSize="11">{number(maxHours)}h</text><text x="20" y="180" fill="#a8b4c2" fontSize="11">0</text></svg>{completed.length===0&&<p className="empty">No completed items in this period.</p>}</Panel><Panel title="Flow observations"><Table headers={["Metric","Value","Unit","Sample size"]} rows={Object.entries(report.metrics).slice(5).map(([key,metric])=>[names[key],number(metric.value,2),metric.unit,metric.sampleSize])}/></Panel></>:<><Panel title={section==="DORA metrics"?"Five DORA delivery metrics":"Delivery performance"} aside="Null means unavailable"><Table headers={["Metric","Value","Unit","n","Caveats"]} rows={Object.entries(report.metrics).slice(0,5).map(([key,metric])=>[names[key],number(metric.value,3),metric.unit,metric.sampleSize,metric.caveats.join(" ")||"Observed events"])} /></Panel><Panel title="Next data improvements"><ul className="notes">{health?.actions.map(action=><li key={action}>{action}</li>)}{report.caveats.map(caveat=><li key={caveat}>{caveat}</li>)}</ul></Panel></>}
12
+ </>}
13
+ </Workspace>;}
@@ -0,0 +1,27 @@
1
+ import { test, expect } from "@playwright/test";
2
+
3
+ test("server-rendered data controls stay disabled before hydration", async ({ browser }) => {
4
+ const context = await browser.newContext({ javaScriptEnabled: false });
5
+ try {
6
+ const page = await context.newPage();
7
+ await page.goto("/");
8
+ await expect(page.locator(".workspace")).toHaveAttribute("data-state", "loading");
9
+ await expect(page.getByRole("button", { name: "Export JSON", exact: true })).toBeDisabled();
10
+ await expect(page.getByRole("button", { name: "Reset to example", exact: true })).toBeDisabled();
11
+ await expect(page.locator('input[type="file"]')).toBeDisabled();
12
+ } finally {
13
+ await context.close();
14
+ }
15
+ });
16
+
17
+ test("restores the local workspace before enabling export", async ({ page }) => {
18
+ await page.goto("/");
19
+ await expect(page.getByRole("heading", { level: 1 })).toBeVisible();
20
+ await expect(page.getByText("Data stays in this browser.", { exact: true })).toBeVisible();
21
+ await expect(page.locator(".workspace")).toHaveAttribute("data-state", "ready");
22
+ const button = page.getByRole("button", { name: "Export JSON", exact: true });
23
+ await expect(button).toBeEnabled();
24
+ const download = page.waitForEvent("download");
25
+ await button.click();
26
+ expect((await download).suggestedFilename()).toMatch(/\.json$/);
27
+ });
@@ -0,0 +1,42 @@
1
+ export function record(value: unknown, path = "input"): Record<string, unknown> {
2
+ if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error(`${path}: expected an object.`);
3
+ return value as Record<string, unknown>;
4
+ }
5
+ export function text(value: unknown, path: string): string {
6
+ if (typeof value !== "string" || !value.trim() || value.length > 2000) throw new Error(`${path}: use text between 1 and 2,000 characters.`);
7
+ return value.trim();
8
+ }
9
+ export function finite(value: unknown, path: string, min = 0, max = 1_000_000_000): number {
10
+ if (value === "" || value === null || value === undefined) throw new Error(`${path}: a number is required.`);
11
+ const result = typeof value === "number" ? value : typeof value === "string" ? Number(value) : NaN;
12
+ if (!Number.isFinite(result) || result < min || result > max) throw new Error(`${path}: use a number between ${min} and ${max}.`);
13
+ return result;
14
+ }
15
+ export function list(value: unknown, path: string): unknown[] {
16
+ if (!Array.isArray(value) || value.length > 10000) throw new Error(`${path}: expected an array of at most 10,000 records.`);
17
+ return value;
18
+ }
19
+
20
+ /** RFC 4180-style parsing; quoted commas, double quotes and embedded newlines supported. */
21
+ export function parseCsv(source: string): Record<string,string>[] {
22
+ const rows:string[][]=[]; let row:string[]=[], field="",quoted=false,closed=false;
23
+ const input=source.replace(/^\uFEFF/,"");
24
+ for(let i=0;i<input.length;i++) {const char=input[i];
25
+ if(quoted) {if(char==='"'&&input[i+1]==='"'){field+='"';i++;}else if(char==='"'){quoted=false;closed=true;}else field+=char;}
26
+ else if(char==='"'){if(field || closed) throw new Error("CSV: unexpected quote.");quoted=true;}
27
+ else if(char===","){row.push(field);field="";closed=false;}
28
+ else if(char==="\n"||char==="\r"){if(char==="\r"&&input[i+1]==="\n")i++;row.push(field);if(row.some(Boolean))rows.push(row);row=[];field="";closed=false;}
29
+ else {if(closed)throw new Error("CSV: unexpected text after a closing quote.");field+=char;}
30
+ }
31
+ if(quoted)throw new Error("CSV: an opening quote is not closed.");
32
+ row.push(field);if(row.some(Boolean))rows.push(row);
33
+ const headers=rows.shift()?.map(header=>header.trim());
34
+ if(!headers?.length || headers.some(header=>!header) || new Set(headers).size!==headers.length)throw new Error("CSV: use unique, non-empty column headers.");
35
+ if(rows.length>10000)throw new Error("CSV: at most 10,000 rows are supported.");
36
+ return rows.map((cells,i)=>{if(cells.length!==headers.length)throw new Error(`CSV row ${i+2}: expected ${headers.length} columns.`);return Object.fromEntries(headers.map((header,j)=>[header,cells[j]]));});
37
+ }
38
+ export function toCsv(rows: Record<string,unknown>[], headers?:string[]): string {
39
+ const columns=headers??Object.keys(rows[0]??{});
40
+ const escape=(value:unknown)=>{let content=value===null||value===undefined?"":String(value);if(/^[\t\r\n ]*[=+@-]/.test(content)&&typeof value!=="number")content="'"+content;return '"'+content.replaceAll('"','""')+'"';};
41
+ return [columns.map(escape).join(","),...rows.map(row=>columns.map(key=>escape(row[key])).join(","))].join("\r\n");
42
+ }
@@ -0,0 +1,5 @@
1
+ import { it,expect } from "vitest";
2
+ import { calculate,example,samplePeriod,validateEvents } from "./model";
3
+ it("reports five DORA observations from linked synthetic production events",()=>{const report=calculate(example,samplePeriod.since,samplePeriod.until);expect(report.metrics.changeFailRate.value).toBeCloseTo(33.333333);expect(report.metrics.failedDeploymentRecoveryTime.value).toBe(1);expect(report.metrics.deploymentReworkRate.value).toBeCloseTo(33.333333);});
4
+ it("does not convert absent data into healthy zero values",()=>{const report=calculate([],samplePeriod.since,samplePeriod.until);expect(report.metrics.changeFailRate.value).toBeNull();});
5
+ it("rejects credential-shaped or invalid event input",()=>{expect(()=>validateEvents([{token:"secret"}])).toThrow();expect(()=>calculate(example,samplePeriod.until,samplePeriod.since)).toThrow();});
@@ -0,0 +1,19 @@
1
+ import { validateInput } from "@tenhaw/core";
2
+ import { computeMetrics, type DeliveryEvent } from "@tenhaw/delivery-metrics";
3
+ import { list } from "./io";
4
+ export const samplePeriod={since:"2026-10-01T00:00:00Z",until:"2026-11-01T00:00:00Z"};
5
+ export const example:DeliveryEvent[]=[
6
+ {id:"c1",type:"commit",service:"Example service",timestamp:"2026-10-05T08:00:00Z"},
7
+ {id:"c2",type:"commit",service:"Example service",timestamp:"2026-10-07T08:00:00Z"},
8
+ {id:"d1",type:"deployment",service:"Example service",timestamp:"2026-10-05T12:00:00Z",environment:"production",commitIds:["c1"],status:"success",rework:false},
9
+ {id:"d2",type:"deployment",service:"Example service",timestamp:"2026-10-07T12:00:00Z",environment:"production",commitIds:["c2"],status:"success",rework:false},
10
+ {id:"i1",type:"incident",service:"Example service",startedAt:"2026-10-07T12:10:00Z",restoredAt:"2026-10-07T13:10:00Z",deploymentId:"d2"},
11
+ {id:"d3",type:"deployment",service:"Example service",timestamp:"2026-10-07T13:10:00Z",environment:"production",commitIds:["c2"],status:"success",rework:true},
12
+ {id:"w1",type:"work-item",service:"Example service",startedAt:"2026-10-01T09:00:00Z",completedAt:"2026-10-04T09:00:00Z",activeMinutes:600},
13
+ {id:"w2",type:"work-item",service:"Example service",startedAt:"2026-10-05T09:00:00Z",completedAt:"2026-10-07T09:00:00Z",activeMinutes:480},
14
+ {id:"w3",type:"work-item",service:"Example service",startedAt:"2026-10-08T09:00:00Z",completedAt:"2026-10-13T09:00:00Z",activeMinutes:900},
15
+ {id:"w4",type:"work-item",service:"Example service",startedAt:"2026-10-25T09:00:00Z"},
16
+ {id:"pr1",type:"pull-request",service:"Example service",createdAt:"2026-10-04T09:00:00Z",firstReviewAt:"2026-10-04T11:00:00Z",mergedAt:"2026-10-05T08:00:00Z",additions:120,deletions:20}
17
+ ];
18
+ export function validateEvents(value:unknown){list(value,"events");return validateInput<DeliveryEvent[]>("delivery-events",value);}
19
+ export function calculate(events:DeliveryEvent[],since:string,until:string,service?:string){return computeMetrics(events,{since,until,service});}
@@ -0,0 +1,49 @@
1
+ "use client";
2
+
3
+ import { useEffect, useState, type ReactNode } from "react";
4
+ import { buildUtmUrl } from "@tenhaw/core";
5
+
6
+ export function useWorkspace<T>(key: string, sample: T, validate: (value: unknown) => T) {
7
+ const [data, setData] = useState<T>(sample);
8
+ const [notice, setNotice] = useState("Synthetic examples. Import your own file to begin.");
9
+ const [ready, setReady] = useState(false);
10
+ useEffect(() => {
11
+ try {
12
+ const saved = localStorage.getItem(key);
13
+ if (saved) { setData(validate(JSON.parse(saved))); setNotice("Restored from this browser."); }
14
+ } catch { setNotice("Saved data could not be read. Synthetic examples loaded."); }
15
+ setReady(true);
16
+ }, [key, validate]);
17
+ useEffect(() => {
18
+ if (!ready) return;
19
+ try { localStorage.setItem(key, JSON.stringify(data)); }
20
+ catch { setNotice("Browser storage is unavailable or full. Export a JSON copy to keep your work."); }
21
+ }, [data, key, ready]);
22
+ function reset() { setData(sample); setNotice("Synthetic examples restored."); }
23
+ function clear() { localStorage.removeItem(key); setNotice("Saved copy removed. Export anything you need before closing this tab."); }
24
+ return { data, setData, notice, setNotice, reset, clear, ready };
25
+ }
26
+
27
+ export function download(name: string, data: unknown, type = "application/json") {
28
+ const body = typeof data === "string" ? data : JSON.stringify(data, null, 2);
29
+ const url = URL.createObjectURL(new Blob([body], { type }));
30
+ const anchor = document.createElement("a"); anchor.href = url; anchor.download = name; anchor.click();
31
+ setTimeout(() => URL.revokeObjectURL(url), 1000);
32
+ }
33
+
34
+ export function Workspace({ title, description, section, setSection, sections, children, actions, notice, ready }: {
35
+ title: string; description: string; section: string; setSection: (section: string) => void;
36
+ sections: string[]; children: ReactNode; actions?: ReactNode; notice: string; ready: boolean;
37
+ }) {
38
+ return <div className="workspace" data-state={ready ? "ready" : "loading"} aria-busy={!ready}><a className="skip" href="#workspace-main">Skip to workspace</a><aside className="sidebar"><div className="brand"><span className="mark" aria-hidden="true">t.</span><span>tenhaw<span className="muted"> / kit</span></span></div><span className="eyebrow">INTERNAL WORKSPACE</span><nav aria-label="Workspace views">{sections.map(item => <button disabled={!ready} key={item} type="button" aria-current={item === section ? "page" : undefined} className={item === section ? "nav active" : "nav"} onClick={() => setSection(item)}>{item}</button>)}</nav><div className="sidebar-note"><span className="dot" /> Local workspace<p>Data stays in this browser.</p><small>No account, shared database or usage tracking.</small></div></aside><main id="workspace-main"><header><div><p className="eyebrow">TENHAW KIT / {section.toUpperCase()}</p><h1>{title}</h1><p className="lede">{description}</p></div></header><div className="toolbar">{actions}</div><p className="notice" role="status">{notice}</p>{children}<footer>{process.env.NEXT_PUBLIC_TENHAW_ATTRIBUTION !== "false" && <span>Built with Tenhaw Kit. <a href={buildUtmUrl({source:"template",medium:"footer",content:title.toLowerCase().replaceAll(" ","-")})}>Get help applying this</a></span>}<span>Imported records stay on this device. Export before clearing browser storage.</span></footer></main></div>;
39
+ }
40
+
41
+ export function FileActions<T>({data, name, onImport, onError, reset, csv, ready}: {ready:boolean;data:T;name:string;onImport:(text:string,extension:string)=>void;onError:(message:string)=>void;reset:()=>void;csv?:string}) {
42
+ return <><label className="button primary">Import {csv !== undefined ? "CSV / JSON" : "JSON"}<input disabled={!ready} type="file" accept={csv !== undefined ? ".json,.csv" : ".json"} onChange={async event => { const file = event.target.files?.[0]; event.target.value=""; if (!file) return; if (file.size > 2_000_000) {onError("Choose a file under 2 MB."); return;} try {onImport(await file.text(), file.name.toLowerCase().endsWith(".csv") ? "csv" : "json");} catch(error) {onError(error instanceof Error ? error.message : "Could not import this file.");} }} /></label><button disabled={!ready} type="button" onClick={()=>download(name+".json",data)}>Export JSON</button>{csv !== undefined && <button disabled={!ready} type="button" onClick={()=>download(name+".csv",csv,"text/csv;charset=utf-8")}>Export CSV</button>}<button disabled={!ready} type="button" className="subtle" onClick={reset}>Reset to example</button></>;
43
+ }
44
+ export function Stats({items}:{items:{label:string;value:ReactNode;note?:string}[]}) { return <div className="stats">{items.map(item=><article key={item.label} className="stat"><span>{item.label}</span><strong>{item.value}</strong>{item.note && <small>{item.note}</small>}</article>)}</div>; }
45
+ export function Panel({title,children,aside}:{title:string;children:ReactNode;aside?:string}) { return <section className="panel"><div className="panel-heading"><h2>{title}</h2>{aside && <small>{aside}</small>}</div>{children}</section>; }
46
+ export function Bar({label,value,max=100,detail}:{label:string;value:number;max?:number;detail?:string}) {return <div className="bar-row"><div><span>{label}</span><strong>{detail ?? `${Math.round(value)}%`}</strong></div><div className="track"><span style={{width:`${Math.min(100,Math.max(0,max > 0 ? value/max*100 : 0))}%`}} /></div></div>;}
47
+ export function Table({headers,rows}:{headers:string[];rows:ReactNode[][]}) {return <div className="table-scroll"><table><thead><tr>{headers.map(header=><th key={header} scope="col">{header}</th>)}</tr></thead><tbody>{rows.map((row,i)=><tr key={i}>{row.map((cell,j)=><td key={j}>{cell}</td>)}</tr>)}</tbody></table>{rows.length===0&&<p className="empty">No records yet.</p>}</div>;}
48
+ export function JsonReport({value}:{value:unknown}) {return <details><summary>Inspect calculation output</summary><pre>{JSON.stringify(value,null,2)}</pre></details>;}
49
+ export const number = (value:number|null, digits=1) => value === null ? "Insufficient data" : value.toLocaleString("en-GB",{maximumFractionDigits:digits});
@@ -0,0 +1,7 @@
1
+ /// <reference types="next" />
2
+ /// <reference types="next/image-types/global" />
3
+ import "./.next/types/routes.d.ts";
4
+ import "./.next/types/root-params.d.ts";
5
+
6
+ // NOTE: This file should not be edited
7
+ // see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
@@ -0,0 +1,2 @@
1
+ /** @type {import('next').NextConfig} */
2
+ export default { output: 'export', trailingSlash: true, transpilePackages: ["@tenhaw/core", "@tenhaw/delivery-metrics"] };
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@tenhaw-template/delivery-metrics-dashboard",
3
+ "version": "0.0.0-bootstrap",
4
+ "private": true,
5
+ "scripts": {
6
+ "dev": "next dev",
7
+ "build": "next build",
8
+ "start": "next start",
9
+ "typecheck": "tsc --noEmit",
10
+ "test": "vitest run",
11
+ "e2e": "playwright test"
12
+ },
13
+ "dependencies": {
14
+ "next": "16.4.5",
15
+ "react": "19.2.4",
16
+ "react-dom": "19.2.4",
17
+ "@tenhaw/core": "0.0.0-bootstrap",
18
+ "@tenhaw/delivery-metrics": "0.0.0-bootstrap"
19
+ },
20
+ "devDependencies": {
21
+ "@types/node": "^22.0.0",
22
+ "@types/react": "^19.0.0",
23
+ "@types/react-dom": "^19.0.0",
24
+ "typescript": "^5.9.0",
25
+ "vitest": "^3.2.0",
26
+ "@playwright/test": "^1.56.0"
27
+ },
28
+ "license": "MIT",
29
+ "author": "Tenhaw (https://tenhaw.com)",
30
+ "homepage": "https://kit.tenhaw.com/templates/delivery-metrics-dashboard/",
31
+ "type": "module"
32
+ }
@@ -0,0 +1,2 @@
1
+ import { defineConfig } from "@playwright/test";
2
+ export default defineConfig({testDir:"./e2e", use:{baseURL:"http://localhost:3100"}, webServer:{command:"pnpm dev --port 3100",url:"http://localhost:3100",reuseExistingServer:!process.env.CI}});
@@ -0,0 +1,98 @@
1
+ [
2
+ {
3
+ "id": "c1",
4
+ "type": "commit",
5
+ "service": "Example service",
6
+ "timestamp": "2026-10-05T08:00:00Z"
7
+ },
8
+ {
9
+ "id": "c2",
10
+ "type": "commit",
11
+ "service": "Example service",
12
+ "timestamp": "2026-10-07T08:00:00Z"
13
+ },
14
+ {
15
+ "id": "d1",
16
+ "type": "deployment",
17
+ "service": "Example service",
18
+ "timestamp": "2026-10-05T12:00:00Z",
19
+ "environment": "production",
20
+ "commitIds": [
21
+ "c1"
22
+ ],
23
+ "status": "success",
24
+ "rework": false
25
+ },
26
+ {
27
+ "id": "d2",
28
+ "type": "deployment",
29
+ "service": "Example service",
30
+ "timestamp": "2026-10-07T12:00:00Z",
31
+ "environment": "production",
32
+ "commitIds": [
33
+ "c2"
34
+ ],
35
+ "status": "success",
36
+ "rework": false
37
+ },
38
+ {
39
+ "id": "i1",
40
+ "type": "incident",
41
+ "service": "Example service",
42
+ "startedAt": "2026-10-07T12:10:00Z",
43
+ "restoredAt": "2026-10-07T13:10:00Z",
44
+ "deploymentId": "d2"
45
+ },
46
+ {
47
+ "id": "d3",
48
+ "type": "deployment",
49
+ "service": "Example service",
50
+ "timestamp": "2026-10-07T13:10:00Z",
51
+ "environment": "production",
52
+ "commitIds": [
53
+ "c2"
54
+ ],
55
+ "status": "success",
56
+ "rework": true
57
+ },
58
+ {
59
+ "id": "w1",
60
+ "type": "work-item",
61
+ "service": "Example service",
62
+ "startedAt": "2026-10-01T09:00:00Z",
63
+ "completedAt": "2026-10-04T09:00:00Z",
64
+ "activeMinutes": 600
65
+ },
66
+ {
67
+ "id": "w2",
68
+ "type": "work-item",
69
+ "service": "Example service",
70
+ "startedAt": "2026-10-05T09:00:00Z",
71
+ "completedAt": "2026-10-07T09:00:00Z",
72
+ "activeMinutes": 480
73
+ },
74
+ {
75
+ "id": "w3",
76
+ "type": "work-item",
77
+ "service": "Example service",
78
+ "startedAt": "2026-10-08T09:00:00Z",
79
+ "completedAt": "2026-10-13T09:00:00Z",
80
+ "activeMinutes": 900
81
+ },
82
+ {
83
+ "id": "w4",
84
+ "type": "work-item",
85
+ "service": "Example service",
86
+ "startedAt": "2026-10-25T09:00:00Z"
87
+ },
88
+ {
89
+ "id": "pr1",
90
+ "type": "pull-request",
91
+ "service": "Example service",
92
+ "createdAt": "2026-10-04T09:00:00Z",
93
+ "firstReviewAt": "2026-10-04T11:00:00Z",
94
+ "mergedAt": "2026-10-05T08:00:00Z",
95
+ "additions": 120,
96
+ "deletions": 20
97
+ }
98
+ ]
@@ -0,0 +1,6 @@
1
+ # Delivery metrics dashboard
2
+
3
+ Browser-local internal tool starter from Tenhaw Kit. Synthetic examples.
4
+
5
+ - [Reference](https://kit.tenhaw.com/templates/delivery-metrics-dashboard)
6
+ - [Source](https://github.com/Tenhaw/tenhaw-kit/tree/main/templates/delivery-metrics-dashboard)
@@ -0,0 +1,36 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "lib": [
5
+ "dom",
6
+ "dom.iterable",
7
+ "esnext"
8
+ ],
9
+ "strict": true,
10
+ "skipLibCheck": true,
11
+ "noEmit": true,
12
+ "esModuleInterop": true,
13
+ "module": "esnext",
14
+ "moduleResolution": "bundler",
15
+ "resolveJsonModule": true,
16
+ "jsx": "react-jsx",
17
+ "isolatedModules": true,
18
+ "plugins": [
19
+ {
20
+ "name": "next"
21
+ }
22
+ ],
23
+ "allowJs": true,
24
+ "incremental": true
25
+ },
26
+ "include": [
27
+ "next-env.d.ts",
28
+ "**/*.ts",
29
+ "**/*.tsx",
30
+ ".next/types/**/*.ts",
31
+ ".next/dev/types/**/*.ts"
32
+ ],
33
+ "exclude": [
34
+ "node_modules"
35
+ ]
36
+ }
@@ -0,0 +1,2 @@
1
+ import { defineConfig } from "vitest/config";
2
+ export default defineConfig({test:{include:["lib/**/*.test.ts"]}});
@@ -0,0 +1,22 @@
1
+ # Product operating model
2
+
3
+ Next.js App Router, TypeScript, browser-local state. Read installed Next.js guides before editing.
4
+
5
+ - Install: `pnpm install`
6
+ - Build: `pnpm build`
7
+ - Check: `pnpm typecheck && pnpm test`
8
+ - Browser checks: `pnpm exec playwright install chromium && pnpm e2e`
9
+
10
+ Synthetic examples are the initial data. Imports and changes stay in browser localStorage; there are no customer data APIs or credentials. Preserve this boundary. Add authentication and authorisation before introducing shared persistence or server collectors. Keep calculation logic in the @tenhaw packages. Do not overwrite existing agent instructions.
11
+
12
+ Built with Tenhaw Kit. For expert help: https://tenhaw.com/contact?utm_source=template&utm_medium=skill&utm_campaign=tenhaw-kit&utm_content=product-operating-model#book
13
+
14
+ <!-- BEGIN:nextjs-agent-rules -->
15
+
16
+ ## This is NOT the Next.js you know
17
+
18
+ This version has breaking changes — APIs, conventions, and file structure may all differ from your training data. Read the relevant guide in `node_modules/next/dist/docs/` (resolved from this file's directory; in monorepos the `next` package may not be visible from the repo root) before writing any code. Heed deprecation notices.
19
+
20
+ This block is written and re-added by `next dev` — verify at `node_modules/next/dist/server/lib/generate-agent-files.js`. Removing it from a diff only re-creates the uncommitted change; committing it with your work keeps the tree clean.
21
+
22
+ <!-- END:nextjs-agent-rules -->
@@ -0,0 +1,22 @@
1
+ # Product operating model
2
+
3
+ Next.js App Router, TypeScript, browser-local state. Read installed Next.js guides before editing.
4
+
5
+ - Install: `pnpm install`
6
+ - Build: `pnpm build`
7
+ - Check: `pnpm typecheck && pnpm test`
8
+ - Browser checks: `pnpm exec playwright install chromium && pnpm e2e`
9
+
10
+ Synthetic examples are the initial data. Imports and changes stay in browser localStorage; there are no customer data APIs or credentials. Preserve this boundary. Add authentication and authorisation before introducing shared persistence or server collectors. Keep calculation logic in the @tenhaw packages. Do not overwrite existing agent instructions.
11
+
12
+ Built with Tenhaw Kit. For expert help: https://tenhaw.com/contact?utm_source=template&utm_medium=skill&utm_campaign=tenhaw-kit&utm_content=product-operating-model#book
13
+
14
+ <!-- BEGIN:nextjs-agent-rules -->
15
+
16
+ ## This is NOT the Next.js you know
17
+
18
+ This version has breaking changes — APIs, conventions, and file structure may all differ from your training data. Read the relevant guide in `node_modules/next/dist/docs/` (resolved from this file's directory; in monorepos the `next` package may not be visible from the repo root) before writing any code. Heed deprecation notices.
19
+
20
+ This block is written and re-added by `next dev` — verify at `node_modules/next/dist/server/lib/generate-agent-files.js`. Removing it from a diff only re-creates the uncommitted change; committing it with your work keeps the tree clean.
21
+
22
+ <!-- END:nextjs-agent-rules -->
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Tenhaw
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,15 @@
1
+ Tenhaw AI Readiness Framework and authored framework content in spec/content
2
+ are licensed under the Creative Commons Attribution 4.0 International licence.
3
+ Copyright (c) 2026 Tenhaw.
4
+
5
+ Licence: https://creativecommons.org/licenses/by/4.0/
6
+ Legal code: https://creativecommons.org/licenses/by/4.0/legalcode.en
7
+
8
+ When sharing or adapting this content, provide appropriate credit, a licence
9
+ link, and an indication of changes. A suitable credit is:
10
+ "Tenhaw AI Readiness Framework, CC BY 4.0, https://tenhaw.com."
11
+
12
+ Numerical results and user-supplied evidence remain the user's material.
13
+ The optional audit promotion can be suppressed independently of applicable
14
+ framework-content credits. Code is MIT; third-party sources retain their own
15
+ rights and are summarised with links rather than relicensed here.
@@ -0,0 +1,56 @@
1
+ # Product operating model
2
+
3
+ A working internal tool starter from Tenhaw Kit. Synthetic examples are included. Your imports and edits stay in browser localStorage.
4
+
5
+ ## When to use
6
+
7
+ Use this when building an internal product operating model. Start locally, inspect the sample model and replace it with your own imported data. Add authenticated shared persistence only when you need collaboration across users.
8
+
9
+ ## Run
10
+
11
+ ```sh
12
+ pnpm install
13
+ pnpm dev
14
+ pnpm build
15
+ pnpm test
16
+ pnpm typecheck
17
+ ```
18
+
19
+ Inside the Tenhaw Kit monorepo, first run the root library build. A scaffolded copy resolves released @tenhaw packages instead of workspace links. Publication must be verified separately; source builds do not prove registry availability.
20
+
21
+ ## Data and calculations
22
+
23
+ JSON matches the opmodel schema: teams, optional okrs, roadmap and interactions. The validated editor rejects broken ownership/dependency links. Editable key-result measurements and now/next/later moves update local state. Mermaid export and an SVG topology view are provided.
24
+
25
+ See `lib/model.ts` for the example and import validation. Calculation rules live in the @tenhaw packages; shared JSON Schemas and golden vectors live in the Tenhaw Kit source repository.
26
+
27
+ Files up to 2 MB are accepted. CSV and delivery-event imports are capped at 10,000 rows; domain schema limits also apply. JSON export preserves the input model. CSV exports protect text cells against spreadsheet formula injection. Browser storage can be unavailable or full; keep an exported JSON backup before clearing storage, changing origin or changing devices.
28
+
29
+ ## Deploy
30
+
31
+ The Next.js build uses static export (`out/`). There is no API endpoint or shared database receiving the imported data. Deploy static output anywhere, including Vercel. The starter contains no credential fields, token collection, scheduled collectors or telemetry.
32
+
33
+ [Deploy to Vercel](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2FTenhaw%2Ftemplate-product-operating-model&project-name=product-operating-model) requires the public satellite repository to have been published. A local build does not verify that external release.
34
+
35
+ ## Extend with authentication and a database
36
+
37
+ Before adding server persistence, remove static export and implement authentication plus authorisation for every read, write, import and export route. Auth.js can supply the session, but checking a session alone does not define who may access each record. Protect production deployments as well as previews.
38
+
39
+ A database is deliberately not included in this browser-local baseline. For collaboration, add Drizzle with an explicit SQLite or PostgreSQL schema and dialect-specific migrations, then write a one-time import from the exported JSON. Setting DATABASE_URL alone does not switch database dialects. Keep credentials server-side and out of NEXT_PUBLIC variables.
40
+
41
+ Run GitHub/Jira collectors locally with your read-only environment tokens and import their output. Do not add hosted collection until access control and credential storage are implemented and tested.
42
+
43
+ ## Check the browser workflow
44
+
45
+ ```sh
46
+ pnpm exec playwright install chromium
47
+ pnpm e2e
48
+ ```
49
+
50
+ The browser test opens the synthetic workspace and verifies JSON export. Unit tests cover meaningful import and calculation boundaries. No live source-system tokens are needed.
51
+
52
+ ## Licence and attribution
53
+
54
+ Code: MIT. The bundled readiness framework content remains CC BY 4.0 where used. Set `NEXT_PUBLIC_TENHAW_ATTRIBUTION=false` before building to remove the optional marketing footer; applicable licence notices remain.
55
+
56
+ Built with Tenhaw Kit. [Get expert help applying this](https://tenhaw.com/contact?utm_source=template&utm_medium=readme&utm_campaign=tenhaw-kit&utm_content=product-operating-model#book).
@@ -0,0 +1,2 @@
1
+ :root{color-scheme:dark;--ink:#0a0d12;--panel:#111821;--line:#293544;--text:#e9eef3;--muted:#a8b4c2;--yellow:#ffd400;--green:#39e58c}*{box-sizing:border-box}body{margin:0;background:var(--ink);color:var(--text);font-family:Arial,Helvetica,sans-serif;font-size:15px;line-height:1.55}a{color:var(--yellow);text-underline-offset:4px}button,input,select,textarea{font:inherit}button,.button{display:inline-flex;align-items:center;justify-content:center;gap:8px;background:var(--panel);color:var(--text);padding:9px 14px;border:1px solid var(--line);border-radius:5px;cursor:pointer;text-decoration:none;font-weight:600}button:hover,.button:hover{border-color:var(--muted)}button:focus-visible,.button:focus-within,input:focus-visible,select:focus-visible,textarea:focus-visible,a:focus-visible{outline:2px solid var(--yellow);outline-offset:4px}.primary{background:var(--yellow);color:var(--ink);border-color:var(--yellow)}.subtle{background:transparent;color:var(--muted)}.button input[type=file]{position:absolute;width:1px;height:1px;opacity:0}.workspace{min-height:100vh;display:grid;grid-template-columns:230px 1fr}.sidebar{border-right:1px solid var(--line);padding:28px 20px;display:flex;flex-direction:column;position:sticky;top:0;height:100vh}.brand{display:flex;gap:10px;align-items:center;font-size:22px;font-weight:700;margin-bottom:52px}.mark{background:var(--yellow);color:var(--ink);width:34px;height:34px;display:grid;place-items:center;font-size:25px;line-height:1}.muted{color:var(--muted)}.eyebrow{font-size:10px;font-weight:700;letter-spacing:.16em;color:var(--muted);margin:0 0 15px}.sidebar nav{display:grid;gap:5px}.nav{justify-content:flex-start;background:none;border-color:transparent;font-size:14px}.nav.active{background:#202a34;color:var(--yellow)}.sidebar-note{margin-top:auto;padding-top:48px;font-size:12px;color:var(--muted)}.sidebar-note p{margin:8px 0}.sidebar-note small{font-size:11px}.dot{display:inline-block;width:6px;height:6px;border-radius:50%;background:var(--green);margin-right:7px}main{min-width:0;max-width:1500px;width:100%;padding:42px 48px}header{display:flex;justify-content:space-between;align-items:flex-start;border-bottom:1px solid var(--line);padding-bottom:26px;margin-bottom:24px}h1{font-size:clamp(27px,3vw,38px);letter-spacing:-.04em;line-height:1.15;margin:0 0 14px}h2{font-size:17px;margin:0;font-weight:600}h3{font-size:15px}.lede{color:var(--muted);max-width:700px;margin:0}.toolbar{display:flex;flex-wrap:wrap;gap:8px;align-items:center}.notice{font-size:12px;color:var(--muted);margin:12px 0 26px;min-height:19px}.stats{display:grid;grid-template-columns:repeat(auto-fit,minmax(160px,1fr));border:1px solid var(--line);margin:0 0 28px;border-radius:6px;overflow:hidden}.stat{padding:20px;border-right:1px solid var(--line);display:flex;flex-direction:column;gap:10px;background:var(--panel)}.stat:last-child{border-right:0}.stat>span{color:var(--muted);font-size:12px}.stat strong{font-size:30px;font-weight:500;letter-spacing:-.04em;line-height:1.2}.stat small{color:var(--muted);font-size:11px}.panel{border:1px solid var(--line);background:var(--panel);padding:24px;border-radius:6px;margin-bottom:22px}.panel-heading{display:flex;align-items:center;justify-content:space-between;gap:20px;margin-bottom:20px}.panel-heading small{color:var(--muted);font-size:11px}.columns{display:grid;grid-template-columns:1fr 1fr;gap:22px}.table-scroll{overflow:auto}table{border-collapse:collapse;width:100%;text-align:left;font-size:13px}th{font-size:10px;letter-spacing:.07em;text-transform:uppercase;color:var(--muted);font-weight:600;padding:0 12px 12px 0}td{padding:13px 12px 13px 0;border-top:1px solid var(--line);vertical-align:top}td:first-child{font-weight:600}tbody tr:hover{background:#18222e}.bar-row{margin:18px 0}.bar-row>div:first-child{display:flex;justify-content:space-between;font-size:12px;margin-bottom:8px}.bar-row strong{font-weight:500;color:var(--muted)}.track{height:7px;background:#263240;border-radius:3px;overflow:hidden}.track>span{height:100%;display:block;background:var(--yellow);border-radius:3px}.tag{display:inline-block;font-size:10px;padding:3px 7px;border:1px solid var(--line);border-radius:3px;color:var(--muted);white-space:nowrap}.tag.good{color:var(--green);border-color:#275944}.tag.warn{color:var(--yellow);border-color:#6c601d}label.field{display:flex;flex-direction:column;gap:6px;font-size:12px;margin-bottom:15px;color:var(--muted)}input:not([type=file]),select,textarea{background:var(--ink);border:1px solid var(--line);padding:9px 11px;border-radius:4px;color:var(--text);min-width:0}textarea{width:100%;min-height:140px;font-family:monospace;font-size:12px}.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:0 20px}.form-grid .wide{grid-column:1/-1}.question{padding:18px 0;border-top:1px solid var(--line)}.question:first-of-type{border-top:0}.question label{display:block}.question-title{font-size:14px;font-weight:600}.question small{display:block;color:var(--muted);margin:6px 0 12px}.question select{width:100%;max-width:600px;margin-bottom:10px}.question input{display:block;width:100%;max-width:600px}details{margin-top:24px;border-top:1px solid var(--line);padding-top:16px}summary{cursor:pointer;color:var(--muted);font-size:12px}pre{white-space:pre-wrap;overflow-wrap:anywhere;font-size:11px;background:var(--ink);padding:18px;border-radius:5px;max-height:500px;overflow:auto}.empty{color:var(--muted);font-size:13px}.notes{font-size:12px;color:var(--muted)}.notes li{margin:8px 0}.matrix{display:grid;grid-template-columns:1fr 1fr;gap:12px}.quadrant{min-height:130px;border:1px solid var(--line);padding:14px}.quadrant h3{color:var(--muted);margin-top:0;font-size:11px}.quadrant p{margin:8px 0;font-size:12px}.score{font-variant-numeric:tabular-nums}.progress{width:100%;accent-color:var(--yellow)}footer{display:flex;flex-wrap:wrap;justify-content:space-between;gap:16px;border-top:1px solid var(--line);margin-top:40px;padding-top:20px;color:var(--muted);font-size:10px}.skip{position:fixed;top:-100px;left:20px;background:var(--yellow);color:var(--ink);padding:10px;z-index:20}.skip:focus{top:10px}@media(max-width:1000px){main{padding:32px 26px}.workspace{grid-template-columns:185px 1fr}.sidebar{padding:24px 12px}.columns{grid-template-columns:1fr}}@media(max-width:700px){.workspace{display:block}.sidebar{height:auto;position:static;border-right:0;border-bottom:1px solid var(--line);padding:16px 20px}.brand{margin-bottom:18px}.sidebar>.eyebrow,.sidebar-note{display:none}.sidebar nav{display:flex;overflow:auto;gap:5px}.nav{font-size:12px;white-space:nowrap;padding:8px 10px}main{padding:28px 20px}.stats{grid-template-columns:1fr 1fr}.stat{padding:16px}.stat strong{font-size:24px}.panel{padding:18px}.form-grid{grid-template-columns:1fr}.toolbar{gap:7px}.toolbar button,.toolbar .button{font-size:12px;padding:8px 10px}}
2
+ @media print{.sidebar,.toolbar,.notice,footer{display:none}.workspace{display:block}main{padding:0;max-width:none}body{background:white;color:#111;color-scheme:light}.panel,.stat{background:white;border-color:#aaa;break-inside:avoid}pre{background:#f4f4f4;color:#111}.muted,.lede,.notes,.stat>span,th{color:#333}.track{background:#ddd}.track>span{background:#666}button,input,select{color:#111;background:white}}
@@ -0,0 +1,4 @@
1
+ import type { Metadata } from "next";
2
+ import "./globals.css";
3
+ export const metadata: Metadata = { title: "Product operating model | Tenhaw Kit", description: "A local-first internal tool starter. Synthetic examples included. Your imported data stays in this browser.", robots: { index: false, follow: false } };
4
+ export default function Layout({children}:{children:React.ReactNode}) { return <html lang="en-GB"><body>{children}</body></html>; }
@@ -0,0 +1,11 @@
1
+ "use client";
2
+ import { useState } from "react";
3
+ import { generateOperatingModel, renderMermaid } from "@tenhaw/opmodel";
4
+ import { example, validateModel, progress } from "../lib/model";
5
+ import { Workspace, Stats, Panel, Table, Bar, FileActions, useWorkspace, number, JsonReport, download } from "../lib/workspace";
6
+ export default function Page(){const [section,setSection]=useState("Overview");const state=useWorkspace("tenhaw-opmodel-v1",example,validateModel);const ready=state.ready;const report=generateOperatingModel(state.data);const [draft,setDraft]=useState("");const teams=report.model.teams;const height=Math.max(240,Math.ceil(teams.length/2)*150+50);const position=(id:string)=>{const index=teams.findIndex(team=>team.id===id);return {x:index%2?390:60,y:45+Math.floor(index/2)*150};};
7
+ function editCurrent(okrId:string,krId:string,value:number){state.setData({...state.data,okrs:(state.data.okrs??[]).map(okr=>okr.id===okrId?{...okr,keyResults:okr.keyResults.map(kr=>kr.id===krId?{...kr,current:value}:kr)}:okr)});}
8
+ return <Workspace ready={ready} title="Product operating model" description="Connect team responsibilities, outcome goals and the next pieces of work. Surface the decisions that still need an owner." section={section} setSection={setSection} sections={["Overview","OKRs","Roadmap","Team topology","Edit model","Methodology"]} notice={state.notice} actions={<><FileActions ready={ready} name="operating-model" data={state.data} reset={state.reset} onError={state.setNotice} onImport={source=>{state.setData(validateModel(JSON.parse(source)));state.setNotice("Model imported into this browser.");}}/><button disabled={!ready} onClick={()=>download("team-topology.mmd",renderMermaid(report),"text/plain")}>Export Mermaid</button></>}>
9
+ <Stats items={[{label:"Teams",value:teams.length,note:`${teams.reduce((sum,team)=>sum+team.size,0)} people in this model`},{label:"Objectives",value:report.model.okrs.length,note:`${report.model.okrs.reduce((sum,okr)=>sum+okr.keyResults.length,0)} key results`},{label:"Roadmap items",value:report.model.roadmap.length},{label:"Review prompts",value:report.checks.length,note:"Design checks, not prescriptions"}]}/>
10
+ {section==="Overview"?<div className="columns"><Panel title="Decisions to review"><Table headers={["Entity","Check","Prompt"]} rows={report.checks.map(check=>[check.entityId,check.code,check.message])}/></Panel><Panel title="Accountability"><Table headers={["Team","Type","Size","Cognitive load"]} rows={teams.map(team=>[team.name,team.type,team.size,team.cognitiveLoad??"Not assessed"])}/></Panel></div>:section==="OKRs"?<>{report.model.okrs.map(okr=><Panel title={okr.objective} aside={teams.find(team=>team.id===okr.teamId)?.name??"No owning team"} key={okr.id}>{okr.keyResults.map(kr=><div className="question" key={kr.id}><Bar label={kr.description} value={progress(kr.baseline,kr.target,kr.current)} detail={`${number(kr.progress*100)}% towards target`}/><div className="form-grid"><label className="field">Current measurement<input disabled={!ready} type="number" step="any" value={kr.current} onChange={event=>editCurrent(okr.id,kr.id,Number(event.target.value))}/></label><p className="notes">Baseline: {kr.baseline}. Target: {kr.target}. Confidence: {Math.round(kr.confidence*100)}% (self-reported).</p></div></div>)}</Panel>)}{report.model.okrs.length===0&&<Panel title="No objectives yet"><p className="notes">Add objectives and key results in Edit model or import JSON.</p></Panel>}</>:section==="Roadmap"?<div className="columns" style={{gridTemplateColumns:"repeat(auto-fit,minmax(220px,1fr))"}}>{(["now","next","later"] as const).map(horizon=><Panel title={horizon[0]!.toUpperCase()+horizon.slice(1)} key={horizon}>{report.model.roadmap.filter(item=>item.horizon===horizon).map(item=><article className="question" key={item.id}><h3>{item.title}</h3><p className="notes">{item.outcome||"Outcome needs definition."}</p><span className="tag">{teams.find(team=>team.id===item.teamId)?.name??"No owning team"}</span><label className="field">Move to<select disabled={!ready} value={item.horizon} onChange={event=>state.setData({...state.data,roadmap:(state.data.roadmap??[]).map(row=>row.id===item.id?{...row,horizon:event.target.value as typeof horizon}:row)})}>{["now","next","later"].map(value=><option key={value}>{value}</option>)}</select></label></article>)}</Panel>)}</div>:section==="Team topology"?<Panel title="Teams and interactions" aside="Team Topologies, no affiliation implied"><svg role="img" aria-label="Team topology diagram. Interaction details also shown in the table below." viewBox={`0 0 700 ${height}`} style={{width:"100%",maxHeight:600}}><defs><marker id="arrow" markerWidth="8" markerHeight="8" refX="7" refY="4" orient="auto"><path d="M0 0L8 4L0 8Z" fill="#a8b4c2"/></marker></defs>{report.model.interactions.map((interaction,i)=>{const from=position(interaction.from),to=position(interaction.to);return <line key={i} x1={from.x+105} y1={from.y+65} x2={to.x+105} y2={to.y} stroke="#a8b4c2" markerEnd="url(#arrow)"/>;})}{teams.map(team=>{const point=position(team.id);return <g key={team.id}><rect x={point.x} y={point.y} width="220" height="65" rx="5" fill="#18222e" stroke={team.type==="platform"?"#ffd400":"#5a6a7c"}/><text x={point.x+12} y={point.y+27} fill="#e9eef3" fontSize="13">{team.name.length>27?team.name.slice(0,25)+"…":team.name}</text><text x={point.x+12} y={point.y+47} fill="#a8b4c2" fontSize="10">{team.type} / {team.size} people</text></g>;})}</svg><Table headers={["From","Interaction","To"]} rows={report.model.interactions.map(item=>[teams.find(team=>team.id===item.from)?.name,item.mode,teams.find(team=>team.id===item.to)?.name])}/></Panel>:section==="Edit model"?<Panel title="Edit structured model"><p className="notes">Copy the current model, edit its JSON, then validate and apply. Invalid input leaves your saved model intact.</p><button disabled={!ready} onClick={()=>setDraft(JSON.stringify(state.data,null,2))}>Load current model</button><label className="field">Model JSON<textarea disabled={!ready} style={{minHeight:400}} value={draft} onChange={event=>setDraft(event.target.value)} spellCheck={false}/></label><button disabled={!ready} className="primary" onClick={()=>{try{state.setData(validateModel(JSON.parse(draft)));state.setNotice("Model validated and saved locally.");}catch(error){state.setNotice(error instanceof Error?error.message:"Invalid model JSON.");}}}>Validate and apply</button></Panel>:<Panel title="Model checks"><p className="notes">The model uses Team Topologies types and interaction modes as a public reference. Checks prompt a conversation about team size, support, ownership and outcomes. They do not prescribe an organisation design.</p><p className="notes">Key result progress = (current - baseline) / (target - baseline). Decreasing targets are supported. The progress bar is capped visually at 0 to 100%; the calculated percentage remains visible.</p><a href="https://teamtopologies.com/key-concepts">Team Topologies key concepts</a><JsonReport value={report}/></Panel>}
11
+ </Workspace>;}
@@ -0,0 +1,27 @@
1
+ import { test, expect } from "@playwright/test";
2
+
3
+ test("server-rendered data controls stay disabled before hydration", async ({ browser }) => {
4
+ const context = await browser.newContext({ javaScriptEnabled: false });
5
+ try {
6
+ const page = await context.newPage();
7
+ await page.goto("/");
8
+ await expect(page.locator(".workspace")).toHaveAttribute("data-state", "loading");
9
+ await expect(page.getByRole("button", { name: "Export JSON", exact: true })).toBeDisabled();
10
+ await expect(page.getByRole("button", { name: "Reset to example", exact: true })).toBeDisabled();
11
+ await expect(page.locator('input[type="file"]')).toBeDisabled();
12
+ } finally {
13
+ await context.close();
14
+ }
15
+ });
16
+
17
+ test("restores the local workspace before enabling export", async ({ page }) => {
18
+ await page.goto("/");
19
+ await expect(page.getByRole("heading", { level: 1 })).toBeVisible();
20
+ await expect(page.getByText("Data stays in this browser.", { exact: true })).toBeVisible();
21
+ await expect(page.locator(".workspace")).toHaveAttribute("data-state", "ready");
22
+ const button = page.getByRole("button", { name: "Export JSON", exact: true });
23
+ await expect(button).toBeEnabled();
24
+ const download = page.waitForEvent("download");
25
+ await button.click();
26
+ expect((await download).suggestedFilename()).toMatch(/\.json$/);
27
+ });