@brutalsystems/birddog-opencode 0.3.6 → 0.5.0

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/birddog.ts +11 -7
  2. package/package.json +1 -1
package/birddog.ts CHANGED
@@ -14,7 +14,7 @@
14
14
  * a plugin, and does not descend into subdirectories. Export exactly one
15
15
  * thing, and never a `default`. All logic lives in ./birddog-lib/.
16
16
  */
17
- import { appendFileSync, chmodSync, mkdirSync, statSync } from 'node:fs';
17
+ import { appendFileSync, chmodSync, mkdirSync, statSync, writeFileSync } from 'node:fs';
18
18
  import { homedir } from 'node:os';
19
19
  import { dirname } from 'node:path';
20
20
  import { pluginLogPath, sessionsDir } from './birddog-lib/paths.js';
@@ -26,7 +26,7 @@ const MAX_LOG_BYTES = 2 * 1024 * 1024;
26
26
 
27
27
  /** version is kept in step with package.json by scripts/sync-version.mjs, and
28
28
  * a test asserts they agree. */
29
- const VERSION = '0.3.6';
29
+ const VERSION = '0.5.0';
30
30
 
31
31
  export const Birddog = async (input?: { client?: { _client?: unknown } }) => {
32
32
  const logPath = pluginLogPath(process.env, homedir());
@@ -54,13 +54,17 @@ export const Birddog = async (input?: { client?: { _client?: unknown } }) => {
54
54
  }
55
55
  if (logBytes >= MAX_LOG_BYTES) {
56
56
  // Truncate rather than rotate: these are diagnostics, not a record
57
- // anyone is entitled to keep.
58
- logBytes = 0;
57
+ // anyone is entitled to keep. Writing rather than appending is what
58
+ // truncates; resetting the counter alone would leave the file to grow
59
+ // forever, one bound's worth at a time.
60
+ writeFileSync(logPath, data, { mode: 0o600 });
61
+ logBytes = Buffer.byteLength(data, 'utf8');
62
+ } else {
63
+ appendFileSync(logPath, data, { mode: 0o600 });
64
+ logBytes += Buffer.byteLength(data, 'utf8');
59
65
  }
60
- appendFileSync(logPath, data, { mode: 0o600 });
61
- logBytes += Buffer.byteLength(data, 'utf8');
62
66
  if (!tightened) {
63
- // `mode` on appendFileSync only applies when the file is created, so
67
+ // `mode` on either write only applies when the file is created, so
64
68
  // a pre-existing world-readable log is tightened here too.
65
69
  chmodSync(logPath, 0o600);
66
70
  tightened = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brutalsystems/birddog-opencode",
3
- "version": "0.3.6",
3
+ "version": "0.5.0",
4
4
  "description": "opencode plugin for birddog — publishes a session's state so birddog can observe it from outside. Read-only: it reports, and never acts on the session.",
5
5
  "keywords": [
6
6
  "opencode",