diff --git a/.gitignore b/.gitignore index 79aba67..7cc0f1c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ node_modules/ *.tgz vindaris-graph.json open-in-vindaris.html +strategy-wrapped.html diff --git a/README.md b/README.md index 4e70969..3c9ad18 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,21 @@ Your assistant finds your goals in the tools and files it can already read (Noti No account and no API key. The data stays in `vindaris-graph.json` in your assistant's workspace. +## Strategy Wrapped + +Ask Claude: + +> Run `npx my-strategy-wrapped 2026` + +`my-strategy-wrapped` (and `my-strategy-wrapped-2026`, the same with the year built in) is a small entry package for `vindaris wrapped`: same check, different output: four cards for one LinkedIn post (1080 x 1350 PNG each), in the spirit of a year-in-review. + +1. How much work your assistant read, and against how many goals +2. The share of current work that moved a goal forward +3. Your goal of the year: the share of linked work it took +4. Your strategy type, from The Sharpshooter to The Side-Quest Collector + +The cards show numbers only. Goal titles, board names and your company name appear only with `--named`. `npx vindaris wrapped --demo` shows the cards on a fictional company. + ## Commands ``` @@ -22,6 +37,7 @@ npx vindaris add Add goals, KPIs, projects, tasks and links from JS npx vindaris status What the graph holds so far npx vindaris check [--json] Run the check and print the briefing npx vindaris export Rewrite open-in-vindaris.html and print its link +npx vindaris wrapped Four Strategy Wrapped cards for LinkedIn (--named, --demo) npx vindaris demo Run the check on a fictional company ``` diff --git a/bin/vindaris.js b/bin/vindaris.js index 126cb3b..0a5155d 100644 --- a/bin/vindaris.js +++ b/bin/vindaris.js @@ -9,6 +9,7 @@ import { check } from '../src/check.js'; import { renderBriefing } from '../src/briefing.js'; import { exportLink, exportHtml } from '../src/export.js'; import { demoInput } from '../src/demo.js'; +import { wrappedStats, wrappedCards, wrappedCaption, wrappedHtml } from '../src/wrapped.js'; const ROOT = join(dirname(fileURLToPath(import.meta.url)), '..'); const VERSION = JSON.parse(readFileSync(join(ROOT, 'package.json'), 'utf8')).version; @@ -85,6 +86,7 @@ const HELP = `vindaris ${VERSION}: strategy check for AI agents vindaris status What the graph holds so far. vindaris check [--json] Run the check, print the briefing, write open-in-vindaris.html. vindaris export Rewrite open-in-vindaris.html and print its link. + vindaris wrapped Make four Strategy Wrapped cards for LinkedIn (--named adds titles, --demo uses the fictional company, --year sets the year on the cards). vindaris demo Run the check on a fictional company. vindaris schema Where the Work Graph schema files are. vindaris reset Start over with an empty graph. @@ -140,6 +142,51 @@ switch (cmd) { console.log(flag('json') ? JSON.stringify(r, null, 2) : renderBriefing(r, { openFile: page?.file })); break; } + case 'wrapped': { + const demo = flag('demo'); + let g; + if (demo) { g = emptyGraph(); mergeBatch(g, normalizeInput(demoInput()).batch); } else g = load(); + const again = process.env.VINDARIS_WRAPPED_CMD || `vindaris wrapped${opt('year') ? ` --year ${opt('year')}` : ''}`; + if (!g.nodes.some((n) => n.type === 'GOAL' && !n.ignored)) { + // First run: hand the agent the guide right away, so one sentence from the person is enough. + console.log(readFileSync(join(ROOT, 'src', 'guide.md'), 'utf8')); + if (isTemp(process.cwd()) && !process.env.VINDARIS_GRAPH) { + console.log(`Note: this is a temp folder (${process.cwd()}). cd to the person's project or documents folder before you go on (see "Before you start").`); + } else if (!existsSync(GRAPH)) save(emptyGraph()); + console.log(`\n(For the agent: the person asked for their Strategy Wrapped. The graph has no goals yet. Do steps 1 to 5 above, adding the data with \`${process.env.VINDARIS_PROG || 'vindaris'} add \` from this folder, then run \`${again}\` again to make the four cards. Skip step 6.)`); + break; + } + const r = check(g, { asOf: opt('as-of') }); + const s = wrappedStats(g, r, { year: opt('year') }); + const named = flag('named'); + const caption = wrappedCaption(s); + const file = join(demo ? process.cwd() : dirname(GRAPH), 'strategy-wrapped.html'); + writeFileSync(file, wrappedHtml(wrappedCards(s, { named, demo }), caption, { demo })); + let shown = file; + if (existsSync(OUTPUTS) && dirname(file) !== OUTPUTS) { + try { const copy = join(OUTPUTS, 'strategy-wrapped.html'); copyFileSync(file, copy); shown = copy; } catch { /* keep the local file */ } + } + const page = demo ? null : writeOpenPage(g); + if (flag('json')) { console.log(JSON.stringify({ ...s, type: { id: s.type.id, name: s.type.name, text: s.type.text }, file: shown, caption, openInVindaris: page?.file || null }, null, 2)); break; } + const cov = s.coverage == null ? 'no work read' : `${Math.round(s.coverage * 100)}% of current work traces to a goal`; + console.log(`# My Strategy Wrapped ${s.year}${demo ? ' (fictional demo)' : ''} + +Wrote ${shown}: four cards, 1080 x 1350 each, with a PNG download button per card and the post text. + +1. ${s.counts.currentTasks ? `${s.counts.currentTasks} pieces of work` : `${s.counts.goals} goals`} read (${s.counts.goals} goals, ${s.counts.kpis} KPIs). +2. ${cov}. +3. Goal of the year: ${s.topGoal ? `${s.topGoal.tasks} tasks, ${s.topGoal.done} done` : 'none yet, no task traces to a goal'}. +4. Strategy type: ${s.type.name}. ${s.type.text} + +Cards ${named ? 'show goal titles, board names and the company name' : 'show numbers only: no goal titles, names or company name'}. + +Post text (the person edits it before posting): + +${caption} + +(For the agent: give the person ${shown} and say they can download each card as PNG there and post all four in one LinkedIn post. ${named ? 'The cards show goal titles: remind the person that the post is public.' : `If they want goal titles and the company name on the cards, ask them first, then run \`${again} --named\`: the cards go public.`} Do not paste the SVG or HTML into the chat.${page ? ` End with one line offering ${page.file}, which opens the plan on the Vindaris strategy map.` : ''})`); + break; + } case 'demo': { const g = emptyGraph(); const { batch } = normalizeInput(demoInput()); diff --git a/package.json b/package.json index a9989c0..f2b1716 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,13 @@ { "name": "vindaris", - "version": "0.1.3", + "version": "0.2.0", "description": "Strategy check for AI agents. Your agent links the work in your tools to your goals, and vindaris flags execution risk. Runs locally, no account.", "type": "module", "bin": { "vindaris": "bin/vindaris.js" }, "files": ["bin", "src", "schema", "examples", "README.md", "LICENSE"], "engines": { "node": ">=18" }, "scripts": { "test": "node --test" }, - "keywords": ["strategy", "okr", "goals", "kpi", "execution", "work-graph", "ai-agent", "claude", "mcp", "jira"], + "keywords": ["strategy", "okr", "goals", "kpi", "execution", "work-graph", "ai-agent", "claude", "mcp", "jira", "wrapped", "linkedin"], "homepage": "https://vindaris.com/ai-agents", "repository": { "type": "git", "url": "git+https://github.com/Vindaris/vindaris-cli.git" }, "license": "MIT", diff --git a/packages/my-strategy-wrapped-2026/README.md b/packages/my-strategy-wrapped-2026/README.md new file mode 100644 index 0000000..8e776b4 --- /dev/null +++ b/packages/my-strategy-wrapped-2026/README.md @@ -0,0 +1,23 @@ +# my-strategy-wrapped-2026 + +Your strategy year in four cards, made by your AI assistant. Ask Claude: + +> Run `npx my-strategy-wrapped-2026` + +Claude finds your goals in the tools and files it can already read, links the work in Jira, Linear, Asana, GitHub or monday.com to them, and [vindaris](https://www.npmjs.com/package/vindaris) checks the result. You get `strategy-wrapped.html`: four 1080 x 1350 cards for one LinkedIn post, a PNG download for each, and a post text to start from. + +1. How much work was read, and against how many goals +2. The share of current work that moved a goal forward +3. Your goal of the year: the share of linked work it took +4. Your strategy type + +The cards show numbers only. Goal titles and your company name appear only when you ask (`--named`). No account, no API key; the data stays in `vindaris-graph.json` in your assistant's workspace. + +``` +npx my-strategy-wrapped 2026 Make the cards (prints the guide first if there is no data yet) +npx my-strategy-wrapped 2026 --named The same, with goal titles and the company name +npx my-strategy-wrapped --demo The cards for a fictional company +npx my-strategy-wrapped add Any vindaris command passes through +``` + +`npx my-strategy-wrapped-2026` does the same as `npx my-strategy-wrapped 2026`. Made by [Vindaris](https://vindaris.com/ai-agents). diff --git a/packages/my-strategy-wrapped-2026/bin/my-strategy-wrapped-2026.js b/packages/my-strategy-wrapped-2026/bin/my-strategy-wrapped-2026.js new file mode 100755 index 0000000..ebad767 --- /dev/null +++ b/packages/my-strategy-wrapped-2026/bin/my-strategy-wrapped-2026.js @@ -0,0 +1,10 @@ +#!/usr/bin/env node +// npx my-strategy-wrapped-2026: the same as npx my-strategy-wrapped 2026. +process.env.MY_STRATEGY_WRAPPED_YEAR ||= '2026'; +process.env.MY_STRATEGY_WRAPPED_NAME ||= 'my-strategy-wrapped-2026'; +try { + await import('my-strategy-wrapped/bin/my-strategy-wrapped.js'); +} catch (e) { + if (e.code !== 'ERR_MODULE_NOT_FOUND' || !String(e.message).includes('my-strategy-wrapped')) throw e; + await import('../../my-strategy-wrapped/bin/my-strategy-wrapped.js'); // inside the vindaris-cli repo +} diff --git a/packages/my-strategy-wrapped-2026/package.json b/packages/my-strategy-wrapped-2026/package.json new file mode 100644 index 0000000..664cdbc --- /dev/null +++ b/packages/my-strategy-wrapped-2026/package.json @@ -0,0 +1,15 @@ +{ + "name": "my-strategy-wrapped-2026", + "version": "0.2.0", + "description": "My Strategy Wrapped 2026: four LinkedIn cards on how your work lined up with your goals this year. Your AI agent reads your tools, Vindaris checks the plan. Runs locally, no account.", + "type": "module", + "bin": { "my-strategy-wrapped-2026": "bin/my-strategy-wrapped-2026.js" }, + "files": ["bin", "README.md"], + "engines": { "node": ">=18" }, + "dependencies": { "my-strategy-wrapped": "^0.2.0" }, + "keywords": ["strategy", "wrapped", "linkedin", "okr", "goals", "claude", "ai-agent", "vindaris"], + "homepage": "https://vindaris.com/ai-agents", + "repository": { "type": "git", "url": "git+https://github.com/Vindaris/vindaris-cli.git", "directory": "packages/my-strategy-wrapped-2026" }, + "license": "MIT", + "author": "Vindaris" +} diff --git a/packages/my-strategy-wrapped/README.md b/packages/my-strategy-wrapped/README.md new file mode 100644 index 0000000..3306d08 --- /dev/null +++ b/packages/my-strategy-wrapped/README.md @@ -0,0 +1,23 @@ +# my-strategy-wrapped + +Your strategy year in four cards, made by your AI assistant. Ask Claude: + +> Run `npx my-strategy-wrapped 2026` + +Claude finds your goals in the tools and files it can already read, links the work in Jira, Linear, Asana, GitHub or monday.com to them, and [vindaris](https://www.npmjs.com/package/vindaris) checks the result. You get `strategy-wrapped.html`: four 1080 x 1350 cards for one LinkedIn post, a PNG download for each, and a post text to start from. + +1. How much work was read, and against how many goals +2. The share of current work that moved a goal forward +3. Your goal of the year: the share of linked work it took +4. Your strategy type + +The cards show numbers only. Goal titles and your company name appear only when you ask (`--named`). No account, no API key; the data stays in `vindaris-graph.json` in your assistant's workspace. + +``` +npx my-strategy-wrapped 2026 Make the cards (prints the guide first if there is no data yet) +npx my-strategy-wrapped 2026 --named The same, with goal titles and the company name +npx my-strategy-wrapped --demo The cards for a fictional company +npx my-strategy-wrapped add Any vindaris command passes through +``` + +`npx my-strategy-wrapped-2026` does the same as `npx my-strategy-wrapped 2026`. Made by [Vindaris](https://vindaris.com/ai-agents). diff --git a/packages/my-strategy-wrapped/bin/my-strategy-wrapped.js b/packages/my-strategy-wrapped/bin/my-strategy-wrapped.js new file mode 100755 index 0000000..71ad7d3 --- /dev/null +++ b/packages/my-strategy-wrapped/bin/my-strategy-wrapped.js @@ -0,0 +1,30 @@ +#!/usr/bin/env node +// npx my-strategy-wrapped [year] [options]: the Strategy Wrapped entry to the +// vindaris package. With no command (or only a year) it runs `vindaris wrapped`; +// any other vindaris command passes through (add, status, scan, guide, ...). +import { spawnSync } from 'node:child_process'; +import { createRequire } from 'node:module'; +import { existsSync } from 'node:fs'; +import { join, dirname } from 'node:path'; +import { fileURLToPath } from 'node:url'; + +const here = dirname(fileURLToPath(import.meta.url)); +function vindarisBin() { + try { return createRequire(import.meta.url).resolve('vindaris/bin/vindaris.js'); } catch { /* not installed */ } + const local = join(here, '..', '..', '..', 'bin', 'vindaris.js'); // inside the vindaris-cli repo + if (existsSync(local)) return local; + console.error('my-strategy-wrapped: the vindaris package is missing. Run: npx vindaris wrapped'); + process.exit(1); +} + +const COMMANDS = new Set(['guide', 'init', 'scan', 'add', 'status', 'check', 'export', 'demo', 'schema', 'reset', 'wrapped', 'help', '--help', '-h', 'version', '--version', '-v']); +let args = process.argv.slice(2); +const year = process.env.MY_STRATEGY_WRAPPED_YEAR || (/^\d{4}$/.test(args[0] || '') ? args.shift() : null); +const self = `npx ${process.env.MY_STRATEGY_WRAPPED_NAME || 'my-strategy-wrapped'}${year && !process.env.MY_STRATEGY_WRAPPED_YEAR ? ` ${year}` : ''}`; + +if (!args.length || !COMMANDS.has(args[0])) args = ['wrapped', ...args]; +if (args[0] === 'wrapped' && year && !args.includes('--year')) args.push('--year', year); + +const env = { ...process.env, VINDARIS_WRAPPED_CMD: self, VINDARIS_PROG: `npx ${process.env.MY_STRATEGY_WRAPPED_NAME || 'my-strategy-wrapped'}` }; +const res = spawnSync(process.execPath, [vindarisBin(), ...args], { stdio: 'inherit', env }); +process.exit(res.status ?? 1); diff --git a/packages/my-strategy-wrapped/package.json b/packages/my-strategy-wrapped/package.json new file mode 100644 index 0000000..2f51ff5 --- /dev/null +++ b/packages/my-strategy-wrapped/package.json @@ -0,0 +1,15 @@ +{ + "name": "my-strategy-wrapped", + "version": "0.2.0", + "description": "My Strategy Wrapped: four LinkedIn cards on how your work lined up with your goals this year. Your AI agent reads your tools, Vindaris checks the plan. Runs locally, no account.", + "type": "module", + "bin": { "my-strategy-wrapped": "bin/my-strategy-wrapped.js" }, + "files": ["bin", "README.md"], + "engines": { "node": ">=18" }, + "dependencies": { "vindaris": "^0.2.0" }, + "keywords": ["strategy", "wrapped", "linkedin", "okr", "goals", "claude", "ai-agent", "vindaris"], + "homepage": "https://vindaris.com/ai-agents", + "repository": { "type": "git", "url": "git+https://github.com/Vindaris/vindaris-cli.git", "directory": "packages/my-strategy-wrapped" }, + "license": "MIT", + "author": "Vindaris" +} diff --git a/src/check.js b/src/check.js index 523f374..b14da2d 100644 --- a/src/check.js +++ b/src/check.js @@ -36,7 +36,7 @@ export function isCurrent(task, now) { return last == null || now - last <= RULES.recentDays * DAY; } -function buildIndex(graph) { +export function buildIndex(graph) { const byId = new Map(graph.nodes.map((n) => [n.id, n])); const up = new Map(); // id -> [parent ids] over CONTRIBUTES_TO / ALIGNED_TO const down = new Map(); // id -> [child ids] @@ -51,7 +51,7 @@ function buildIndex(graph) { return { byId, up, down }; } -function reach(start, adj) { +export function reach(start, adj) { const seen = new Set(); const stack = [start]; while (stack.length) { diff --git a/src/guide.md b/src/guide.md index bc4c6c4..253ca74 100644 --- a/src/guide.md +++ b/src/guide.md @@ -111,6 +111,15 @@ Report to the person in plain words: Writing the file sends nothing. When the person clicks the button, the titles in it go to Vindaris; nothing else leaves this conversation. Signing up there connects their tools, and Vindaris runs this check every day with the full engine: it grades every signal, follows Slack, Teams and meeting transcripts, and flags risk to the people who own it. +## Strategy Wrapped: four cards for LinkedIn + +If the person asked for their Strategy Wrapped (for example "Run npx My Strategy Wrapped 2026", which means `npx my-strategy-wrapped 2026`), do steps 1 to 5 the same way, then run `vindaris wrapped` (or `npx my-strategy-wrapped 2026`) instead of `vindaris check`. It writes `strategy-wrapped.html`: four cards (1080 x 1350 each, the 4:5 portrait format LinkedIn shows best), a PNG download button for each, and a post text to start from. In a hosted sandbox a copy also goes to the outputs folder. + +- The cards show numbers only: how much work was read, the share that moved a goal forward, the goal of the year as a share of linked work, and the company's strategy type. +- Goal titles, board names and the company name stay off the cards, because the post is public. Only when the person asks for them, run `vindaris wrapped --named`. +- Give the person the file, tell them to download the four cards and post them together in one LinkedIn post, and show the post text. Do not paste the cards into the chat. +- To show the cards before reading anything, run `vindaris wrapped --demo` (a fictional company, marked as a demo on every card). + ## When you find nothing If no tool, file or memory gives you the goals, ask the person these four questions, one at a time, then write what they answer as goals, KPIs and projects: diff --git a/src/wrapped.js b/src/wrapped.js new file mode 100644 index 0000000..163f547 --- /dev/null +++ b/src/wrapped.js @@ -0,0 +1,352 @@ +// Strategy Wrapped: four shareable cards from the same graph and check. +// Each card is a 1080x1350 SVG (LinkedIn's 4:5 portrait). The page that holds +// them turns each card into a PNG in the browser, so the package needs no +// image library. Goal titles, board names and the company name stay off the +// cards unless the person asks for them (--named): the cards are made to be +// posted in public. + +import { isCurrent, isDone, lastActivity, buildIndex, reach } from './check.js'; + +const DAY = 86400000; +const W = 1080; +const H = 1350; +const FONT = `-apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif`; + +const esc = (s) => String(s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c])); +const plural = (n, one, many = one + 's') => `${n} ${n === 1 ? one : many}`; +const pctNum = (x) => Math.round(x * 100); + +function sourceNames(sources) { + const names = []; + for (const s of sources || []) { + const n = typeof s === 'string' ? s : s.name || s.tool; + if (n && !names.includes(n)) names.push(n); + } + return names; +} + +const joinAnd = (list) => (list.length <= 1 ? list.join('') : `${list.slice(0, -1).join(', ')} and ${list[list.length - 1]}`); + +/** Strategy types, checked in order; the first that fits is the card. */ +export const TYPES = [ + { id: 'visionary', name: 'The Visionary', text: 'Big goals, and most of them still wait for their first piece of work.', + fits: (s) => s.goalsWithoutWork >= Math.max(1, s.counts.goals / 2) }, + { id: 'side-quests', name: 'The Side-Quest Collector', text: 'Plenty got done. A good share of it went somewhere the plan never asked for.', + fits: (s) => s.coverage != null && s.coverage < 0.7 }, + { id: 'one-person-army', name: 'The One-Person Army', text: 'One person holds most of the goals. Everything moves when they do.', + fits: (s) => s.ownerOverload }, + { id: 'gut-feeler', name: 'The Gut Feeler', text: 'Clear goals, few numbers. Progress gets felt more than measured.', + fits: (s) => s.counts.goals > 0 && s.goalsWithoutNumber >= s.counts.goals / 2 }, + { id: 'late-sprinter', name: 'The Late Sprinter', text: 'The numbers trail the calendar. The home stretch has to run faster.', + fits: (s) => s.behindPace > 0 }, + { id: 'sharpshooter', name: 'The Sharpshooter', text: 'Almost every task aims at a goal. Very little effort goes astray.', + fits: (s) => s.coverage != null && s.coverage >= 0.85 && s.risks.high === 0 }, + { id: 'steady-builder', name: 'The Steady Builder', text: 'Work and goals mostly line up, with a few loose ends to tie.', + fits: () => true }, +]; + +/** The numbers the cards show, from the graph and its check result. */ +export function wrappedStats(graph, r, { year } = {}) { + const now = Date.parse(r.asOf); + const { byId, down } = buildIndex(graph); + const goals = graph.nodes.filter((n) => n.type === 'GOAL' && !n.ignored); + const current = graph.nodes.filter((n) => n.type === 'TASK' && isCurrent(n, now)); + + // Busiest goal: the most current tasks below it. + let top = null; + let quietest = null; + let goalsWithoutWork = 0; + for (const g of goals) { + const all = [...reach(g.id, down)].map((id) => byId.get(id)); + if (!all.some((n) => n?.type === 'TASK' || n?.type === 'PROJECT')) goalsWithoutWork++; + const below = all.filter((n) => n?.type === 'TASK'); + const cur = below.filter((x) => isCurrent(x, now)); + if (cur.length && (!top || cur.length > top.tasks)) top = { title: g.title, tasks: cur.length, done: cur.filter(isDone).length }; + const lasts = below.map(lastActivity).filter((x) => x != null); + if (lasts.length) { + const days = Math.floor((now - Math.max(...lasts)) / DAY); + if (!quietest || days > quietest.days) quietest = { title: g.title, days }; + } + } + + const unlinkedFinding = r.findings.find((f) => f.rule === 'work-without-goal'); + const linked = r.coverage == null ? 0 : Math.round(r.coverage * current.length); + const risks = { high: 0, medium: 0, low: 0 }; + for (const f of r.findings) risks[f.severity]++; + + const s = { + year: /^\d{4}$/.test(String(year || '')) ? String(year) : r.asOf.slice(0, 4), + asOf: r.asOf, + company: r.company, + sources: sourceNames(r.sources), + counts: r.counts, + coverage: r.coverage, + linked, + unlinked: current.length - linked, + topBoard: unlinkedFinding?.groups?.[0]?.label || null, + doneTasks: current.filter(isDone).length, + topGoal: top, + topGoalShare: top && linked ? top.tasks / linked : null, + quietGoal: quietest && quietest.days >= 30 ? quietest : null, + goalsWithoutWork, + goalsWithoutNumber: r.findings.filter((f) => f.rule === 'kpi-untracked' && f.subject?.type === 'GOAL').length, + behindPace: r.findings.filter((f) => f.rule === 'kpi-behind-pace').length, + ownerOverload: r.findings.some((f) => f.rule === 'owner-overload' && f.subject?.type === 'PERSON'), + risks, + }; + s.type = TYPES.find((t) => t.fits(s)); + return s; +} + +// ---- SVG helpers ----------------------------------------------------------- + +/** Split text into lines that fit maxWidth at this font size (bold sans estimate). */ +export function wrap(text, size, maxWidth, factor = 0.52) { + const perLine = Math.max(4, Math.floor(maxWidth / (size * factor))); + const lines = []; + let line = ''; + for (const word of String(text).split(/\s+/).filter(Boolean)) { + const next = line ? `${line} ${word}` : word; + if (next.length > perLine && line) { lines.push(line); line = word; } else line = next; + } + if (line) lines.push(line); + return lines; +} + +function text(str, { x = 80, y, size, weight = 700, fill = '#FFFFFF', anchor = 'start', spacing = 0, opacity = 1, family = FONT }) { + return `${esc(str)}`; +} + +/** A wrapped paragraph; returns { svg, bottom } so the next block can follow it. */ +function para(str, { y, size, lineHeight = 1.18, maxWidth = W - 160, maxLines = 4, ...rest }) { + let lines = wrap(str, size, maxWidth, rest.weight && rest.weight < 600 ? 0.48 : 0.52); + if (lines.length > maxLines) { lines = lines.slice(0, maxLines); lines[maxLines - 1] = lines[maxLines - 1].replace(/\s*\S*$/, '') + '...'; } + const svg = lines.map((l, i) => text(l, { y: y + i * size * lineHeight, size, ...rest })).join('\n'); + return { svg, bottom: y + (lines.length - 1) * size * lineHeight }; +} + +/** Font size so a big figure fits the card width. */ +const bigSize = (str, max = 300) => Math.min(max, Math.floor((W - 160) / (String(str).length * 0.62))); + +function frame(i, s, { from, to, angle = 135, shapes, body, ink = '#FFFFFF', demo }) { + const id = `g${i}`; + const rad = (angle * Math.PI) / 180; + const x2 = (0.5 + Math.cos(rad) / 2).toFixed(3); + const y2 = (0.5 + Math.sin(rad) / 2).toFixed(3); + const x1 = (1 - x2).toFixed(3); + const y1 = (1 - y2).toFixed(3); + return ` + + +${shapes} +${text(`MY STRATEGY WRAPPED ${s.year}`, { y: 120, size: 32, weight: 800, fill: ink, spacing: 5 })} +${text(`${i}/4`, { x: W - 80, y: 120, size: 32, weight: 700, fill: ink, anchor: 'end', opacity: 0.7 })} +${demo ? text('DEMO, FICTIONAL COMPANY', { y: 170, size: 24, weight: 700, fill: ink, spacing: 3, opacity: 0.75 }) : ''} +${body} +${text('vindaris', { y: H - 80, size: 46, weight: 800, fill: ink, spacing: -1 })} +${text('npx my-strategy-wrapped', { x: W - 80, y: H - 84, size: 28, weight: 600, fill: ink, anchor: 'end', opacity: 0.8, family: 'Menlo, Consolas, monospace' })} +`; +} + +// ---- The four cards ------------------------------------------------------------ + +function cardVolume(s, o) { + const c = s.counts; + const hasTasks = c.currentTasks > 0; + const big = String(hasTasks ? c.currentTasks : c.goals); + const size = bigSize(big, 340); + const label = o.named && s.company ? `At ${s.company}, this year we read` : 'This year we read'; + const lp = para(label, { y: 330, size: 50, weight: 600, maxLines: 2 }); + let body = lp.svg; + const top = lp.bottom + 70; + body += text(big, { y: top + size * 0.78, size, weight: 900, spacing: -8 }); + let y = top + size * 0.78 + 90; + body += text(hasTasks ? 'pieces of work' : (c.goals === 1 ? 'goal on the plan' : 'goals on the plan'), { y, size: 72, weight: 800 }); + const sub = hasTasks + ? `and checked each one against ${plural(c.goals, 'goal')} and ${plural(c.kpis, 'KPI')}.` + : `with ${plural(c.kpis, 'KPI')} to show progress.`; + const p = para(sub, { y: y + 90, size: 44, weight: 500, maxLines: 3, maxWidth: 760 }); + body += p.svg; + if (s.sources.length) body += para(`Read from ${joinAnd(s.sources.slice(0, 4))}`, { y: p.bottom + 110, size: 34, weight: 600, opacity: 0.85, maxLines: 2 }).svg; + const shapes = ` + +`; + return frame(1, s, { from: '#FF8C00', to: '#E0245E', shapes, body, demo: o.demo }); +} + +function cardCoverage(s, o) { + const shapes = ` + +`; + let body; + if (s.coverage == null) { + const big = String(s.counts.kpis); + const size = bigSize(big, 340); + body = text('Numbers on the plan', { y: 330, size: 50, weight: 600 }); + body += text(big, { y: 400 + size * 0.78, size, weight: 900, fill: '#FF8C00', spacing: -8 }); + body += para(s.counts.kpis === 1 ? 'KPI to show progress' : 'KPIs to show progress', { y: 400 + size * 0.78 + 90, size: 72, weight: 800, maxLines: 2 }).svg; + body += para('No work tool was read, so the work itself is still unchecked.', { y: 1000, size: 40, weight: 500, maxLines: 3, opacity: 0.85 }).svg; + } else { + const big = `${pctNum(s.coverage)}%`; + const size = bigSize(big, 330); + body = text('Of all current work', { y: 330, size: 50, weight: 600 }); + body += text(big, { y: 400 + size * 0.78, size, weight: 900, fill: '#FF8C00', spacing: -8 }); + let y = 400 + size * 0.78 + 95; + const p = para('moved a goal forward', { y, size: 72, weight: 800, maxLines: 2 }); + body += p.svg; + y = p.bottom + 100; + const sub = s.unlinked + ? `${plural(s.unlinked, 'task')} served no goal at all.${o.named && s.topBoard ? ` Most of them sat in ${s.topBoard}.` : ''}` + : 'Every current task traced to a goal.'; + body += para(sub, { y, size: 44, weight: 500, maxLines: 3, maxWidth: 760 }).svg; + } + return frame(2, s, { from: '#003153', to: '#001A2E', angle: 90, shapes, body, demo: o.demo }); +} + +function cardTopGoal(s, o) { + const shapes = ` + +`; + let body = text('Your goal of the year', { y: 330, size: 50, weight: 600 }); + const t = s.topGoal; + let y; + if (!t) { + body += text('Still open', { y: 520, size: 140, weight: 900, spacing: -4 }); + body += para('No task traced to a goal yet. Link the work, and one goal will take the lead.', { y: 660, size: 44, weight: 500, maxLines: 3 }).svg; + return frame(3, s, { from: '#5B2EFF', to: '#00A6C8', shapes, body, demo: o.demo }); + } + if (o.named) { + const p = para(`"${t.title}"`, { y: 470, size: 84, weight: 900, maxLines: 4, lineHeight: 1.08, spacing: -1 }); + body += p.svg; + y = p.bottom + 110; + } else if (s.topGoalShare != null) { + const big = `${pctNum(s.topGoalShare)}%`; + const size = bigSize(big, 300); + body += text(big, { y: 400 + size * 0.78, size, weight: 900, spacing: -8 }); + const p = para('of linked work went to one goal', { y: 400 + size * 0.78 + 90, size: 56, weight: 800, maxLines: 2 }); + body += p.svg; + y = p.bottom + 100; + } + const p = para(`${plural(t.tasks, 'task')} behind it, ${t.done} of them done.`, { y, size: 44, weight: 500, maxLines: 2, maxWidth: 820 }); + body += p.svg; + if (s.quietGoal && s.quietGoal.title !== t.title) { + body += para(`Another goal waited ${s.quietGoal.days} days for its next task.`, { y: p.bottom + 70, size: 44, weight: 500, maxLines: 2, maxWidth: 820, opacity: 0.85 }).svg; + } + return frame(3, s, { from: '#5B2EFF', to: '#00A6C8', shapes, body, demo: o.demo }); +} + +function cardType(s, o) { + const shapes = ` + +`; + let body = text('Our strategy type', { y: 330, size: 50, weight: 600 }); + const name = para(s.type.name, { y: 700, size: 104, weight: 900, maxLines: 3, lineHeight: 1.04, spacing: -2, maxWidth: W - 160 }); + body += name.svg; + const d = para(s.type.text, { y: name.bottom + 100, size: 44, weight: 500, maxLines: 3, opacity: 0.92 }); + body += d.svg; + const pills = [`${plural(s.risks.high, 'high risk')}`, `${plural(s.risks.medium, 'medium risk')}`]; + let x = 80; + const py = d.bottom + 80; + for (const label of pills) { + const w = Math.round(label.length * 34 * 0.56 + 64); + body += ``; + body += text(label, { x: x + w / 2, y: py + 46, size: 34, weight: 700, anchor: 'middle' }); + x += w + 24; + } + return frame(4, s, { from: '#1A1033', to: '#3A0F3A', angle: 120, shapes, body, demo: o.demo }); +} + +/** The four card SVGs, in posting order. */ +export function wrappedCards(s, { named = false, demo = false } = {}) { + const o = { named, demo }; + return [cardVolume(s, o), cardCoverage(s, o), cardTopGoal(s, o), cardType(s, o)]; +} + +/** A short post to go with the cards. The person edits it before posting. */ +export function wrappedCaption(s) { + const lines = [`My Strategy Wrapped ${s.year}.`, '']; + if (s.coverage != null) lines.push(`${pctNum(s.coverage)}% of our current work moved a goal forward, across ${plural(s.counts.currentTasks, 'task')} and ${plural(s.counts.goals, 'goal')}.`); + else lines.push(`${plural(s.counts.goals, 'goal')} and ${plural(s.counts.kpis, 'KPI')} on the plan.`); + lines.push(`Our strategy type: ${s.type.name}. ${s.type.text}`); + lines.push(''); + lines.push('Made in Claude with npx my-strategy-wrapped, a strategy check by Vindaris that reads the tools we already use. What would yours say?'); + return lines.join('\n'); +} + +/** The page: the four cards, a PNG download for each, and the caption. */ +export function wrappedHtml(cards, caption, { demo = false } = {}) { + const figs = cards.map((svg, i) => `
+${svg.replace('Download card ${i + 1} +
`).join('\n'); + return ` + + + + +Strategy Wrapped + + + +
+

Strategy Wrapped

+

Four cards for a LinkedIn post (1080 x 1350, the 4:5 portrait format). Download them as PNG and add all four to one post, in order.${demo ? ' These cards show a fictional demo company.' : ' Check every card before you post it: the cards go public.'}

+ +
+
+${figs} +
+
+

Post text

+

A starting point. Make it yours.

+
+ +
+ + + +`; +} diff --git a/test/wrapped.test.js b/test/wrapped.test.js new file mode 100644 index 0000000..506708d --- /dev/null +++ b/test/wrapped.test.js @@ -0,0 +1,91 @@ +import { test } from 'node:test'; +import assert from 'node:assert/strict'; +import { execFileSync } from 'node:child_process'; +import { mkdtempSync, writeFileSync, readFileSync, existsSync } from 'node:fs'; +import { tmpdir } from 'node:os'; +import { join, dirname } from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { emptyGraph, normalizeInput, mergeBatch } from '../src/model.js'; +import { check } from '../src/check.js'; +import { demoInput } from '../src/demo.js'; +import { wrappedStats, wrappedCards, wrappedCaption, wrap } from '../src/wrapped.js'; + +const BIN = join(dirname(fileURLToPath(import.meta.url)), '..', 'bin', 'vindaris.js'); +const build = (input) => { const g = emptyGraph(); mergeBatch(g, normalizeInput(input).batch); return g; }; +const statsOf = (input, asOf) => { const g = build(input); return wrappedStats(g, check(g, { asOf })); }; + +test('demo makes four 1080x1350 cards and a Side-Quest Collector', () => { + const s = statsOf(demoInput()); + assert.equal(s.type.id, 'side-quests'); + const cards = wrappedCards(s, { demo: true }); + assert.equal(cards.length, 4); + for (const c of cards) { + assert.match(c, /^]*width="1080" height="1350"/); + assert.match(c, /DEMO, FICTIONAL COMPANY/); + } +}); + +test('cards keep titles and the company off unless named', () => { + const s = statsOf(demoInput()); + const plain = wrappedCards(s).join(''); + assert.doesNotMatch(plain, /Northwind|Make the app work|Multi-tenant/); + const named = wrappedCards(s, { named: true }).join(''); + assert.match(named, /Northwind/); + assert.match(named, /Make the app work/); + assert.doesNotMatch(wrappedCaption(s), /Northwind|Lena|Make the app/); +}); + +test('named cards escape titles', () => { + const s = statsOf({ company: 'A&B ', goals: [{ id: 'g', title: 'Grow & "far"', owner: 'X' }], + tasks: [{ id: 'T-1', title: 't', status: 'In Progress', updatedAt: '2026-12-01', parent: 'g' }] }, '2026-12-02'); + const svg = wrappedCards(s, { named: true }).join(''); + assert.match(svg, /A&B <Co>/); + assert.doesNotMatch(svg, //); +}); + +test('linked, owned and measured work is a Sharpshooter', () => { + const s = statsOf({ goals: [{ id: 'g', title: 'G', owner: 'A' }], + kpis: [{ id: 'k', title: 'K', currentValue: 5, parent: 'g' }], + tasks: [1, 2, 3].map((i) => ({ id: `T-${i}`, title: `t${i}`, status: 'In Progress', updatedAt: '2026-12-01', parent: 'k' })) }, '2026-12-02'); + assert.equal(s.coverage, 1); + assert.equal(s.topGoal.tasks, 3); + assert.equal(s.type.id, 'sharpshooter'); +}); + +test('wrap keeps lines within the estimate', () => { + const lines = wrap('of linked work went to one goal and then some more words', 56, 920); + assert.ok(lines.length >= 2); + for (const l of lines) assert.ok(l.length <= Math.floor(920 / (56 * 0.52))); +}); + +test('wrapped CLI: no goals means guidance and no file; goals mean a page', () => { + const dir = mkdtempSync(join(tmpdir(), 'vnd-')); + const env = { ...process.env, VINDARIS_GRAPH: join(dir, 'vindaris-graph.json') }; + const go = (args) => execFileSync(process.execPath, [BIN, ...args], { cwd: dir, encoding: 'utf8', env }); + assert.match(go(['wrapped']), /Step 1: take stock[\s\S]*run `vindaris wrapped` again/); + assert.equal(existsSync(join(dir, 'strategy-wrapped.html')), false); + writeFileSync(join(dir, 'plan.json'), JSON.stringify({ goals: [{ id: 'g1', title: 'Reach 300 clinics' }] })); + go(['add', join(dir, 'plan.json')]); + const out = go(['wrapped']); + assert.match(out, /Strategy type:/); + const html = readFileSync(join(dir, 'strategy-wrapped.html'), 'utf8'); + assert.equal((html.match(/ { + const ALIAS = join(dirname(BIN), '..', 'packages', 'my-strategy-wrapped', 'bin', 'my-strategy-wrapped.js'); + const ALIAS26 = join(dirname(BIN), '..', 'packages', 'my-strategy-wrapped-2026', 'bin', 'my-strategy-wrapped-2026.js'); + const dir = mkdtempSync(join(tmpdir(), 'vnd-')); + const env = { ...process.env, VINDARIS_GRAPH: join(dir, 'vindaris-graph.json') }; + const go = (bin, args, input) => execFileSync(process.execPath, [bin, ...args], { cwd: dir, encoding: 'utf8', env, input }); + const first = go(ALIAS, ['2026']); + assert.match(first, /Step 1: take stock/); + assert.match(first, /npx my-strategy-wrapped add .*run `npx my-strategy-wrapped 2026` again/); + go(ALIAS, ['add', '-'], JSON.stringify({ goals: [{ id: 'g1', title: 'Reach 300 clinics' }] })); + assert.match(go(ALIAS, ['2025']), /# My Strategy Wrapped 2025[\s\S]*`npx my-strategy-wrapped 2025 --named`/); + assert.match(readFileSync(join(dir, 'strategy-wrapped.html'), 'utf8'), /MY STRATEGY WRAPPED 2025/); + assert.match(go(ALIAS26, []), /# My Strategy Wrapped 2026[\s\S]*`npx my-strategy-wrapped-2026 --named`/); + assert.match(go(ALIAS, ['status']), /1 goals/); +});