wrapt-cli 0.1.3 → 0.1.4

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/README.md CHANGED
@@ -24,7 +24,9 @@ Put your own first name in place of Ada. When it's done, a QR code appears in yo
24
24
  Scan it with your phone on the same Wi-Fi to open your cards, save them and copy a ready-made
25
25
  caption for each platform.
26
26
 
27
- Your cards are saved in `~/.wrapt/<year>/`, with a ZIP of each set. To open that folder:
27
+ Your cards are saved in a `wrapt-<year>` folder inside the folder you ran the command from,
28
+ with a ZIP of each set. Your private stats stay separately in `~/.wrapt/<year>/`. To open the
29
+ cards folder:
28
30
 
29
31
  ```bash
30
32
  npx wrapt-cli open
package/dist/analyze.js CHANGED
@@ -27,9 +27,14 @@ export async function analyze(opts) {
27
27
  const outDir = opts.outDir ?? path.join(wraptHome(), String(opts.year));
28
28
  fs.mkdirSync(outDir, { recursive: true, mode: 0o700 });
29
29
  const statsPath = path.join(outDir, "stats.json");
30
- const samplesPath = path.join(outDir, "samples.json");
31
30
  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 };
31
+ const samplesPath = path.join(outDir, "samples.json");
32
+ if (opts.samples) {
33
+ // samples.json holds prompt excerpts: private, local only, never rendered. Only the /wrapt skill needs it.
34
+ fs.writeFileSync(samplesPath, JSON.stringify({ year: opts.year, samples }, null, 2) + "\n", { mode: 0o600 });
35
+ return { stats, samples, statsPath, samplesPath };
36
+ }
37
+ // Don't leave excerpts from an earlier --samples run lying around.
38
+ fs.rmSync(samplesPath, { force: true });
39
+ return { stats, samples, statsPath };
35
40
  }
package/dist/cli.js CHANGED
@@ -15,12 +15,17 @@ import { buildSite, pushSite, resolveTarget } from "./publish.js";
15
15
  import { THEMES } from "./render/theme.js";
16
16
  import { StatsSchema } from "./stats/schema.js";
17
17
  import { summary } from "./format.js";
18
+ /** A path as the user would type it: ./wrapt-2026 under the current folder, ~/… under home. */
19
+ function shown(p) {
20
+ const rel = path.relative(process.cwd(), p);
21
+ return rel && !rel.startsWith("..") && !path.isAbsolute(rel) ? `./${rel}` : tildify(p);
22
+ }
18
23
  const HELP = `wrapt — your year with Claude Code, wrapped. 100% local.
19
24
 
20
25
  Run it with npx: npx wrapt-cli <command> (or install it: npm i -g wrapt-cli, then wrapt <command>)
21
26
 
22
27
  Usage
23
- wrapt analyze [--year 2026] [--source all|claude|copilot] [--json] [--projects-dir <dir>] [--out <dir>]
28
+ wrapt analyze [--year 2026] [--source all|claude|copilot] [--json] [--samples] [--projects-dir <dir>]
24
29
  wrapt render [--year 2026] [--name "Ada"] [--show-projects] [--theme bold|mono|pastel] [--out <dir>]
25
30
  wrapt schema [--validate <narrative.json>]
26
31
  wrapt share [--year 2026] [--minutes 15] [--port <n>]
@@ -29,12 +34,13 @@ Usage
29
34
  wrapt publish --repo <owner/name> [--branch gh-pages] [--url <base>] [--dry-run] [--yes] [--remove]
30
35
 
31
36
  Commands
32
- analyze Read Claude Code (and GitHub Copilot) history and write ~/.wrapt/<year>/stats.json
33
- render Turn stats.json (+ narrative.json) into story/carousel PNGs, linkedin.pdf and x-card.png
37
+ analyze Read Claude Code (and GitHub Copilot) history and save your stats privately in ~/.wrapt/<year>/
38
+ render Make the cards in ./wrapt-<year>/ in the current folder: story and carousel PNGs, a ZIP of
39
+ each, linkedin.pdf and x-card.png
34
40
  schema Print the JSON Schema for narrative.json, or --validate a file against it
35
41
  share Serve the cards on your Wi-Fi and show a QR code to open them on your phone. No upload.
36
42
  airdrop Mac only: AirDrop the cards to your iPhone, where they go straight into Photos.
37
- open Open the folder with your cards and ZIPs (Finder, File Explorer or your file manager).
43
+ open Open ./wrapt-<year>/ with your cards and ZIPs (Finder, File Explorer or your file manager).
38
44
  publish Opt-in: put the cards on GitHub Pages (a gh-pages branch in YOUR repo) with link previews.
39
45
  Uploads only the rendered images, PDF and page. --remove takes the year down again.
40
46
 
@@ -44,7 +50,10 @@ Options
44
50
  copilot-vscode, copilot-cli, or a comma list
45
51
  --json Print stats.json to stdout instead of the summary
46
52
  --projects-dir Claude Code projects dir (default: ~/.claude/projects)
47
- --out Output dir (default: ~/.wrapt/<year>)
53
+ --out Where the cards go, and where share/airdrop/open/publish look for them
54
+ (default: ./wrapt-<year> in the folder you run wrapt from)
55
+ --data Where your private stats live (default: ~/.wrapt/<year>). Never shared.
56
+ --samples analyze: also save samples.json, prompt excerpts for the /wrapt skill. Off by default.
48
57
  --name Name for the cover (default: "Your 2026 with Claude")
49
58
  --show-projects Put your real project names on the cards (default: "Project A/B/C")
50
59
  --theme Colour theme: ${Object.keys(THEMES).join(", ")} (default: bold)
@@ -60,6 +69,8 @@ async function main(argv) {
60
69
  "projects-dir": { type: "string" },
61
70
  source: { type: "string" },
62
71
  out: { type: "string" },
72
+ data: { type: "string" },
73
+ samples: { type: "boolean", default: false },
63
74
  name: { type: "string" },
64
75
  "show-projects": { type: "boolean", default: false },
65
76
  // Older flag: project names are hidden by default now, so this is a no-op kept for scripts.
@@ -86,11 +97,27 @@ async function main(argv) {
86
97
  const year = values.year ? Number(values.year) : new Date().getFullYear();
87
98
  if (!Number.isInteger(year) || year < 2000 || year > 3000)
88
99
  throw new Error(`Invalid --year: ${values.year}`);
89
- /** The full command to run next, keeping --year/--out so it finds the same cards. */
90
- const next = (sub) => `npx wrapt-cli ${sub}${values.year ? ` --year ${year}` : ""}${values.out ? ` --out "${values.out}"` : ""}`;
100
+ /** The full command to run next, keeping --year/--out/--data so it finds the same cards. */
101
+ const next = (sub) => `npx wrapt-cli ${sub}${values.year ? ` --year ${year}` : ""}${values.out ? ` --out "${values.out}"` : ""}${values.data ? ` --data "${values.data}"` : ""}`;
102
+ // Two folders, kept apart so the private one never gets shared by accident:
103
+ // cardsDir: the cards, in the folder the command runs from (./wrapt-<year>) unless --out says otherwise
104
+ // dataDir: stats.json, samples.json, narrative.json, report.md, render.json, in ~/.wrapt/<year>
105
+ const cardsDir = path.resolve(values.out ?? `wrapt-${year}`);
106
+ const homeDataDir = path.join(wraptHome(), String(year));
107
+ // A folder given with --out that already holds stats.json (scripts, tests) is used for both.
108
+ const dataDir = values.data ?? (values.out && fs.existsSync(path.join(cardsDir, "stats.json")) ? cardsDir : homeDataDir);
109
+ /** Where existing cards are: ./wrapt-<year>, or ~/.wrapt/<year> for cards made before wrapt 0.1.4. */
110
+ const findCards = () => {
111
+ if (values.out || fs.existsSync(path.join(cardsDir, "story")))
112
+ return cardsDir;
113
+ if (fs.existsSync(path.join(homeDataDir, "story")))
114
+ return homeDataDir;
115
+ throw new Error(`No cards in ${shown(cardsDir)}. Run \`${next("render")}\` here first, or cd to the folder where you ran it.`);
116
+ };
91
117
  switch (cmd) {
92
118
  case "analyze": {
93
- const res = await analyze({ year, projectsDir: values["projects-dir"], outDir: values.out, source: values.source });
119
+ // --out is accepted here for older scripts, where it meant the stats folder.
120
+ const res = await analyze({ year, projectsDir: values["projects-dir"], outDir: values.data ?? values.out, source: values.source, samples: values.samples });
94
121
  if (values.json)
95
122
  process.stdout.write(JSON.stringify(res.stats, null, 2) + "\n");
96
123
  else
@@ -101,13 +128,13 @@ async function main(argv) {
101
128
  return;
102
129
  }
103
130
  case "render": {
104
- const dir = values.out ?? path.join(wraptHome(), String(year));
105
- const statsPath = path.join(dir, "stats.json");
131
+ const dir = cardsDir;
132
+ const statsPath = path.join(dataDir, "stats.json");
106
133
  if (!fs.existsSync(statsPath))
107
- throw new Error(`No ${statsPath}. Run \`wrapt analyze --year ${year}\` first.`);
134
+ throw new Error(`No stats for ${year} yet. Run \`${next("analyze")}\` first.`);
108
135
  const stats = StatsSchema.parse(JSON.parse(fs.readFileSync(statsPath, "utf8")));
109
136
  let narrative;
110
- const narrativePath = path.join(dir, "narrative.json");
137
+ const narrativePath = path.join(dataDir, "narrative.json");
111
138
  if (fs.existsSync(narrativePath)) {
112
139
  const parsed = NarrativeSchema.safeParse(JSON.parse(fs.readFileSync(narrativePath, "utf8")));
113
140
  if (parsed.success)
@@ -116,7 +143,7 @@ async function main(argv) {
116
143
  process.stderr.write(`Ignoring invalid narrative.json:\n${parsed.error.message}\n`);
117
144
  }
118
145
  const t0 = Date.now();
119
- const res = await renderAll({ stats, narrative, name: values.name, hideProjects: values["hide-projects"] || !values["show-projects"], theme: values.theme, outDir: dir });
146
+ const res = await renderAll({ stats, narrative, name: values.name, hideProjects: values["hide-projects"] || !values["show-projects"], theme: values.theme, outDir: dir, infoDir: dataDir });
120
147
  // Every card of a set in one file, for downloading or sending in one go.
121
148
  const zipNames = [];
122
149
  for (const [set, buf] of Object.entries(cardZips(dir, year, collectAssets(dir)))) {
@@ -130,7 +157,7 @@ async function main(argv) {
130
157
  "",
131
158
  ` ✓ Your cards are ready (${((Date.now() - t0) / 1000).toFixed(1)}s)${narrative ? "" : ". Card 4 shows your week, and the archetype comes from your rhythm."}`,
132
159
  "",
133
- ` Saved in ${tildify(dir)}`,
160
+ ` Saved in ${shown(dir)}`,
134
161
  row("story/", `${n} Instagram Story cards (1080 × 1920)`),
135
162
  row("carousel/", `${res.carousel.length} Instagram carousel cards (1080 × 1350)`),
136
163
  ...zipNames.map((z) => row(z, `all the ${z.includes("story") ? "story" : "carousel"} cards in one file`)),
@@ -143,12 +170,13 @@ async function main(argv) {
143
170
  ...(process.platform === "darwin" ? [row("Mac + iPhone:", next("airdrop"))] : []),
144
171
  "",
145
172
  ` When you post, link ${SITE_URL} so people can make their own.`,
173
+ ...(dataDir !== dir ? [` Your private stats stay in ${shown(dataDir)} and are never shared.`] : []),
146
174
  "",
147
175
  ].join("\n") + "\n");
148
176
  return;
149
177
  }
150
178
  case "share": {
151
- const dir = values.out ?? path.join(wraptHome(), String(year));
179
+ const dir = findCards();
152
180
  const minutes = values.minutes ? Number(values.minutes) : 15;
153
181
  if (!(minutes > 0 && minutes <= 120))
154
182
  throw new Error("--minutes must be between 1 and 120");
@@ -190,7 +218,6 @@ async function main(argv) {
190
218
  return;
191
219
  }
192
220
  case "publish": {
193
- const dir = values.out ?? path.join(wraptHome(), String(year));
194
221
  const branch = values.branch ?? "gh-pages";
195
222
  if (!values.repo && !values["dry-run"])
196
223
  throw new Error("Pass --repo <owner/name> (an existing GitHub repo you can push to), or --dry-run.");
@@ -214,13 +241,15 @@ async function main(argv) {
214
241
  process.stdout.write(changed ? ` Removed ${target.pageUrl}\n` : ` Nothing to remove for ${year}.\n`);
215
242
  return;
216
243
  }
217
- const statsPath = path.join(dir, "stats.json");
244
+ const dir = findCards();
245
+ const statsPath = path.join(dataDir, "stats.json");
218
246
  if (!fs.existsSync(statsPath))
219
- throw new Error(`No ${statsPath}. Run \`wrapt analyze\` and \`wrapt render\` first.`);
247
+ throw new Error(`No stats for ${year} yet. Run \`${next("analyze")}\` and \`${next("render")}\` first.`);
220
248
  const stats = StatsSchema.parse(JSON.parse(fs.readFileSync(statsPath, "utf8")));
221
249
  const renderInfo = (() => {
222
250
  try {
223
- return JSON.parse(fs.readFileSync(path.join(dir, "render.json"), "utf8"));
251
+ const info = [dataDir, dir].map((d) => path.join(d, "render.json")).find((f) => fs.existsSync(f)) ?? "";
252
+ return JSON.parse(fs.readFileSync(info, "utf8"));
224
253
  }
225
254
  catch {
226
255
  return {};
@@ -239,13 +268,20 @@ async function main(argv) {
239
268
  }
240
269
  process.stdout.write(L.join("\n") + "\n");
241
270
  if (values["dry-run"]) {
242
- process.stdout.write(`\n Dry run: nothing uploaded. Open ${path.join(siteDir, "index.html")} to preview.\n`);
271
+ process.stdout.write(`\n Dry run: nothing uploaded. Open ${path.join(siteDir, "index.html")} to preview (a temporary copy).\n`);
243
272
  return;
244
273
  }
274
+ const cleanup = () => fs.rmSync(siteDir, { recursive: true, force: true });
245
275
  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`);
246
- if (!(await confirm(" Publish? [y/N] ")))
247
- return void process.stdout.write(" Cancelled. Nothing was uploaded.\n");
248
- const changed = pushSite({ remote: target.remote, branch, year, siteDir, message: `wrapt: publish ${year} cards` });
276
+ let changed;
277
+ try {
278
+ if (!(await confirm(" Publish? [y/N] ")))
279
+ return void process.stdout.write(" Cancelled. Nothing was uploaded.\n");
280
+ changed = pushSite({ remote: target.remote, branch, year, siteDir, message: `wrapt: publish ${year} cards` });
281
+ }
282
+ finally {
283
+ cleanup();
284
+ }
249
285
  process.stdout.write([
250
286
  "",
251
287
  changed ? ` ✓ Published → ${target.pageUrl}` : ` Already up to date → ${target.pageUrl}`,
@@ -256,13 +292,13 @@ async function main(argv) {
256
292
  return;
257
293
  }
258
294
  case "airdrop": {
259
- const dir = values.out ?? path.join(wraptHome(), String(year));
260
295
  const set = values.set ?? "story";
261
296
  if (!["story", "carousel", "all"].includes(set))
262
297
  throw new Error("--set must be story, carousel or all");
263
298
  if (process.platform !== "darwin") {
264
299
  throw new Error("AirDrop needs a Mac. Use `wrapt share` instead: it shows a QR code to open the cards on your phone.");
265
300
  }
301
+ const dir = findCards();
266
302
  const assets = collectAssets(dir);
267
303
  const rels = set === "story" ? assets.story : set === "carousel" ? assets.carousel : [...assets.story, ...assets.carousel, ...(assets.xCard ? [assets.xCard] : [])];
268
304
  if (!rels.length)
@@ -288,16 +324,16 @@ async function main(argv) {
288
324
  return;
289
325
  }
290
326
  case "open": {
291
- const dir = values.out ?? path.join(wraptHome(), String(year));
292
327
  const set = values.set;
293
328
  if (set && !["story", "carousel"].includes(set))
294
329
  throw new Error("--set must be story or carousel");
330
+ const dir = findCards();
295
331
  const target = set ? path.join(dir, set) : dir;
296
332
  if (!fs.existsSync(target))
297
- throw new Error(`No cards in ${tildify(dir)} yet. Run \`${next("render")}\` first.`);
333
+ throw new Error(`No ${set} cards in ${shown(dir)}. Run \`${next("render")}\` first.`);
298
334
  const opened = await openFolder(target);
299
335
  process.stdout.write(opened
300
- ? ` Opened ${tildify(target)}\n`
336
+ ? ` Opened ${shown(target)}\n`
301
337
  : ` Couldn't open a file browser here. Your cards are in:\n ${target}\n`);
302
338
  return;
303
339
  }
package/dist/format.js CHANGED
@@ -79,7 +79,8 @@ export function summary(s, paths) {
79
79
  const excluded = Object.values(p.excludedUser).reduce((a, b) => a + b, 0);
80
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
81
  L.push(dim(` → ${paths.stats}`));
82
- L.push(dim(` → ${paths.samples} (private, stays on this machine)`));
82
+ if (paths.samples)
83
+ L.push(dim(` → ${paths.samples} (private, stays on this machine)`));
83
84
  L.push("");
84
85
  return L.join("\n");
85
86
  }
package/dist/publish.js CHANGED
@@ -42,8 +42,8 @@ export function buildSite(o) {
42
42
  const assets = collectAssets(o.dir);
43
43
  if (!assets.story.length || !assets.xCard)
44
44
  throw new Error(`No rendered cards in ${o.dir}. Run \`wrapt render\` first.`);
45
- const siteDir = path.join(o.dir, "site");
46
- fs.rmSync(siteDir, { recursive: true, force: true });
45
+ // Built in a temporary folder, never next to the cards, so no copy is left behind after publishing.
46
+ const siteDir = fs.mkdtempSync(path.join(os.tmpdir(), "wrapt-site-"));
47
47
  const files = [];
48
48
  const copy = (rel, from = path.join(o.dir, rel)) => {
49
49
  fs.mkdirSync(path.dirname(path.join(siteDir, rel)), { recursive: true });
@@ -54,7 +54,8 @@ export async function renderAll(opts) {
54
54
  fs.writeFileSync(out.xCard, await toPng(Outro(ctxFor(SIZES.x, CARDS.length - 1)), SIZES.x));
55
55
  fs.writeFileSync(out.pdf, await carouselPdf(carouselPngs, opts.stats.year, brandFor(opts.stats).long));
56
56
  // Remember how the cards were made, so `wrapt publish` can warn before project names go public.
57
- fs.writeFileSync(path.join(opts.outDir, "render.json"), JSON.stringify({ name: opts.name ?? null, hideProjects: opts.hideProjects ?? true, theme: opts.theme ?? "bold", renderedAt: new Date().toISOString() }, null, 2) + "\n");
57
+ fs.writeFileSync(path.join(opts.infoDir ?? opts.outDir, "render.json"), JSON.stringify({ name: opts.name ?? null, hideProjects: opts.hideProjects ?? true, theme: opts.theme ?? "bold", renderedAt: new Date().toISOString() }, null, 2) + "\n", { mode: 0o600 });
58
+ fs.chmodSync(path.join(opts.infoDir ?? opts.outDir, "render.json"), 0o600); // also when the file already existed
58
59
  return out;
59
60
  }
60
61
  /** One carousel card per page at its pixel size — LinkedIn renders PDFs as swipeable documents. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wrapt-cli",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Your year with Claude Code and GitHub Copilot, wrapped. Share cards made on your own computer.",
5
5
  "license": "MIT",
6
6
  "type": "module",