codex-blocker 0.0.9 → 0.0.10-alpha.3

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
@@ -34,6 +34,9 @@ npx codex-blocker --remove
34
34
 
35
35
  # Show help
36
36
  npx codex-blocker --help
37
+
38
+ # Show version
39
+ npx codex-blocker --version
37
40
  ```
38
41
 
39
42
  ## How It Works
package/dist/bin.js CHANGED
@@ -2,9 +2,10 @@
2
2
  import {
3
3
  DEFAULT_PORT,
4
4
  startServer
5
- } from "./chunk-YPG2D6CV.js";
5
+ } from "./chunk-APDAIY47.js";
6
6
 
7
7
  // src/bin.ts
8
+ import { createRequire } from "module";
8
9
  import { createInterface } from "readline";
9
10
 
10
11
  // src/setup.ts
@@ -39,6 +40,8 @@ function removeCodexSetup() {
39
40
  }
40
41
 
41
42
  // src/bin.ts
43
+ var require2 = createRequire(import.meta.url);
44
+ var { version } = require2("../package.json");
42
45
  var args = process.argv.slice(2);
43
46
  function prompt(question) {
44
47
  const rl = createInterface({
@@ -63,6 +66,7 @@ Options:
63
66
  --setup Show Codex setup info
64
67
  --remove Remove Codex setup (no-op)
65
68
  --port Server port (default: ${DEFAULT_PORT})
69
+ --version Show version
66
70
  --help Show this help message
67
71
 
68
72
  Examples:
@@ -75,6 +79,10 @@ async function main() {
75
79
  printHelp();
76
80
  process.exit(0);
77
81
  }
82
+ if (args.includes("--version") || args.includes("-v")) {
83
+ console.log(version ?? "unknown");
84
+ process.exit(0);
85
+ }
78
86
  if (args.includes("--setup")) {
79
87
  setupCodex();
80
88
  process.exit(0);
@@ -222,8 +222,6 @@ function parseCodexLine(line, sessionId) {
222
222
 
223
223
  // src/codex.ts
224
224
  var DEFAULT_CODEX_HOME = join(homedir(), ".codex");
225
- var TAIL_MAX_BYTES = 1024 * 1024;
226
- var TAIL_MAX_LINES = 2e3;
227
225
  async function listRolloutFiles(root) {
228
226
  const files = [];
229
227
  const entries = await fs.readdir(root, { withFileTypes: true });
@@ -237,30 +235,6 @@ async function listRolloutFiles(root) {
237
235
  }
238
236
  return files;
239
237
  }
240
- async function readTailLines(filePath, fileSize, maxBytes, maxLines) {
241
- if (fileSize === 0) return [];
242
- const start = Math.max(0, fileSize - maxBytes);
243
- const end = Math.max(fileSize - 1, start);
244
- const chunks = [];
245
- await new Promise((resolve, reject) => {
246
- const stream = createReadStream(filePath, { start, end });
247
- stream.on("data", (chunk) => chunks.push(Buffer.from(chunk)));
248
- stream.on("error", reject);
249
- stream.on("end", resolve);
250
- });
251
- let content = Buffer.concat(chunks).toString("utf-8");
252
- let lines = content.split("\n");
253
- if (start > 0 && content[0] !== "\n") {
254
- lines = lines.slice(1);
255
- }
256
- if (lines.length > 0 && lines[lines.length - 1]?.trim() === "") {
257
- lines.pop();
258
- }
259
- if (lines.length > maxLines) {
260
- lines = lines.slice(-maxLines);
261
- }
262
- return lines.filter((line) => line.trim().length > 0);
263
- }
264
238
  async function readNewLines(filePath, fileState) {
265
239
  const stat = await fs.stat(filePath);
266
240
  if (stat.size < fileState.position) {
@@ -332,15 +306,6 @@ var CodexSessionWatcher = class {
332
306
  try {
333
307
  const stat = await fs.stat(filePath);
334
308
  fileState.position = stat.size;
335
- const tailLines = await readTailLines(
336
- filePath,
337
- stat.size,
338
- TAIL_MAX_BYTES,
339
- TAIL_MAX_LINES
340
- );
341
- if (tailLines.length > 0) {
342
- this.processLines(tailLines, fileState);
343
- }
344
309
  } catch {
345
310
  continue;
346
311
  }
@@ -353,25 +318,22 @@ var CodexSessionWatcher = class {
353
318
  continue;
354
319
  }
355
320
  if (newLines.length === 0) continue;
356
- this.processLines(newLines, fileState);
357
- }
358
- }
359
- processLines(lines, fileState) {
360
- for (const line of lines) {
361
- const parsed = parseCodexLine(line, fileState.sessionId);
362
- fileState.sessionId = parsed.sessionId;
363
- if (parsed.previousSessionId) {
364
- this.state.removeSession(parsed.previousSessionId);
365
- }
366
- this.state.markCodexSessionSeen(parsed.sessionId, parsed.cwd);
367
- if (parsed.markWorking) {
368
- this.state.handleCodexActivity({
369
- sessionId: parsed.sessionId,
370
- cwd: parsed.cwd
371
- });
372
- }
373
- if (parsed.markIdle) {
374
- this.state.setCodexIdle(parsed.sessionId, parsed.cwd);
321
+ for (const line of newLines) {
322
+ const parsed = parseCodexLine(line, fileState.sessionId);
323
+ fileState.sessionId = parsed.sessionId;
324
+ if (parsed.previousSessionId) {
325
+ this.state.removeSession(parsed.previousSessionId);
326
+ }
327
+ this.state.markCodexSessionSeen(parsed.sessionId, parsed.cwd);
328
+ if (parsed.markWorking) {
329
+ this.state.handleCodexActivity({
330
+ sessionId: parsed.sessionId,
331
+ cwd: parsed.cwd
332
+ });
333
+ }
334
+ if (parsed.markIdle) {
335
+ this.state.setCodexIdle(parsed.sessionId, parsed.cwd);
336
+ }
375
337
  }
376
338
  }
377
339
  }
package/dist/server.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  startServer
3
- } from "./chunk-YPG2D6CV.js";
3
+ } from "./chunk-APDAIY47.js";
4
4
  export {
5
5
  startServer
6
6
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codex-blocker",
3
- "version": "0.0.9",
3
+ "version": "0.0.10-alpha.3",
4
4
  "description": "Block distracting websites unless Codex is actively running inference. Forked from Theo Browne's (T3) Claude Blocker",
5
5
  "author": "Adam Blumoff ",
6
6
  "repository": {