@vladar107/claudescope 0.4.1 → 0.4.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 (3) hide show
  1. package/cli.js +1 -1
  2. package/package.json +1 -1
  3. package/server.js +80 -80
package/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __cr } from 'node:module';
3
3
  const require = __cr(import.meta.url);
4
- import{spawn as T,spawnSync as b}from"node:child_process";import{existsSync as D,mkdirSync as $,openSync as F,readFileSync as I,realpathSync as J,rmSync as y,writeFileSync as U}from"node:fs";import{dirname as V,join as h}from"node:path";import{createInterface as G}from"node:readline/promises";import{parseArgs as W}from"node:util";import{fileURLToPath as K}from"node:url";import{copyFileSync as ie,existsSync as H,mkdirSync as ae}from"node:fs";import{homedir as l}from"node:os";import{dirname as M,join as s}from"node:path";import{fileURLToPath as B}from"node:url";var v=M(B(import.meta.url));function x(e,o){return e.find(t=>H(t))??o}var E=Number(process.env.PORT??4317),f=s(v,"..");function m(e){return e==="~"?l():e.startsWith("~/")?s(l(),e.slice(2)):e}var w=m(process.env.CLAUDE_PROJECTS_DIR??s(l(),".claude","projects")),ue=m(process.env.CODEX_SESSIONS_DIR??s(l(),".codex","sessions")),de=m(process.env.JUNIE_SESSIONS_DIR??s(l(),".junie","sessions")),fe=process.env.OPEN_BROWSER==="1",me=Number(process.env.REINDEX_INTERVAL_MS??15e3),a=m(process.env.CLAUDESCOPE_HOME??s(l(),".claudescope")),ge=process.env.DUCKDB_PATH??s(a,"index.duckdb"),he=x([s(v,"pricing.default.json"),s(f,"pricing.json")],s(f,"pricing.json")),Se=process.env.PRICING_PATH??s(a,"pricing.json"),ve=process.env.WEB_DIST_DIR??x([s(v,"web"),s(f,"..","web","dist")],s(f,"..","web","dist")),i="0.4.1";var P=V(K(import.meta.url)),X=h(P,"server.js"),p=h(a,"daemon.json"),g=h(a,"daemon.log"),_=h(a,"update-check.json"),u="@vladar107/claudescope",q=24*60*60*1e3;function S(){if(!D(p))return null;try{return JSON.parse(I(p,"utf8"))}catch{return null}}function d(e){try{return process.kill(e,0),!0}catch{return!1}}async function C(e){try{return(await fetch(`http://127.0.0.1:${e}/api/health`,{signal:AbortSignal.timeout(1500)})).ok}catch{return!1}}async function Y(e,o){let t=Date.now()+o;for(;Date.now()<t;){if(await C(e))return!0;process.stdout.write("."),await new Promise(r=>setTimeout(r,500))}return!1}function R(e){let o=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";try{T(o,[e],{stdio:"ignore",detached:!0,shell:process.platform==="win32"}).unref()}catch{}}async function N(e,o){$(a,{recursive:!0});let t=S();if(t&&d(t.pid)&&await C(t.port)){console.log(`\u2713 claudescope is already running \u2192 ${t.url}`),o&&R(t.url);return}t&&!d(t.pid)&&y(p,{force:!0});let r=`http://localhost:${e}`,n=F(g,"a"),c=T(process.execPath,[X],{detached:!0,stdio:["ignore",n,n],env:{...process.env,PORT:String(e),OPEN_BROWSER:"0"}});if(c.unref(),U(p,JSON.stringify({pid:c.pid,port:e,url:r,version:i,startedAt:new Date().toISOString()},null,2)),process.stdout.write("\u203A Starting claudescope"),!await Y(e,2e4)){console.error(`
4
+ import{spawn as T,spawnSync as b}from"node:child_process";import{existsSync as D,mkdirSync as $,openSync as F,readFileSync as I,realpathSync as J,rmSync as y,writeFileSync as U}from"node:fs";import{dirname as V,join as h}from"node:path";import{createInterface as G}from"node:readline/promises";import{parseArgs as W}from"node:util";import{fileURLToPath as K}from"node:url";import{copyFileSync as ie,existsSync as H,mkdirSync as ae}from"node:fs";import{homedir as l}from"node:os";import{dirname as M,join as s}from"node:path";import{fileURLToPath as B}from"node:url";var v=M(B(import.meta.url));function x(e,o){return e.find(t=>H(t))??o}var E=Number(process.env.PORT??4317),f=s(v,"..");function m(e){return e==="~"?l():e.startsWith("~/")?s(l(),e.slice(2)):e}var w=m(process.env.CLAUDE_PROJECTS_DIR??s(l(),".claude","projects")),ue=m(process.env.CODEX_SESSIONS_DIR??s(l(),".codex","sessions")),de=m(process.env.JUNIE_SESSIONS_DIR??s(l(),".junie","sessions")),fe=process.env.OPEN_BROWSER==="1",me=Number(process.env.REINDEX_INTERVAL_MS??15e3),a=m(process.env.CLAUDESCOPE_HOME??s(l(),".claudescope")),ge=process.env.DUCKDB_PATH??s(a,"index.duckdb"),he=x([s(v,"pricing.default.json"),s(f,"pricing.json")],s(f,"pricing.json")),Se=process.env.PRICING_PATH??s(a,"pricing.json"),ve=process.env.WEB_DIST_DIR??x([s(v,"web"),s(f,"..","web","dist")],s(f,"..","web","dist")),i="0.4.2";var P=V(K(import.meta.url)),X=h(P,"server.js"),p=h(a,"daemon.json"),g=h(a,"daemon.log"),_=h(a,"update-check.json"),u="@vladar107/claudescope",q=24*60*60*1e3;function S(){if(!D(p))return null;try{return JSON.parse(I(p,"utf8"))}catch{return null}}function d(e){try{return process.kill(e,0),!0}catch{return!1}}async function C(e){try{return(await fetch(`http://127.0.0.1:${e}/api/health`,{signal:AbortSignal.timeout(1500)})).ok}catch{return!1}}async function Y(e,o){let t=Date.now()+o;for(;Date.now()<t;){if(await C(e))return!0;process.stdout.write("."),await new Promise(r=>setTimeout(r,500))}return!1}function R(e){let o=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";try{T(o,[e],{stdio:"ignore",detached:!0,shell:process.platform==="win32"}).unref()}catch{}}async function N(e,o){$(a,{recursive:!0});let t=S();if(t&&d(t.pid)&&await C(t.port)){console.log(`\u2713 claudescope is already running \u2192 ${t.url}`),o&&R(t.url);return}t&&!d(t.pid)&&y(p,{force:!0});let r=`http://localhost:${e}`,n=F(g,"a"),c=T(process.execPath,[X],{detached:!0,stdio:["ignore",n,n],env:{...process.env,PORT:String(e),OPEN_BROWSER:"0"}});if(c.unref(),U(p,JSON.stringify({pid:c.pid,port:e,url:r,version:i,startedAt:new Date().toISOString()},null,2)),process.stdout.write("\u203A Starting claudescope"),!await Y(e,2e4)){console.error(`
5
5
  \u2717 Server did not become healthy in time. Inspect: claudescope logs`),process.exitCode=1;return}console.log(`
6
6
  \u2713 claudescope running \u2192 ${r}`),console.log(` Sessions: ${w} (read-only)`),o&&R(r),await j(!1)}function O(){let e=S();if(!e||!d(e.pid)){console.log("claudescope is not running."),y(p,{force:!0});return}try{process.kill(e.pid,"SIGTERM")}catch{}y(p,{force:!0}),console.log(`\u2713 Stopped claudescope (pid ${e.pid}).`)}async function z(){let e=S();e&&d(e.pid)&&await C(e.port)?console.log(`\u25CF running ${e.url} (pid ${e.pid}, v${e.version})`):console.log(`\u25CB stopped (installed v${i})`),await j(!0)}function Q(){let e=S();e&&d(e.pid)?R(e.url):console.log("claudescope is not running. Start it with: claudescope start")}function Z(e){if(!D(g)){console.log("No logs yet.");return}e&&process.platform!=="win32"?b("tail",["-f",g],{stdio:"inherit"}):process.stdout.write(I(g,"utf8"))}async function ee(e,o){if(!process.stdin.isTTY)return o;let t=G({input:process.stdin,output:process.stdout});try{let r=(await t.question(`${e} ${o?"[Y/n]":"[y/N]"} `)).trim().toLowerCase();return r?r==="y"||r==="yes":o}finally{t.close()}}function oe(){let e=P;try{e=J(P)}catch{}return e.includes("/nix/store/")?"nix":/[\\/]Cellar[\\/]claudescope[\\/]/.test(e)?"brew":"npm"}async function te(e){let o=await L(!0);if(o&&!k(o,i)){console.log(`\u2713 Already on the latest version (v${i}).`);return}let t=oe();if(t==="brew"){console.log("claudescope was installed via Homebrew."),console.log(" Run: brew upgrade vladar107/tap/claudescope");return}if(t==="nix"){console.log("claudescope was installed via Nix."),console.log(" Run: nix profile upgrade claudescope"),console.log(" (flake users: re-run `nix run --refresh github:vladar107/claudescope`)");return}o||console.log("\u26A0 Could not reach the npm registry to confirm the latest version.");let r=o?`v${i} \u2192 v${o}`:`v${i} \u2192 latest`;if(console.log(`\u203A Will run: npm install -g ${u}@latest (${r})`),!e&&!await ee("Proceed?",!0)){console.log("Aborted.");return}console.log(`\u203A Updating ${u}\u2026`);let n=process.platform==="win32"?"npm.cmd":"npm";if(b(n,["install","-g",`${u}@latest`],{stdio:"inherit"}).status!==0){console.error(`\u2717 Update failed. If you run via npx, just re-run \`npx ${u}\` to get the latest.`),process.exitCode=1;return}O(),console.log("\u2713 Updated. Restarting\u2026"),b("claudescope",["start"],{stdio:"inherit",shell:process.platform==="win32"})}function k(e,o){let t=e.split(".").map(n=>Number.parseInt(n,10)||0),r=o.split(".").map(n=>Number.parseInt(n,10)||0);for(let n=0;n<3;n++){if((t[n]??0)>(r[n]??0))return!0;if((t[n]??0)<(r[n]??0))return!1}return!1}async function L(e){let o=Date.now();if(!e&&D(_))try{let c=JSON.parse(I(_,"utf8"));if(o-c.lastCheck<q)return c.latest}catch{}let t=`https://registry.npmjs.org/${u.replace("/","%2f")}/latest`,r=await fetch(t,{signal:AbortSignal.timeout(2500)});if(!r.ok)return null;let n=await r.json();return n.version?($(a,{recursive:!0}),U(_,JSON.stringify({lastCheck:o,latest:n.version})),n.version):null}async function j(e){try{let o=await L(e);o&&k(o,i)&&console.log(`
7
7
  \u2B06 Update available: v${i} \u2192 v${o}. Run: claudescope update`)}catch{}}function A(){console.log(`claudescope v${i} \u2014 local viewer for Claude Code transcripts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vladar107/claudescope",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "Local, read-only web app to browse, read, search, and analyze your AI coding-agent transcripts — Claude Code, OpenAI Codex, and JetBrains Junie.",
5
5
  "keywords": [
6
6
  "claude",