claudekit-cli 3.41.0-dev.1 → 3.41.0-dev.2

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 (2) hide show
  1. package/dist/index.js +62 -32
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -57633,7 +57633,7 @@ var package_default;
57633
57633
  var init_package = __esm(() => {
57634
57634
  package_default = {
57635
57635
  name: "claudekit-cli",
57636
- version: "3.41.0-dev.1",
57636
+ version: "3.41.0-dev.2",
57637
57637
  description: "CLI tool for bootstrapping and updating ClaudeKit projects",
57638
57638
  type: "module",
57639
57639
  repository: {
@@ -68344,7 +68344,7 @@ var init_content_validator = __esm(() => {
68344
68344
  import { createHash as createHash6 } from "node:crypto";
68345
68345
  import { existsSync as existsSync66, mkdirSync as mkdirSync4, readFileSync as readFileSync15, readdirSync as readdirSync8, statSync as statSync10 } from "node:fs";
68346
68346
  import { rename as rename9, writeFile as writeFile35 } from "node:fs/promises";
68347
- import { homedir as homedir34 } from "node:os";
68347
+ import { homedir as homedir33 } from "node:os";
68348
68348
  import { basename as basename19, join as join132 } from "node:path";
68349
68349
  function getCachedContext(repoPath) {
68350
68350
  const cachePath = getCacheFilePath(repoPath);
@@ -68419,7 +68419,7 @@ function getCacheFilePath(repoPath) {
68419
68419
  }
68420
68420
  var CACHE_DIR, CACHE_TTL_MS4;
68421
68421
  var init_context_cache_manager = __esm(() => {
68422
- CACHE_DIR = join132(homedir34(), ".claudekit", "cache");
68422
+ CACHE_DIR = join132(homedir33(), ".claudekit", "cache");
68423
68423
  CACHE_TTL_MS4 = 24 * 60 * 60 * 1000;
68424
68424
  });
68425
68425
 
@@ -68873,10 +68873,10 @@ IMPORTANT: Generate the image and output the path as JSON: {"imagePath": "/path/
68873
68873
  // src/commands/content/phases/photo-generator.ts
68874
68874
  import { execSync as execSync7 } from "node:child_process";
68875
68875
  import { existsSync as existsSync68, mkdirSync as mkdirSync5, readdirSync as readdirSync10 } from "node:fs";
68876
- import { homedir as homedir35 } from "node:os";
68876
+ import { homedir as homedir34 } from "node:os";
68877
68877
  import { join as join134 } from "node:path";
68878
68878
  async function generatePhoto(_content, context, config, platform14, contentId, contentLogger) {
68879
- const mediaDir = join134(config.contentDir.replace(/^~/, homedir35()), "media", String(contentId));
68879
+ const mediaDir = join134(config.contentDir.replace(/^~/, homedir34()), "media", String(contentId));
68880
68880
  if (!existsSync68(mediaDir)) {
68881
68881
  mkdirSync5(mediaDir, { recursive: true });
68882
68882
  }
@@ -68990,7 +68990,7 @@ var init_content_creator = __esm(() => {
68990
68990
 
68991
68991
  // src/commands/content/phases/content-logger.ts
68992
68992
  import { createWriteStream as createWriteStream4, existsSync as existsSync69, mkdirSync as mkdirSync6, statSync as statSync11 } from "node:fs";
68993
- import { homedir as homedir36 } from "node:os";
68993
+ import { homedir as homedir35 } from "node:os";
68994
68994
  import { join as join135 } from "node:path";
68995
68995
 
68996
68996
  class ContentLogger {
@@ -68999,7 +68999,7 @@ class ContentLogger {
68999
68999
  logDir;
69000
69000
  maxBytes;
69001
69001
  constructor(maxBytes = 0) {
69002
- this.logDir = join135(homedir36(), ".claudekit", "logs");
69002
+ this.logDir = join135(homedir35(), ".claudekit", "logs");
69003
69003
  this.maxBytes = maxBytes;
69004
69004
  }
69005
69005
  init() {
@@ -70598,11 +70598,11 @@ var init_setup_wizard = __esm(() => {
70598
70598
 
70599
70599
  // src/commands/content/content-review-commands.ts
70600
70600
  import { existsSync as existsSync73 } from "node:fs";
70601
- import { homedir as homedir37 } from "node:os";
70601
+ import { homedir as homedir36 } from "node:os";
70602
70602
  async function queueContent() {
70603
70603
  const cwd2 = process.cwd();
70604
70604
  const config = await loadContentConfig(cwd2);
70605
- const dbPath = config.dbPath.replace(/^~/, homedir37());
70605
+ const dbPath = config.dbPath.replace(/^~/, homedir36());
70606
70606
  if (!existsSync73(dbPath)) {
70607
70607
  logger.info("No content database found. Run 'ck content setup' first.");
70608
70608
  return;
@@ -70629,7 +70629,7 @@ async function queueContent() {
70629
70629
  async function approveContentCmd(id) {
70630
70630
  const cwd2 = process.cwd();
70631
70631
  const config = await loadContentConfig(cwd2);
70632
- const dbPath = config.dbPath.replace(/^~/, homedir37());
70632
+ const dbPath = config.dbPath.replace(/^~/, homedir36());
70633
70633
  const db = initDatabase(dbPath);
70634
70634
  try {
70635
70635
  approveContent(db, Number.parseInt(id, 10));
@@ -70641,7 +70641,7 @@ async function approveContentCmd(id) {
70641
70641
  async function rejectContentCmd(id, reason) {
70642
70642
  const cwd2 = process.cwd();
70643
70643
  const config = await loadContentConfig(cwd2);
70644
- const dbPath = config.dbPath.replace(/^~/, homedir37());
70644
+ const dbPath = config.dbPath.replace(/^~/, homedir36());
70645
70645
  const db = initDatabase(dbPath);
70646
70646
  try {
70647
70647
  rejectContent(db, Number.parseInt(id, 10), reason);
@@ -70672,7 +70672,7 @@ __export(exports_content_subcommands, {
70672
70672
  approveContentCmd: () => approveContentCmd
70673
70673
  });
70674
70674
  import { existsSync as existsSync74, readFileSync as readFileSync18, unlinkSync as unlinkSync5 } from "node:fs";
70675
- import { homedir as homedir38 } from "node:os";
70675
+ import { homedir as homedir37 } from "node:os";
70676
70676
  import { join as join140 } from "node:path";
70677
70677
  function isDaemonRunning() {
70678
70678
  const lockFile = join140(LOCK_DIR, `${LOCK_NAME2}.lock`);
@@ -70746,7 +70746,7 @@ async function statusContent() {
70746
70746
  } catch {}
70747
70747
  }
70748
70748
  async function logsContent(options2) {
70749
- const logDir = join140(homedir38(), ".claudekit", "logs");
70749
+ const logDir = join140(homedir37(), ".claudekit", "logs");
70750
70750
  const dateStr = new Date().toISOString().slice(0, 10).replace(/-/g, "");
70751
70751
  const logPath = join140(logDir, `content-${dateStr}.log`);
70752
70752
  if (!existsSync74(logPath)) {
@@ -70780,12 +70780,12 @@ var init_content_subcommands = __esm(() => {
70780
70780
  init_setup_wizard();
70781
70781
  init_state_manager();
70782
70782
  init_content_review_commands();
70783
- LOCK_DIR = join140(homedir38(), ".claudekit", "locks");
70783
+ LOCK_DIR = join140(homedir37(), ".claudekit", "locks");
70784
70784
  });
70785
70785
 
70786
70786
  // src/commands/content/content-command.ts
70787
70787
  import { existsSync as existsSync75, mkdirSync as mkdirSync8, unlinkSync as unlinkSync6, writeFileSync as writeFileSync6 } from "node:fs";
70788
- import { homedir as homedir39 } from "node:os";
70788
+ import { homedir as homedir38 } from "node:os";
70789
70789
  import { join as join141 } from "node:path";
70790
70790
  async function contentCommand(options2) {
70791
70791
  const cwd2 = process.cwd();
@@ -70818,7 +70818,7 @@ async function contentCommand(options2) {
70818
70818
  if (!existsSync75(LOCK_DIR2))
70819
70819
  mkdirSync8(LOCK_DIR2, { recursive: true });
70820
70820
  writeFileSync6(LOCK_FILE, String(process.pid), "utf-8");
70821
- const dbPath = config.dbPath.replace(/^~/, homedir39());
70821
+ const dbPath = config.dbPath.replace(/^~/, homedir38());
70822
70822
  const db = initDatabase(dbPath);
70823
70823
  contentLogger.info(`Database initialised at ${dbPath}`);
70824
70824
  const adapters = initializeAdapters(config);
@@ -70964,7 +70964,7 @@ var init_content_command = __esm(() => {
70964
70964
  init_publisher();
70965
70965
  init_review_manager();
70966
70966
  init_state_manager();
70967
- LOCK_DIR2 = join141(homedir39(), ".claudekit", "locks");
70967
+ LOCK_DIR2 = join141(homedir38(), ".claudekit", "locks");
70968
70968
  LOCK_FILE = join141(LOCK_DIR2, "ck-content.lock");
70969
70969
  });
70970
70970
 
@@ -82793,9 +82793,9 @@ var import_proper_lockfile4 = __toESM(require_proper_lockfile(), 1);
82793
82793
  import { mkdir as mkdir19 } from "node:fs/promises";
82794
82794
  import os5 from "node:os";
82795
82795
  import { join as join75 } from "node:path";
82796
- var LOCK_CONFIG = {
82797
- stale: 60000,
82798
- retries: 0
82796
+ var LOCK_CONFIGS = {
82797
+ short: { stale: 60000, retries: 0 },
82798
+ long: { stale: 300000, retries: 0 }
82799
82799
  };
82800
82800
  var activeLocks = new Set;
82801
82801
  var cleanupRegistered = false;
@@ -82805,8 +82805,7 @@ function getLocksDir() {
82805
82805
  function cleanupLocks() {
82806
82806
  for (const name of activeLocks) {
82807
82807
  try {
82808
- const lockPath = join75(getLocksDir(), `${name}.lock`);
82809
- import_proper_lockfile4.default.unlockSync(lockPath, { realpath: false });
82808
+ import_proper_lockfile4.default.unlockSync(getLockPaths(name).resource, { realpath: false });
82810
82809
  } catch {
82811
82810
  try {
82812
82811
  logger.verbose(`Failed to cleanup lock: ${name}`);
@@ -82825,13 +82824,24 @@ async function ensureLocksDir() {
82825
82824
  const lockDir = getLocksDir();
82826
82825
  await mkdir19(lockDir, { recursive: true });
82827
82826
  }
82828
- async function withProcessLock(lockName, fn) {
82827
+ function getLockPaths(lockName) {
82828
+ const resource = join75(getLocksDir(), `${lockName}.lock`);
82829
+ return { resource, lockfile: `${resource}.lock` };
82830
+ }
82831
+ async function withProcessLock(lockName, fn, duration = "short") {
82829
82832
  registerCleanupHandlers();
82830
82833
  await ensureLocksDir();
82831
- const lockPath = join75(getLocksDir(), `${lockName}.lock`);
82834
+ const { resource: lockPath } = getLockPaths(lockName);
82835
+ const config = LOCK_CONFIGS[duration];
82832
82836
  let release;
82833
82837
  try {
82834
- release = await import_proper_lockfile4.default.lock(lockPath, { ...LOCK_CONFIG, realpath: false });
82838
+ release = await import_proper_lockfile4.default.lock(lockPath, {
82839
+ ...config,
82840
+ realpath: false,
82841
+ onCompromised: duration === "long" ? (err) => {
82842
+ logger.warning(`Lock "${lockName}" compromised: ${err.message}. Continuing...`);
82843
+ } : undefined
82844
+ });
82835
82845
  activeLocks.add(lockName);
82836
82846
  return await fn();
82837
82847
  } catch (e2) {
@@ -82841,11 +82851,24 @@ async function withProcessLock(lockName, fn) {
82841
82851
 
82842
82852
  Operation: ${lockName}
82843
82853
  Wait for it to complete or remove lock: ${lockPath}`);
82854
+ }
82855
+ if (error.code === "ECOMPROMISED") {
82856
+ throw new Error(`Lock was compromised (stale or externally removed).
82857
+
82858
+ Operation: ${lockName}
82859
+ Use --force to clear and restart.`);
82844
82860
  }
82845
82861
  throw e2;
82846
82862
  } finally {
82847
82863
  if (release) {
82848
- await release();
82864
+ try {
82865
+ await release();
82866
+ } catch (releaseErr) {
82867
+ const code = releaseErr.code;
82868
+ if (code !== "ERELEASED") {
82869
+ logger.warning(`Failed to release lock "${lockName}": ${releaseErr.message}`);
82870
+ }
82871
+ }
82849
82872
  }
82850
82873
  activeLocks.delete(lockName);
82851
82874
  }
@@ -101685,7 +101708,6 @@ ${import_picocolors38.default.bold(import_picocolors38.default.cyan(result.kitCo
101685
101708
  init_logger();
101686
101709
  import { existsSync as existsSync65 } from "node:fs";
101687
101710
  import { rm as rm16 } from "node:fs/promises";
101688
- import { homedir as homedir33 } from "node:os";
101689
101711
  import { join as join131 } from "node:path";
101690
101712
  var import_picocolors39 = __toESM(require_picocolors(), 1);
101691
101713
 
@@ -102237,6 +102259,9 @@ async function invokeClaude(options2) {
102237
102259
  "--allowedTools",
102238
102260
  tools
102239
102261
  ];
102262
+ if (outputFormat === "stream-json") {
102263
+ args.push("--verbose");
102264
+ }
102240
102265
  const child = spawn10("claude", args, {
102241
102266
  cwd: options2.cwd,
102242
102267
  stdio: ["pipe", "pipe", "pipe"],
@@ -102282,7 +102307,7 @@ function collectClaudeOutput(child, timeoutSec, verbose = false) {
102282
102307
  });
102283
102308
  }
102284
102309
  function logStreamEvent(chunk) {
102285
- for (const line of chunk.split(`
102310
+ for (const line of chunk.replace(/\r/g, "").split(`
102286
102311
  `).filter(Boolean)) {
102287
102312
  try {
102288
102313
  const event = JSON.parse(line);
@@ -102310,7 +102335,7 @@ function logStreamEvent(chunk) {
102310
102335
  }
102311
102336
  }
102312
102337
  function parseStreamJsonOutput(stdout2) {
102313
- const lines = stdout2.split(`
102338
+ const lines = stdout2.replace(/\r/g, "").split(`
102314
102339
  `).filter(Boolean);
102315
102340
  for (let i = lines.length - 1;i >= 0; i--) {
102316
102341
  try {
@@ -103410,11 +103435,13 @@ async function watchCommand(options2) {
103410
103435
  process.removeListener("SIGINT", shutdown);
103411
103436
  process.removeListener("SIGTERM", shutdown);
103412
103437
  }
103413
- });
103438
+ }, "long");
103414
103439
  } catch (error) {
103415
103440
  const err = error;
103416
103441
  if (err.message?.includes("Another ClaudeKit process")) {
103417
103442
  logger.error("Another ck watch instance is already running. Use --force to override.");
103443
+ } else if (err.message?.includes("Lock was compromised")) {
103444
+ logger.error("Lock was compromised (stale or externally removed). Use --force to restart.");
103418
103445
  } else {
103419
103446
  watchLog.error("Watch command failed", err);
103420
103447
  console.error(`[ck watch] Fatal: ${err.message}`);
@@ -103497,9 +103524,12 @@ async function resetState(state, projectDir, watchLog) {
103497
103524
  watchLog.info(`Watch state reset (--force) for ${projectDir}`);
103498
103525
  }
103499
103526
  async function forceRemoveLock(watchLog) {
103500
- const lockPath = join131(homedir33(), ".claudekit", "locks", `${LOCK_NAME}.lock`);
103527
+ const { resource, lockfile: lockfile5 } = getLockPaths(LOCK_NAME);
103501
103528
  try {
103502
- await rm16(lockPath, { recursive: true, force: true });
103529
+ await Promise.all([
103530
+ rm16(resource, { recursive: true, force: true }),
103531
+ rm16(lockfile5, { recursive: true, force: true })
103532
+ ]);
103503
103533
  watchLog.info("Removed existing lock file (--force)");
103504
103534
  } catch {}
103505
103535
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claudekit-cli",
3
- "version": "3.41.0-dev.1",
3
+ "version": "3.41.0-dev.2",
4
4
  "description": "CLI tool for bootstrapping and updating ClaudeKit projects",
5
5
  "type": "module",
6
6
  "repository": {