wrapt-cli 0.0.0-stage → 0.1.1

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mayank Agarwal
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.
package/README.md CHANGED
@@ -1,3 +1,78 @@
1
- # Temporary Holding Version
1
+ # wrapt
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ **Your year with Claude Code and GitHub Copilot, wrapped.** wrapt reads your coding-assistant
4
+ history on your own computer, works out your year in review and makes share cards for
5
+ Instagram, LinkedIn and X. Your chats never leave your machine.
6
+
7
+ <p>
8
+ <img src="https://wrapt.cc/cards/01.png" alt="Cover card" width="19%">
9
+ <img src="https://wrapt.cc/cards/02.png" alt="Big number card" width="19%">
10
+ <img src="https://wrapt.cc/cards/03.png" alt="Rhythm card" width="19%">
11
+ <img src="https://wrapt.cc/cards/05.png" alt="Word of the year card" width="19%">
12
+ <img src="https://wrapt.cc/cards/08.png" alt="Outro card" width="19%">
13
+ </p>
14
+
15
+ <sub>Sample cards for “Ada”, a made-up demo user.</sub>
16
+
17
+ ## Get yours
18
+
19
+ ```bash
20
+ npx wrapt-cli analyze && npx wrapt-cli render --name "Ada" && npx wrapt-cli share
21
+ ```
22
+
23
+ Put your own first name in place of Ada. When it's done, a QR code appears in your terminal.
24
+ Scan it with your phone on the same Wi-Fi to open your cards, save them and copy a ready-made
25
+ caption for each platform.
26
+
27
+ Step-by-step guide: **https://wrapt.cc**
28
+
29
+ ## What you get
30
+
31
+ | Format | Size | For |
32
+ |---|---|---|
33
+ | 8 story cards | 1080 × 1920 | Instagram Stories |
34
+ | 8 carousel cards | 1080 × 1350 | Instagram carousel post |
35
+ | 8-page PDF | 1080 × 1350 | LinkedIn document post |
36
+ | 1 summary card | 1200 × 675 | X |
37
+
38
+ The eight cards: your name and year, your biggest number (tokens, hours or prompts), when you
39
+ work and your longest streak, your busiest weekday, your word of the year, your languages,
40
+ tools and models, an archetype, and a summary with a QR code to wrapt.cc.
41
+
42
+ <img src="https://wrapt.cc/x-card.png" alt="X summary card for Ada" width="60%">
43
+
44
+ ## Options
45
+
46
+ ```bash
47
+ npx wrapt-cli render --name "Ada" --theme pastel
48
+ ```
49
+
50
+ | Option | What it does |
51
+ |---|---|
52
+ | `--name "Ada"` | Your first name on the cover. Without it, the cover says “Your 2026”. |
53
+ | `--theme bold\|mono\|pastel` | Color theme. Default: `bold`. |
54
+ | `--show-projects` | Put your real project names on the cards. By default they show as “Project A”, “Project B”. |
55
+ | `--year 2025` | Make the cards for another year. Add it to each command. Default: this year. |
56
+ | `--source claude\|copilot` | Only read one tool's history. Default: every supported tool found. |
57
+ | `--minutes 30` | With `share`: keep the QR code working for longer. Default: 15 minutes. |
58
+
59
+ Run `npx wrapt-cli --help` for everything else.
60
+
61
+ ## Privacy
62
+
63
+ - **Nothing is uploaded.** wrapt reads your history and writes the results on your computer.
64
+ It collects no usage data.
65
+ - **Cards show counts, not prompts.** They show totals, a chart, your most-typed word and short
66
+ repeated prompts like “continue”. They never show what you asked.
67
+ - **Secrets are filtered out.** Anything that looks like a key or token is left out.
68
+ - **Project names are hidden by default**, so work projects don't end up on a public card.
69
+ - **`share` stays on your Wi-Fi.** It serves only your cards, behind a random link, and stops
70
+ after 15 minutes or when you press Ctrl+C.
71
+
72
+ ## Requirements
73
+
74
+ - Node.js 20 or newer
75
+ - Claude Code or GitHub Copilot (Chat in VS Code, or the Copilot CLI), used on this computer
76
+ this year
77
+
78
+ MIT license · https://wrapt.cc
@@ -0,0 +1,93 @@
1
+ Copyright 2020 The Space Grotesk Project Authors (https://github.com/floriankarsten/space-grotesk)
2
+
3
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
+ This license is copied below, and is also available with a FAQ at:
5
+ http://scripts.sil.org/OFL
6
+
7
+
8
+ -----------------------------------------------------------
9
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
+ -----------------------------------------------------------
11
+
12
+ PREAMBLE
13
+ The goals of the Open Font License (OFL) are to stimulate worldwide
14
+ development of collaborative font projects, to support the font creation
15
+ efforts of academic and linguistic communities, and to provide a free and
16
+ open framework in which fonts may be shared and improved in partnership
17
+ with others.
18
+
19
+ The OFL allows the licensed fonts to be used, studied, modified and
20
+ redistributed freely as long as they are not sold by themselves. The
21
+ fonts, including any derivative works, can be bundled, embedded,
22
+ redistributed and/or sold with any software provided that any reserved
23
+ names are not used by derivative works. The fonts and derivatives,
24
+ however, cannot be released under any other type of license. The
25
+ requirement for fonts to remain under this license does not apply
26
+ to any document created using the fonts or their derivatives.
27
+
28
+ DEFINITIONS
29
+ "Font Software" refers to the set of files released by the Copyright
30
+ Holder(s) under this license and clearly marked as such. This may
31
+ include source files, build scripts and documentation.
32
+
33
+ "Reserved Font Name" refers to any names specified as such after the
34
+ copyright statement(s).
35
+
36
+ "Original Version" refers to the collection of Font Software components as
37
+ distributed by the Copyright Holder(s).
38
+
39
+ "Modified Version" refers to any derivative made by adding to, deleting,
40
+ or substituting -- in part or in whole -- any of the components of the
41
+ Original Version, by changing formats or by porting the Font Software to a
42
+ new environment.
43
+
44
+ "Author" refers to any designer, engineer, programmer, technical
45
+ writer or other person who contributed to the Font Software.
46
+
47
+ PERMISSION & CONDITIONS
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
+ redistribute, and sell modified and unmodified copies of the Font
51
+ Software, subject to the following conditions:
52
+
53
+ 1) Neither the Font Software nor any of its individual components,
54
+ in Original or Modified Versions, may be sold by itself.
55
+
56
+ 2) Original or Modified Versions of the Font Software may be bundled,
57
+ redistributed and/or sold with any software, provided that each copy
58
+ contains the above copyright notice and this license. These can be
59
+ included either as stand-alone text files, human-readable headers or
60
+ in the appropriate machine-readable metadata fields within text or
61
+ binary files as long as those fields can be easily viewed by the user.
62
+
63
+ 3) No Modified Version of the Font Software may use the Reserved Font
64
+ Name(s) unless explicit written permission is granted by the corresponding
65
+ Copyright Holder. This restriction only applies to the primary font name as
66
+ presented to the users.
67
+
68
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
+ Software shall not be used to promote, endorse or advertise any
70
+ Modified Version, except to acknowledge the contribution(s) of the
71
+ Copyright Holder(s) and the Author(s) or with their explicit written
72
+ permission.
73
+
74
+ 5) The Font Software, modified or unmodified, in part or in whole,
75
+ must be distributed entirely under this license, and must not be
76
+ distributed under any other license. The requirement for fonts to
77
+ remain under this license does not apply to any document created
78
+ using the Font Software.
79
+
80
+ TERMINATION
81
+ This license becomes null and void if any of the above conditions are
82
+ not met.
83
+
84
+ DISCLAIMER
85
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
+ OTHER DEALINGS IN THE FONT SOFTWARE.
@@ -0,0 +1,35 @@
1
+ import fs from "node:fs";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+ import { emptyReport } from "./parse/reader.js";
5
+ import { resolveSources } from "./sources/index.js";
6
+ import { StatsEngine } from "./stats/engine.js";
7
+ export function claudeProjectsDir() {
8
+ const base = process.env.CLAUDE_CONFIG_DIR ?? path.join(os.homedir(), ".claude");
9
+ return path.join(base, "projects");
10
+ }
11
+ export function wraptHome() {
12
+ return process.env.WRAPT_HOME ?? path.join(os.homedir(), ".wrapt");
13
+ }
14
+ export async function analyze(opts) {
15
+ const paths = {
16
+ claudeProjects: opts.projectsDir ?? claudeProjectsDir(),
17
+ vscodeUserDirs: opts.vscodeUserDirs,
18
+ copilotHome: opts.copilotHome,
19
+ };
20
+ const sources = resolveSources(opts.source, paths);
21
+ const report = emptyReport();
22
+ const engine = new StatsEngine({ year: opts.year });
23
+ for (const src of sources)
24
+ for await (const e of src.read(paths, report))
25
+ engine.add(e);
26
+ const { stats, samples } = engine.finish(report);
27
+ const outDir = opts.outDir ?? path.join(wraptHome(), String(opts.year));
28
+ fs.mkdirSync(outDir, { recursive: true, mode: 0o700 });
29
+ const statsPath = path.join(outDir, "stats.json");
30
+ const samplesPath = path.join(outDir, "samples.json");
31
+ fs.writeFileSync(statsPath, JSON.stringify(stats, null, 2) + "\n", { mode: 0o600 });
32
+ // samples.json holds prompt excerpts: private, local only, never rendered.
33
+ fs.writeFileSync(samplesPath, JSON.stringify({ year: opts.year, samples }, null, 2) + "\n", { mode: 0o600 });
34
+ return { stats, samples, statsPath, samplesPath };
35
+ }
package/dist/brand.js ADDED
@@ -0,0 +1,11 @@
1
+ /** Name the tools a year actually came from. stats.json without `sources` predates Copilot support = Claude only. */
2
+ export function brandFor(stats) {
3
+ const ids = new Set((stats.sources ?? []).filter((s) => s.prompts > 0).map((s) => s.id));
4
+ const claude = ids.has("claude") || ids.size === 0;
5
+ const copilot = ids.has("copilot-vscode") || ids.has("copilot-cli");
6
+ if (claude && copilot)
7
+ return { short: "Claude & Copilot", long: "Claude Code & Copilot", partner: "your AI pair programmers" };
8
+ if (copilot)
9
+ return { short: "Copilot", long: "GitHub Copilot", partner: "Copilot" };
10
+ return { short: "Claude", long: "Claude Code", partner: "Claude" };
11
+ }
package/dist/cli.js ADDED
@@ -0,0 +1,261 @@
1
+ #!/usr/bin/env node
2
+ import { parseArgs } from "node:util";
3
+ import fs from "node:fs";
4
+ import path from "node:path";
5
+ import { analyze, wraptHome } from "./analyze.js";
6
+ import { NarrativeSchema, narrativeJsonSchema } from "./narrative.js";
7
+ import { renderAll } from "./render/index.js";
8
+ import { SITE_URL } from "./site.js";
9
+ import { startShare } from "./share/server.js";
10
+ import qrcode from "qrcode-terminal";
11
+ import readlinePromises from "node:readline/promises";
12
+ import { buildSite, pushSite, resolveTarget } from "./publish.js";
13
+ import { THEMES } from "./render/theme.js";
14
+ import { StatsSchema } from "./stats/schema.js";
15
+ import { summary } from "./format.js";
16
+ const HELP = `wrapt — your year with Claude Code, wrapped. 100% local.
17
+
18
+ Run it with npx: npx wrapt-cli <command> (or install it: npm i -g wrapt-cli, then wrapt <command>)
19
+
20
+ Usage
21
+ wrapt analyze [--year 2026] [--source all|claude|copilot] [--json] [--projects-dir <dir>] [--out <dir>]
22
+ wrapt render [--year 2026] [--name "Ada"] [--show-projects] [--theme bold|mono|pastel] [--out <dir>]
23
+ wrapt schema [--validate <narrative.json>]
24
+ wrapt share [--year 2026] [--minutes 15] [--port <n>]
25
+ wrapt publish --repo <owner/name> [--branch gh-pages] [--url <base>] [--dry-run] [--yes] [--remove]
26
+
27
+ Commands
28
+ analyze Read Claude Code (and GitHub Copilot) history and write ~/.wrapt/<year>/stats.json
29
+ render Turn stats.json (+ narrative.json) into story/carousel PNGs, linkedin.pdf and x-card.png
30
+ schema Print the JSON Schema for narrative.json, or --validate a file against it
31
+ share Serve the cards on your Wi-Fi and show a QR code to open them on your phone. No upload.
32
+ publish Opt-in: put the cards on GitHub Pages (a gh-pages branch in YOUR repo) with link previews.
33
+ Uploads only the rendered images, PDF and page. --remove takes the year down again.
34
+
35
+ Options
36
+ --year Calendar year to analyze (default: current year)
37
+ --source Which history to read: all (default, every tool found), claude, copilot,
38
+ copilot-vscode, copilot-cli, or a comma list
39
+ --json Print stats.json to stdout instead of the summary
40
+ --projects-dir Claude Code projects dir (default: ~/.claude/projects)
41
+ --out Output dir (default: ~/.wrapt/<year>)
42
+ --name Name for the cover (default: "Your 2026 with Claude")
43
+ --show-projects Put your real project names on the cards (default: "Project A/B/C")
44
+ --theme Colour theme: ${Object.keys(THEMES).join(", ")} (default: bold)
45
+ -h, --help Show help
46
+ `;
47
+ async function main(argv) {
48
+ const { values, positionals } = parseArgs({
49
+ args: argv,
50
+ allowPositionals: true,
51
+ options: {
52
+ year: { type: "string" },
53
+ json: { type: "boolean", default: false },
54
+ "projects-dir": { type: "string" },
55
+ source: { type: "string" },
56
+ out: { type: "string" },
57
+ name: { type: "string" },
58
+ "show-projects": { type: "boolean", default: false },
59
+ // Older flag: project names are hidden by default now, so this is a no-op kept for scripts.
60
+ "hide-projects": { type: "boolean", default: false },
61
+ theme: { type: "string" },
62
+ validate: { type: "string" },
63
+ minutes: { type: "string" },
64
+ repo: { type: "string" },
65
+ branch: { type: "string" },
66
+ url: { type: "string" },
67
+ "dry-run": { type: "boolean", default: false },
68
+ yes: { type: "boolean", short: "y", default: false },
69
+ remove: { type: "boolean", default: false },
70
+ port: { type: "string" },
71
+ help: { type: "boolean", short: "h", default: false },
72
+ },
73
+ });
74
+ const cmd = positionals[0] ?? "analyze";
75
+ if (values.help || cmd === "help") {
76
+ process.stdout.write(HELP);
77
+ return;
78
+ }
79
+ const year = values.year ? Number(values.year) : new Date().getFullYear();
80
+ if (!Number.isInteger(year) || year < 2000 || year > 3000)
81
+ throw new Error(`Invalid --year: ${values.year}`);
82
+ switch (cmd) {
83
+ case "analyze": {
84
+ const res = await analyze({ year, projectsDir: values["projects-dir"], outDir: values.out, source: values.source });
85
+ if (values.json)
86
+ process.stdout.write(JSON.stringify(res.stats, null, 2) + "\n");
87
+ else
88
+ process.stdout.write(summary(res.stats, { stats: res.statsPath, samples: res.samplesPath }) + "\n");
89
+ if (res.stats.totals.prompts === 0) {
90
+ process.stderr.write(`No prompts found for ${year} (sources: ${values.source ?? "all"}). Is ~/.claude/projects or Copilot history populated?\n`);
91
+ }
92
+ return;
93
+ }
94
+ case "render": {
95
+ const dir = values.out ?? path.join(wraptHome(), String(year));
96
+ const statsPath = path.join(dir, "stats.json");
97
+ if (!fs.existsSync(statsPath))
98
+ throw new Error(`No ${statsPath}. Run \`wrapt analyze --year ${year}\` first.`);
99
+ const stats = StatsSchema.parse(JSON.parse(fs.readFileSync(statsPath, "utf8")));
100
+ let narrative;
101
+ const narrativePath = path.join(dir, "narrative.json");
102
+ if (fs.existsSync(narrativePath)) {
103
+ const parsed = NarrativeSchema.safeParse(JSON.parse(fs.readFileSync(narrativePath, "utf8")));
104
+ if (parsed.success)
105
+ narrative = parsed.data;
106
+ else
107
+ process.stderr.write(`Ignoring invalid narrative.json:\n${parsed.error.message}\n`);
108
+ }
109
+ const t0 = Date.now();
110
+ const res = await renderAll({ stats, narrative, name: values.name, hideProjects: values["hide-projects"] || !values["show-projects"], theme: values.theme, outDir: dir });
111
+ process.stdout.write([
112
+ "",
113
+ ` Rendered in ${((Date.now() - t0) / 1000).toFixed(1)}s${narrative ? "" : " (no narrative.json: card 4 shows your week, and the archetype comes from your rhythm)"}`,
114
+ ` story ${path.dirname(res.story[0])}/01..08.png`,
115
+ ` carousel ${path.dirname(res.carousel[0])}/01..08.png`,
116
+ ` linkedin ${res.pdf}`,
117
+ ` x ${res.xCard}`,
118
+ "",
119
+ ` When you post, link ${SITE_URL} so people can make their own.`,
120
+ " Run `npx wrapt-cli share` for ready-to-copy captions on your phone.",
121
+ "",
122
+ ].join("\n") + "\n");
123
+ return;
124
+ }
125
+ case "share": {
126
+ const dir = values.out ?? path.join(wraptHome(), String(year));
127
+ const minutes = values.minutes ? Number(values.minutes) : 15;
128
+ if (!(minutes > 0 && minutes <= 120))
129
+ throw new Error("--minutes must be between 1 and 120");
130
+ const seen = new Set();
131
+ const share = await startShare({
132
+ dir,
133
+ year,
134
+ minutes,
135
+ port: values.port ? Number(values.port) : undefined,
136
+ onRequest: (p) => {
137
+ if (p === "/" && !seen.has(p))
138
+ process.stdout.write(" ✓ Page opened on a device\n");
139
+ seen.add(p);
140
+ },
141
+ });
142
+ const qr = await new Promise((resolve) => qrcode.generate(share.url, { small: true }, resolve));
143
+ process.stdout.write([
144
+ "",
145
+ " Scan with your phone's camera (same Wi-Fi as this computer):",
146
+ "",
147
+ qr.replace(/^/gm, " "),
148
+ ` ${share.url}`,
149
+ share.lan ? "" : " ! No Wi-Fi/LAN address found, so only this computer can open the link.",
150
+ ` Serving only your rendered cards and PDF. Nothing is uploaded. Stops in ${minutes} min or on Ctrl+C.`,
151
+ "",
152
+ ].join("\n") + "\n");
153
+ const stop = () => {
154
+ process.stdout.write("\n Share server stopped.\n");
155
+ share.close();
156
+ };
157
+ process.once("SIGINT", stop);
158
+ process.once("SIGTERM", stop);
159
+ await share.closed;
160
+ process.removeListener("SIGINT", stop);
161
+ process.removeListener("SIGTERM", stop);
162
+ if (!process.exitCode)
163
+ process.stdout.write(" Done.\n");
164
+ return;
165
+ }
166
+ case "publish": {
167
+ const dir = values.out ?? path.join(wraptHome(), String(year));
168
+ const branch = values.branch ?? "gh-pages";
169
+ if (!values.repo && !values["dry-run"])
170
+ throw new Error("Pass --repo <owner/name> (an existing GitHub repo you can push to), or --dry-run.");
171
+ const target = values.repo
172
+ ? resolveTarget(values.repo, year, values.url)
173
+ : { remote: "", pageUrl: `${(values.url ?? "https://example.github.io/wrapt").replace(/\/$/, "")}/${year}/` };
174
+ const confirm = async (question) => {
175
+ if (values.yes)
176
+ return true;
177
+ if (!process.stdin.isTTY)
178
+ throw new Error("Refusing to publish without confirmation. Re-run in a terminal or pass --yes.");
179
+ const rl = readlinePromises.createInterface({ input: process.stdin, output: process.stdout });
180
+ const answer = (await rl.question(question)).trim().toLowerCase();
181
+ rl.close();
182
+ return answer === "y" || answer === "yes";
183
+ };
184
+ if (values.remove) {
185
+ if (!(await confirm(`Remove ${year}/ from ${target.remote} (${branch})? [y/N] `)))
186
+ return void process.stdout.write(" Cancelled.\n");
187
+ const changed = pushSite({ remote: target.remote, branch, year, message: `wrapt: remove ${year}` });
188
+ process.stdout.write(changed ? ` Removed ${target.pageUrl}\n` : ` Nothing to remove for ${year}.\n`);
189
+ return;
190
+ }
191
+ const statsPath = path.join(dir, "stats.json");
192
+ if (!fs.existsSync(statsPath))
193
+ throw new Error(`No ${statsPath}. Run \`wrapt analyze\` and \`wrapt render\` first.`);
194
+ const stats = StatsSchema.parse(JSON.parse(fs.readFileSync(statsPath, "utf8")));
195
+ const renderInfo = (() => {
196
+ try {
197
+ return JSON.parse(fs.readFileSync(path.join(dir, "render.json"), "utf8"));
198
+ }
199
+ catch {
200
+ return {};
201
+ }
202
+ })();
203
+ const { siteDir, files } = buildSite({ dir, stats, name: values.name ?? renderInfo.name ?? undefined, pageUrl: target.pageUrl });
204
+ const L = [
205
+ "",
206
+ ` Site built: ${siteDir} (${files.length} files)`,
207
+ " Contains only: story + carousel PNGs, linkedin.pdf, x-card.png, index.html, font.",
208
+ " Never uploaded: stats.json, samples.json, narrative.json, report.md.",
209
+ ];
210
+ const projects = stats.stack.projects.slice(0, 3).map((p) => p.name);
211
+ if (renderInfo.hideProjects !== true && projects.length) {
212
+ L.push("", ` ! Your cards show project names (${projects.join(", ")}). If any are private or work-related,`, ` run \`wrapt render\` again without --show-projects first.`);
213
+ }
214
+ process.stdout.write(L.join("\n") + "\n");
215
+ if (values["dry-run"]) {
216
+ process.stdout.write(`\n Dry run: nothing uploaded. Open ${path.join(siteDir, "index.html")} to preview.\n`);
217
+ return;
218
+ }
219
+ process.stdout.write(`\n This makes the cards PUBLIC at ${target.pageUrl}\n (pushed to ${target.remote}, branch ${branch}). You can undo it with --remove.\n`);
220
+ if (!(await confirm(" Publish? [y/N] ")))
221
+ return void process.stdout.write(" Cancelled. Nothing was uploaded.\n");
222
+ const changed = pushSite({ remote: target.remote, branch, year, siteDir, message: `wrapt: publish ${year} cards` });
223
+ process.stdout.write([
224
+ "",
225
+ changed ? ` ✓ Published → ${target.pageUrl}` : ` Already up to date → ${target.pageUrl}`,
226
+ ` First time? In the repo's Settings → Pages, set the source to "Deploy from a branch: ${branch} / (root)".`,
227
+ " GitHub usually takes a minute or two to serve a new site.",
228
+ "",
229
+ ].join("\n") + "\n");
230
+ return;
231
+ }
232
+ case "schema": {
233
+ if (!values.validate) {
234
+ process.stdout.write(JSON.stringify(narrativeJsonSchema(), null, 2) + "\n");
235
+ return;
236
+ }
237
+ let json;
238
+ try {
239
+ json = JSON.parse(fs.readFileSync(values.validate, "utf8"));
240
+ }
241
+ catch (e) {
242
+ throw new Error(`Could not read ${values.validate}: ${e instanceof Error ? e.message : String(e)}`);
243
+ }
244
+ const res = NarrativeSchema.safeParse(json);
245
+ if (res.success)
246
+ process.stdout.write(`✓ ${values.validate} is a valid narrative.json\n`);
247
+ else {
248
+ process.stderr.write(`✗ ${values.validate} is invalid:\n${res.error.issues.map((i) => ` - ${i.path.join(".") || "(root)"}: ${i.message}`).join("\n")}\n`);
249
+ process.exitCode = 1;
250
+ }
251
+ return;
252
+ }
253
+ default:
254
+ process.stderr.write(`Unknown command: ${cmd}\n\n${HELP}`);
255
+ process.exitCode = 1;
256
+ }
257
+ }
258
+ main(process.argv.slice(2)).catch((err) => {
259
+ process.stderr.write(`wrapt: ${err instanceof Error ? err.message : String(err)}\n`);
260
+ process.exitCode = 1;
261
+ });
package/dist/format.js ADDED
@@ -0,0 +1,85 @@
1
+ import { brandFor } from "./brand.js";
2
+ /** 48213000 -> "48.2M" */
3
+ export function human(n) {
4
+ const abs = Math.abs(n);
5
+ const units = [
6
+ [1e12, "T"],
7
+ [1e9, "B"],
8
+ [1e6, "M"],
9
+ [1e3, "K"],
10
+ ];
11
+ for (const [v, s] of units) {
12
+ if (abs >= v) {
13
+ const x = n / v;
14
+ return `${x >= 100 ? Math.round(x) : Math.round(x * 10) / 10}${s}`;
15
+ }
16
+ }
17
+ return String(Math.round(n));
18
+ }
19
+ const tty = process.stdout.isTTY && !process.env.NO_COLOR;
20
+ const c = (code) => (s) => (tty ? `\x1b[${code}m${s}\x1b[0m` : s);
21
+ const bold = c(1);
22
+ const dim = c(2);
23
+ const cyan = c(36);
24
+ const magenta = c(35);
25
+ const BARS = " ▁▂▃▄▅▆▇█";
26
+ function spark(values) {
27
+ const max = Math.max(...values, 1);
28
+ return values.map((v) => BARS[Math.round((v / max) * (BARS.length - 1))]).join("");
29
+ }
30
+ /** "mcp__github__create_issue" -> "create_issue (github)". Long server ids are dropped. */
31
+ export function displayTool(name) {
32
+ const m = /^mcp__(.+?)__(.+)$/.exec(name);
33
+ if (!m)
34
+ return name;
35
+ const server = m[1];
36
+ return /^[0-9a-f-]{20,}$/i.test(server) ? m[2] : `${m[2]} (${server})`;
37
+ }
38
+ function list(items, fmt = (n) => String(n)) {
39
+ return items.length ? items.map((i) => `${i.name} ${dim(fmt(i.count))}`).join(dim(" · ")) : dim("—");
40
+ }
41
+ export function summary(s, paths) {
42
+ const t = s.totals;
43
+ const r = s.rhythm;
44
+ const L = [];
45
+ const row = (k, v) => L.push(` ${dim(k.padEnd(18))}${v}`);
46
+ L.push("");
47
+ L.push(bold(magenta(` wrapt · your ${s.year} with ${brandFor(s).long}`)));
48
+ L.push("");
49
+ L.push(bold(" Totals"));
50
+ row("sessions", bold(String(t.sessions)));
51
+ row("prompts", bold(String(t.prompts)));
52
+ row("assistant turns", bold(String(t.assistantTurns)));
53
+ if (s.sources?.length)
54
+ row("sources", s.sources.map((x) => `${x.name} ${dim(`${x.prompts} prompts · ${x.sessions} sessions`)}`).join(dim(" · ")));
55
+ row("tokens", `${bold(human(t.tokens.total))} ${dim(`(in ${human(t.tokens.input)} · out ${human(t.tokens.output)} · cache write ${human(t.tokens.cacheCreation)} · cache read ${human(t.tokens.cacheRead)})`)}`);
56
+ row("active days", bold(String(t.activeDays)));
57
+ row("hours (est.)", bold(String(t.hours)));
58
+ L.push("");
59
+ L.push(bold(" Rhythm"));
60
+ row("you are a", bold(cyan(r.label)));
61
+ row("by hour", `${cyan(spark(r.hours))} ${dim("0h → 23h")}`);
62
+ row("by weekday", `${cyan(spark(r.weekdays))} ${dim("Mon → Sun")}`);
63
+ row("longest streak", `${bold(String(r.longestStreak.days))} days ${dim(r.longestStreak.start ? `${r.longestStreak.start} → ${r.longestStreak.end}` : "")}`);
64
+ row("busiest day", r.busiestDay ? `${r.busiestDay.date} ${dim(`(${r.busiestDay.prompts} prompts)`)}` : dim("—"));
65
+ row("after midnight", `${r.afterMidnight} prompts`);
66
+ L.push("");
67
+ L.push(bold(" Stack"));
68
+ row("projects", list(s.stack.projects));
69
+ row("tools", list(s.stack.tools.slice(0, 6).map((t) => ({ ...t, name: displayTool(t.name) }))));
70
+ row("models", s.stack.models.length ? s.stack.models.map((m) => `${m.name} ${dim(`${m.pct}%`)}`).join(dim(" · ")) : dim("—"));
71
+ row("languages", list(s.stack.languages));
72
+ L.push("");
73
+ L.push(bold(" Words"));
74
+ row("word of the year", s.words.wordOfYear ? `${bold(cyan(s.words.wordOfYear.name))} ${dim(`×${s.words.wordOfYear.count}`)}` : dim("—"));
75
+ row("repeat prompts", s.words.repeatPrompts.length ? s.words.repeatPrompts.map((p) => `"${p.text}" ${dim(`×${p.count}`)}`).join(dim(" · ")) : dim("none repeated yet"));
76
+ L.push("");
77
+ const p = s.parse;
78
+ const skipped = Object.values(p.skippedTypes).reduce((a, b) => a + b, 0);
79
+ const excluded = Object.values(p.excludedUser).reduce((a, b) => a + b, 0);
80
+ L.push(dim(` parsed ${p.files} files · ${p.lines} lines · ${p.malformed} malformed · ${p.duplicates} duplicates · ${skipped} non-chat lines · ${excluded} non-prompt user lines`));
81
+ L.push(dim(` → ${paths.stats}`));
82
+ L.push(dim(` → ${paths.samples} (private, stays on this machine)`));
83
+ L.push("");
84
+ return L.join("\n");
85
+ }
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ /** Public API: schemas and building blocks for tools that consume wrapt output. */
2
+ export { NarrativeSchema, narrativeJsonSchema } from "./narrative.js";
3
+ export { StatsSchema } from "./stats/schema.js";
4
+ export { analyze, claudeProjectsDir, wraptHome } from "./analyze.js";
5
+ export { renderAll } from "./render/index.js";
@@ -0,0 +1,20 @@
1
+ import { z } from "zod";
2
+ /** narrative.json — written by Claude via the /wrapt skill from samples.json + stats.json. */
3
+ export const NarrativeSchema = z.object({
4
+ categories: z
5
+ .array(z.object({
6
+ name: z.string().min(1).max(22).describe("Short category name, e.g. 'Debugging'"),
7
+ pct: z.number().min(0).max(100).describe("Share of sampled prompts, 0-100"),
8
+ }))
9
+ .min(1)
10
+ .max(5)
11
+ .describe("Top ask categories, largest first"),
12
+ archetype: z.object({
13
+ name: z.string().min(1).max(32).describe("e.g. 'The Midnight Refactorer'"),
14
+ description: z.string().min(1).max(140).describe("One-line roast or compliment grounded in the stats"),
15
+ }),
16
+ tagline: z.string().max(80).optional().describe("Optional one-liner for the cover"),
17
+ });
18
+ export function narrativeJsonSchema() {
19
+ return z.toJSONSchema(NarrativeSchema);
20
+ }