@spilno/herald-mcp 1.34.2 → 1.34.4

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
@@ -30,11 +30,31 @@ herald.gotStuck('What failed');
30
30
 
31
31
  ## Quick Start
32
32
 
33
+ ### MCP Server (for AI agents like Claude)
34
+
33
35
  ```bash
34
36
  cd your-project
35
37
  npx @spilno/herald-mcp init
36
38
  ```
37
39
 
40
+ ### SDK (for programmatic access)
41
+
42
+ ```typescript
43
+ import { herald } from '@spilno/herald-mcp';
44
+
45
+ // Capture a pattern (something that worked)
46
+ await herald.learned('Always run tests before committing');
47
+
48
+ // Capture an antipattern (something that failed)
49
+ await herald.gotStuck('Forgot to check existing tests before refactoring');
50
+
51
+ // Query patterns
52
+ const patterns = await herald.recall();
53
+
54
+ // Configure (optional - uses git context by default)
55
+ herald.configure({ baseUrl: 'https://custom.ceda.com', token: 'your-token' });
56
+ ```
57
+
38
58
  **What this does:**
39
59
  1. Creates `.mcp.json` with Herald MCP configuration
40
60
  2. Fetches learned patterns from CEDA (if any exist)
@@ -42,6 +62,41 @@ npx @spilno/herald-mcp init
42
62
 
43
63
  Company and project default to your folder name. Zero config.
44
64
 
65
+ ## Interactive Chat
66
+
67
+ For humans who want to capture patterns directly from the terminal:
68
+
69
+ ```bash
70
+ npx @spilno/herald-mcp chat
71
+ ```
72
+
73
+ ```
74
+ Herald Pattern Journal
75
+
76
+ Commands:
77
+ /learned <insight> - capture what worked
78
+ /stuck <insight> - capture what failed
79
+ /recall [topic] - see your patterns
80
+ /quit - exit
81
+
82
+ > /learned Error boundaries prevent silent failures
83
+ Pattern captured
84
+
85
+ > /stuck Forgot to await in test setup
86
+ Antipattern captured
87
+
88
+ > /recall testing
89
+ Patterns:
90
+ - Error boundaries prevent silent failures
91
+ Antipatterns:
92
+ - Forgot to await in test setup
93
+
94
+ > /quit
95
+ Bye! Your patterns are saved.
96
+ ```
97
+
98
+ No AI key needed. Just pattern capture and recall.
99
+
45
100
  ## Init Options
46
101
 
47
102
  ```bash
@@ -188,6 +243,82 @@ CEDA (Cognitive Event-Driven Architecture) is pattern memory for AI:
188
243
 
189
244
  Unlike RAG (retrieves content), CEDA retrieves **what worked**.
190
245
 
246
+ ## SDK API
247
+
248
+ The SDK provides programmatic access to CEDA pattern memory for use in your own applications.
249
+
250
+ ### Installation
251
+
252
+ ```bash
253
+ npm install @spilno/herald-mcp
254
+ ```
255
+
256
+ ### API Reference
257
+
258
+ #### `herald.learned(insight, context?)`
259
+
260
+ Capture a pattern (something that worked).
261
+
262
+ ```typescript
263
+ await herald.learned('Always run tests before committing');
264
+ await herald.learned('Use feature flags for gradual rollouts', 'deployment pipeline');
265
+ ```
266
+
267
+ #### `herald.gotStuck(insight, context?)`
268
+
269
+ Capture an antipattern (something that failed).
270
+
271
+ ```typescript
272
+ await herald.gotStuck('Forgot to check existing tests before refactoring');
273
+ await herald.gotStuck('Deployed without running migrations', 'production incident');
274
+ ```
275
+
276
+ #### `herald.recall(topic?)`
277
+
278
+ Query learned patterns and antipatterns.
279
+
280
+ ```typescript
281
+ const patterns = await herald.recall();
282
+ const deployPatterns = await herald.recall('deployment');
283
+ ```
284
+
285
+ Returns an array of `Pattern` objects:
286
+
287
+ ```typescript
288
+ interface Pattern {
289
+ insight: string;
290
+ feeling: 'success' | 'stuck';
291
+ signal?: string;
292
+ reinforcement?: string;
293
+ warning?: string;
294
+ scope?: string;
295
+ }
296
+ ```
297
+
298
+ #### `herald.configure(opts)`
299
+
300
+ Configure the SDK (optional - uses git context by default).
301
+
302
+ ```typescript
303
+ herald.configure({
304
+ baseUrl: 'https://custom.ceda.com',
305
+ token: 'your-api-token',
306
+ company: 'acme',
307
+ project: 'backend',
308
+ user: 'developer'
309
+ });
310
+ ```
311
+
312
+ ### Context Detection
313
+
314
+ By default, the SDK automatically derives context from:
315
+
316
+ 1. **Git remote** - Organization and repository name from git origin
317
+ 2. **Git user** - User name from git config
318
+ 3. **Path** - Falls back to folder names if not in a git repo
319
+
320
+ This means you can use the SDK without any configuration in most projects.
321
+
191
322
  ## Links
192
323
 
193
324
  - **CEDA**: https://getceda.com
@@ -200,4 +331,4 @@ MIT
200
331
 
201
332
  ---
202
333
 
203
- *Herald v1.25.0 — Pattern memory for AI agents*
334
+ *Herald v1.33.0 — Pattern memory for AI agents*
@@ -0,0 +1,2 @@
1
+ export declare function runChat(): Promise<void>;
2
+ //# sourceMappingURL=chat.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../src/cli/chat.ts"],"names":[],"mappings":"AAIA,wBAAsB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAoF7C"}
@@ -0,0 +1,91 @@
1
+ import * as readline from 'readline';
2
+ const BASE_URL = process.env.CEDA_URL || process.env.HERALD_API_URL || 'https://getceda.com';
3
+ export async function runChat() {
4
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
5
+ console.log('\nHerald Pattern Journal\n');
6
+ console.log('Commands:');
7
+ console.log(' /learned <insight> - capture what worked');
8
+ console.log(' /stuck <insight> - capture what failed');
9
+ console.log(' /recall [topic] - see your patterns');
10
+ console.log(' /quit - exit\n');
11
+ const prompt = () => {
12
+ rl.question('> ', async (input) => {
13
+ const trimmed = input.trim();
14
+ if (!trimmed) {
15
+ prompt();
16
+ return;
17
+ }
18
+ const [cmd, ...args] = trimmed.split(' ');
19
+ const text = args.join(' ');
20
+ if (cmd === '/learned' && text) {
21
+ try {
22
+ await fetch(`${BASE_URL}/api/herald/reflect`, {
23
+ method: 'POST',
24
+ headers: { 'Content-Type': 'application/json' },
25
+ body: JSON.stringify({ feeling: 'success', insight: text, session: 'chat' })
26
+ });
27
+ console.log('Pattern captured\n');
28
+ }
29
+ catch {
30
+ console.log('Failed to capture pattern\n');
31
+ }
32
+ }
33
+ else if (cmd === '/stuck' && text) {
34
+ try {
35
+ await fetch(`${BASE_URL}/api/herald/reflect`, {
36
+ method: 'POST',
37
+ headers: { 'Content-Type': 'application/json' },
38
+ body: JSON.stringify({ feeling: 'stuck', insight: text, session: 'chat' })
39
+ });
40
+ console.log('Antipattern captured\n');
41
+ }
42
+ catch {
43
+ console.log('Failed to capture antipattern\n');
44
+ }
45
+ }
46
+ else if (cmd === '/recall') {
47
+ try {
48
+ const url = text
49
+ ? `${BASE_URL}/api/herald/reflections?limit=10&topic=${encodeURIComponent(text)}`
50
+ : `${BASE_URL}/api/herald/reflections?limit=10`;
51
+ const res = await fetch(url);
52
+ const data = await res.json();
53
+ const patterns = data.patterns || [];
54
+ const antipatterns = data.antipatterns || [];
55
+ if (patterns.length > 0) {
56
+ console.log('Patterns:');
57
+ patterns.forEach(p => console.log(` - ${p.insight}`));
58
+ }
59
+ else {
60
+ console.log('Patterns: (none)');
61
+ }
62
+ if (antipatterns.length > 0) {
63
+ console.log('Antipatterns:');
64
+ antipatterns.forEach(p => console.log(` - ${p.insight}`));
65
+ }
66
+ else {
67
+ console.log('Antipatterns: (none)');
68
+ }
69
+ console.log('');
70
+ }
71
+ catch {
72
+ console.log('Failed to recall patterns\n');
73
+ }
74
+ }
75
+ else if (cmd === '/quit') {
76
+ console.log('Bye! Your patterns are saved.');
77
+ rl.close();
78
+ return;
79
+ }
80
+ else if (cmd === '/learned' || cmd === '/stuck') {
81
+ console.log(`Usage: ${cmd} <insight>\n`);
82
+ }
83
+ else {
84
+ console.log('Commands: /learned <text>, /stuck <text>, /recall [topic], /quit\n');
85
+ }
86
+ prompt();
87
+ });
88
+ };
89
+ prompt();
90
+ }
91
+ //# sourceMappingURL=chat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat.js","sourceRoot":"","sources":["../../src/cli/chat.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AAErC,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,qBAAqB,CAAC;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