@claudemini/shit-cli 1.8.0 → 1.8.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.
package/README.md CHANGED
@@ -262,7 +262,30 @@ shit-cli can send webhook notifications to external systems (Slack, Lark, CI, cu
262
262
 
263
263
  ### Configuration
264
264
 
265
- Add a `webhooks` field to `.shit-logs/config.json`:
265
+ Webhook supports three configuration sources (highest priority first):
266
+
267
+ **1. Environment variables** (highest priority):
268
+
269
+ ```bash
270
+ export SHIT_WEBHOOK_URL=https://example.com/hook
271
+ export SHIT_WEBHOOK_SECRET=my-secret # HMAC-SHA256 signing
272
+ export SHIT_WEBHOOK_AUTH_TOKEN=bearer-token # Bearer auth (alternative to secret)
273
+ export SHIT_WEBHOOK_EVENTS=session.ended,review.completed
274
+ ```
275
+
276
+ **2. `.shit-logs/config.json` `env` field**:
277
+
278
+ ```json
279
+ {
280
+ "env": {
281
+ "SHIT_WEBHOOK_URL": "https://example.com/hook",
282
+ "SHIT_WEBHOOK_SECRET": "my-secret",
283
+ "SHIT_WEBHOOK_EVENTS": "session.ended,review.completed"
284
+ }
285
+ }
286
+ ```
287
+
288
+ **3. `.shit-logs/config.json` `webhooks` field** (lowest priority):
266
289
 
267
290
  ```json
268
291
  {
@@ -277,15 +300,6 @@ Add a `webhooks` field to `.shit-logs/config.json`:
277
300
  }
278
301
  ```
279
302
 
280
- Or use environment variables (higher priority than config.json):
281
-
282
- ```bash
283
- export SHIT_WEBHOOK_URL=https://example.com/hook
284
- export SHIT_WEBHOOK_SECRET=my-secret # HMAC-SHA256 signing
285
- export SHIT_WEBHOOK_AUTH_TOKEN=bearer-token # Bearer auth (alternative to secret)
286
- export SHIT_WEBHOOK_EVENTS=session.ended,review.completed
287
- ```
288
-
289
303
  ### Authentication
290
304
 
291
305
  - **HMAC-SHA256** — Set `secret` or `SHIT_WEBHOOK_SECRET`. Adds `X-Signature-256: sha256=<hex>` header (GitHub-compatible format).
package/lib/log.js CHANGED
@@ -5,7 +5,7 @@
5
5
  * Reads stdin, parses event, delegates to session/extract/report modules.
6
6
  */
7
7
 
8
- import { appendFileSync, existsSync, mkdirSync, writeFileSync } from 'fs';
8
+ import { appendFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
9
9
  import { join } from 'path';
10
10
  import { getProjectRoot, getLogDir } from './config.js';
11
11
  import { loadState, saveState, processEvent, updateIndex } from './session.js';
@@ -67,7 +67,6 @@ export default async function log(args) {
67
67
 
68
68
  // Dispatch webhook for session end — must await before exit
69
69
  try {
70
- const { readFileSync } = await import('fs');
71
70
  const summaryPath = join(sessionDir, 'summary.json');
72
71
  const summary = JSON.parse(readFileSync(summaryPath, 'utf-8'));
73
72
  await dispatchWebhook(projectRoot, 'session.ended', summary);
package/lib/review.js CHANGED
@@ -710,7 +710,7 @@ export default async function review(args) {
710
710
  const report = buildReport(selectedSessions, options);
711
711
 
712
712
  // Dispatch webhook for review completion
713
- dispatchWebhook(projectRoot, 'review.completed', report).catch(() => {});
713
+ await dispatchWebhook(projectRoot, 'review.completed', report);
714
714
 
715
715
  if (options.format === 'json') {
716
716
  console.log(JSON.stringify(report, null, 2));
package/lib/webhook.js CHANGED
@@ -11,22 +11,33 @@ import { request as httpRequest } from 'http';
11
11
 
12
12
  /**
13
13
  * Load webhook configuration from .shit-logs/config.json + environment variables.
14
- * Env vars take precedence over config.json values.
14
+ * Priority (highest wins): process.env > config.json env > config.json webhooks
15
15
  */
16
16
  export function loadWebhookConfig(projectRoot) {
17
17
  let fileConfig = {};
18
+ let configEnv = {};
18
19
  const configPath = join(projectRoot, '.shit-logs', 'config.json');
19
20
  if (existsSync(configPath)) {
20
21
  try {
21
22
  const raw = JSON.parse(readFileSync(configPath, 'utf-8'));
22
23
  fileConfig = raw.webhooks || {};
24
+ if (raw.env && typeof raw.env === 'object') {
25
+ configEnv = raw.env;
26
+ }
23
27
  } catch { /* ignore malformed config */ }
24
28
  }
25
29
 
26
- const url = process.env.SHIT_WEBHOOK_URL || fileConfig.url;
30
+ // Resolve: process.env > config.json env > config.json webhooks field
31
+ const env = (key) => {
32
+ if (key in process.env) return process.env[key];
33
+ if (key in configEnv) return configEnv[key];
34
+ return '';
35
+ };
36
+
37
+ const url = env('SHIT_WEBHOOK_URL') || fileConfig.url;
27
38
  if (!url) return null;
28
39
 
29
- const envEvents = process.env.SHIT_WEBHOOK_EVENTS;
40
+ const envEvents = env('SHIT_WEBHOOK_EVENTS');
30
41
  const events = envEvents
31
42
  ? envEvents.split(',').map(e => e.trim()).filter(Boolean)
32
43
  : (Array.isArray(fileConfig.events) ? fileConfig.events : []);
@@ -34,8 +45,8 @@ export function loadWebhookConfig(projectRoot) {
34
45
  return {
35
46
  url,
36
47
  events,
37
- secret: process.env.SHIT_WEBHOOK_SECRET || fileConfig.secret || '',
38
- auth_token: process.env.SHIT_WEBHOOK_AUTH_TOKEN || fileConfig.auth_token || '',
48
+ secret: env('SHIT_WEBHOOK_SECRET') || fileConfig.secret || '',
49
+ auth_token: env('SHIT_WEBHOOK_AUTH_TOKEN') || fileConfig.auth_token || '',
39
50
  headers: fileConfig.headers || {},
40
51
  timeout_ms: fileConfig.timeout_ms || 5000,
41
52
  retry: typeof fileConfig.retry === 'number' ? fileConfig.retry : 1,
@@ -169,12 +180,14 @@ export default async function webhook(args) {
169
180
  console.log(' --test Send a test webhook ping');
170
181
  console.log(' --help Show this help');
171
182
  console.log('');
172
- console.log('Configuration:');
173
- console.log(' Set webhooks in .shit-logs/config.json or via environment variables:');
183
+ console.log('Configuration (highest priority first):');
184
+ console.log(' 1. Environment variables:');
174
185
  console.log(' SHIT_WEBHOOK_URL Webhook endpoint URL');
175
186
  console.log(' SHIT_WEBHOOK_SECRET HMAC-SHA256 signing secret');
176
187
  console.log(' SHIT_WEBHOOK_AUTH_TOKEN Bearer token');
177
188
  console.log(' SHIT_WEBHOOK_EVENTS Comma-separated event list');
189
+ console.log(' 2. .shit-logs/config.json "env" field');
190
+ console.log(' 3. .shit-logs/config.json "webhooks" field');
178
191
  return 0;
179
192
  }
180
193
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@claudemini/shit-cli",
3
- "version": "1.8.0",
3
+ "version": "1.8.2",
4
4
  "description": "Session-based Hook Intelligence Tracker - Zero-dependency memory system for human-AI coding sessions",
5
5
  "type": "module",
6
6
  "bin": {