skillwiki 0.2.0-beta.25 → 0.2.0-beta.26

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/dist/cli.js CHANGED
@@ -2337,6 +2337,71 @@ ${migratedBody}${newFooter}`;
2337
2337
  };
2338
2338
  }
2339
2339
 
2340
+ // src/commands/frontmatter-fix.ts
2341
+ import { writeFile as writeFile8 } from "fs/promises";
2342
+ function isoToday() {
2343
+ return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
2344
+ }
2345
+ function fixFrontmatter(rawFm) {
2346
+ const additions = [];
2347
+ if (!/^created:/m.test(rawFm)) additions.push(`created: ${isoToday()}`);
2348
+ if (!/^updated:/m.test(rawFm)) additions.push(`updated: ${isoToday()}`);
2349
+ if (!/^tags:/m.test(rawFm)) additions.push("tags: []");
2350
+ if (!/^sources:/m.test(rawFm)) additions.push("sources: []");
2351
+ if (!/^provenance:/m.test(rawFm)) additions.push("provenance: research");
2352
+ if (additions.length === 0) return rawFm;
2353
+ return rawFm.trimEnd() + "\n" + additions.join("\n") + "\n";
2354
+ }
2355
+ function removeOrphanTagsLines(body) {
2356
+ return body.split("\n").filter((line) => !/^tags:\s*\[/.test(line.trim())).join("\n");
2357
+ }
2358
+ async function runFrontmatterFix(input) {
2359
+ const scan = await scanVault(input.vault);
2360
+ if (!scan.ok) return { exitCode: ExitCode.VAULT_PATH_INVALID, result: scan };
2361
+ const fixed = [];
2362
+ const skipped = [];
2363
+ let unchanged = 0;
2364
+ for (const page of scan.data.typedKnowledge) {
2365
+ const text = await readPage(page);
2366
+ const split = splitFrontmatter(text);
2367
+ if (!split.ok) {
2368
+ skipped.push(page.relPath);
2369
+ continue;
2370
+ }
2371
+ const { rawFrontmatter, body } = split.data;
2372
+ const newFm = fixFrontmatter(rawFrontmatter);
2373
+ const newBody = removeOrphanTagsLines(body);
2374
+ const newText = `---
2375
+ ${newFm}
2376
+ ---
2377
+ ${newBody}`;
2378
+ if (newText === text) {
2379
+ unchanged++;
2380
+ continue;
2381
+ }
2382
+ if (!input.dryRun) {
2383
+ await writeFile8(page.absPath, newText, "utf8");
2384
+ }
2385
+ fixed.push(page.relPath);
2386
+ }
2387
+ const exitCode = fixed.length > 0 ? ExitCode.MIGRATION_APPLIED : ExitCode.OK;
2388
+ const hintLines = [`scanned: ${fixed.length + skipped.length + unchanged}`];
2389
+ if (fixed.length > 0) hintLines.push(`fixed: ${fixed.length}`);
2390
+ if (skipped.length > 0) hintLines.push(`skipped (parse error): ${skipped.length}`);
2391
+ if (unchanged > 0) hintLines.push(`unchanged: ${unchanged}`);
2392
+ if (input.dryRun && fixed.length > 0) hintLines.push("(dry run \u2014 no files written)");
2393
+ return {
2394
+ exitCode,
2395
+ result: ok({
2396
+ scanned: fixed.length + skipped.length + unchanged,
2397
+ fixed,
2398
+ skipped,
2399
+ unchanged,
2400
+ humanHint: hintLines.join("\n")
2401
+ })
2402
+ };
2403
+ }
2404
+
2340
2405
  // src/commands/update.ts
2341
2406
  import { execSync as execSync2 } from "child_process";
2342
2407
  import { readFileSync as readFileSync3 } from "fs";
@@ -2548,6 +2613,11 @@ program.command("migrate-citations [vault]").description("migrate ^[raw/...] mar
2548
2613
  if (!v.ok) emit({ exitCode: v.exitCode, result: v.payload });
2549
2614
  else emit(await runMigrateCitations({ vault: v.vault, dryRun: !!opts.dryRun }));
2550
2615
  });
2616
+ program.command("frontmatter-fix [vault]").description("fix common frontmatter issues on typed-knowledge pages").option("--dry-run", "preview changes without writing", false).option("--wiki <name>", "wiki profile name").action(async (vault, opts) => {
2617
+ const v = await resolveVaultArg(vault, opts.wiki);
2618
+ if (!v.ok) emit({ exitCode: v.exitCode, result: v.payload });
2619
+ else emit(await runFrontmatterFix({ vault: v.vault, dryRun: !!opts.dryRun }));
2620
+ });
2551
2621
  program.command("update").description("update skillwiki CLI to the latest version").option("--tag <tag>", "npm dist-tag", "beta").action(async (opts) => emit(await runUpdate({
2552
2622
  home: process.env.HOME ?? "",
2553
2623
  distTag: opts.tag
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skillwiki",
3
- "version": "0.2.0-beta.25",
3
+ "version": "0.2.0-beta.26",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "skillwiki": "dist/cli.js"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skillwiki",
3
- "version": "0.2.0-beta.25",
3
+ "version": "0.2.0-beta.26",
4
4
  "skills": "./",
5
5
  "description": "Project-aware Karpathy-style knowledge base for Claude Code: 11 prompt-only skills (wiki-*, proj-*, using-skillwiki) backed by the deterministic `skillwiki` CLI (8 subcommands, JSON-by-default).",
6
6
  "author": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skillwiki/skills",
3
- "version": "0.2.0-beta.25",
3
+ "version": "0.2.0-beta.26",
4
4
  "private": true,
5
5
  "files": [
6
6
  "wiki-*",