@spilno/herald-mcp 1.26.0 → 1.28.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.
- package/README.md +111 -105
- package/dist/cli/init.d.ts +0 -5
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +53 -115
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/templates/claude-md.d.ts +1 -3
- package/dist/cli/templates/claude-md.d.ts.map +1 -1
- package/dist/cli/templates/claude-md.js +11 -42
- package/dist/cli/templates/claude-md.js.map +1 -1
- package/dist/index.js +149 -466
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/cli/templates/hookify-rules.d.ts +0 -22
- package/dist/cli/templates/hookify-rules.d.ts.map +0 -1
- package/dist/cli/templates/hookify-rules.js +0 -57
- package/dist/cli/templates/hookify-rules.js.map +0 -1
- package/dist/sanitization.d.ts +0 -68
- package/dist/sanitization.d.ts.map +0 -1
- package/dist/sanitization.js +0 -236
- package/dist/sanitization.js.map +0 -1
- package/dist/sanitization.spec.d.ts +0 -2
- package/dist/sanitization.spec.d.ts.map +0 -1
- package/dist/sanitization.spec.js +0 -90
- package/dist/sanitization.spec.js.map +0 -1
package/README.md
CHANGED
|
@@ -18,153 +18,159 @@ AI agents start fresh each session. Herald gives them memory:
|
|
|
18
18
|
## Quick Start
|
|
19
19
|
|
|
20
20
|
```bash
|
|
21
|
-
|
|
21
|
+
# One command setup for Claude Desktop
|
|
22
22
|
npx @spilno/herald-mcp init
|
|
23
|
+
|
|
24
|
+
# Or install globally
|
|
25
|
+
npm install -g @spilno/herald-mcp
|
|
26
|
+
herald-mcp init
|
|
23
27
|
```
|
|
24
28
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
3. Creates/updates `CLAUDE.md` with patterns baked in
|
|
29
|
+
Done. Herald is now available to Claude.
|
|
30
|
+
|
|
31
|
+
## Core Tools
|
|
29
32
|
|
|
30
|
-
|
|
33
|
+
| Tool | Purpose |
|
|
34
|
+
|------|---------|
|
|
35
|
+
| `herald_predict` | Generate structure from natural language |
|
|
36
|
+
| `herald_refine` | Refine predictions with feedback |
|
|
37
|
+
| `herald_patterns` | Query what worked before |
|
|
38
|
+
| `herald_reflect` | Capture patterns and antipatterns |
|
|
39
|
+
| `herald_feedback` | Reinforce helpful patterns |
|
|
31
40
|
|
|
32
|
-
|
|
41
|
+
### Pattern Memory
|
|
33
42
|
|
|
34
|
-
```bash
|
|
35
|
-
npx @spilno/herald-mcp init [options]
|
|
36
43
|
```
|
|
44
|
+
AI: herald_patterns()
|
|
45
|
+
→ Returns: patterns that worked, antipatterns to avoid
|
|
37
46
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
| `--sync`, `-s` | Just sync patterns to CLAUDE.md (quick update) |
|
|
41
|
-
| `--hookify` | Generate hookify rules for auto pattern reminders |
|
|
42
|
-
| `--company`, `-c` | Override company (default: folder name) |
|
|
43
|
-
| `--project`, `-p` | Override project (default: folder name) |
|
|
44
|
-
| `--user`, `-u` | Override user (default: "default") |
|
|
45
|
-
| `--force`, `-f` | Overwrite existing config |
|
|
46
|
-
| `--help`, `-h` | Show help |
|
|
47
|
-
|
|
48
|
-
**Examples:**
|
|
49
|
-
```bash
|
|
50
|
-
# Basic setup (zero config)
|
|
51
|
-
npx @spilno/herald-mcp init
|
|
47
|
+
AI: herald_predict("create safety assessment module")
|
|
48
|
+
→ Returns: structured prediction based on accumulated patterns
|
|
52
49
|
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
User: "That worked well"
|
|
51
|
+
AI: herald_reflect(feeling="success", insight="field grouping approach")
|
|
52
|
+
→ Pattern captured, weight increased
|
|
53
|
+
```
|
|
55
54
|
|
|
56
|
-
|
|
57
|
-
npx @spilno/herald-mcp init --hookify
|
|
55
|
+
## Session Flow
|
|
58
56
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
```bash
|
|
58
|
+
# Start a session
|
|
59
|
+
herald-mcp predict "create incident report module"
|
|
62
60
|
|
|
63
|
-
|
|
61
|
+
# Refine iteratively
|
|
62
|
+
herald-mcp refine "add witness section"
|
|
63
|
+
herald-mcp refine "require photos for severity > 3"
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
# Accept when satisfied
|
|
66
|
+
herald-mcp observe yes
|
|
66
67
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
↓ inherits from
|
|
70
|
-
project (team patterns)
|
|
71
|
-
↓ inherits from
|
|
72
|
-
company (org-wide patterns)
|
|
68
|
+
# Resume anytime
|
|
69
|
+
herald-mcp resume
|
|
73
70
|
```
|
|
74
71
|
|
|
75
|
-
|
|
72
|
+
## Configuration
|
|
76
73
|
|
|
77
|
-
|
|
74
|
+
### Claude Desktop / Claude Code
|
|
75
|
+
|
|
76
|
+
```json
|
|
77
|
+
{
|
|
78
|
+
"mcpServers": {
|
|
79
|
+
"herald": {
|
|
80
|
+
"command": "npx",
|
|
81
|
+
"args": ["@spilno/herald-mcp"],
|
|
82
|
+
"env": {
|
|
83
|
+
"HERALD_API_URL": "https://getceda.com"
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
```
|
|
78
89
|
|
|
79
|
-
|
|
90
|
+
### Environment Variables
|
|
80
91
|
|
|
81
|
-
|
|
|
82
|
-
|
|
83
|
-
| `
|
|
84
|
-
| `
|
|
92
|
+
| Variable | Required | Description |
|
|
93
|
+
|----------|----------|-------------|
|
|
94
|
+
| `HERALD_API_URL` | Yes | CEDA server (default: https://getceda.com) |
|
|
95
|
+
| `HERALD_COMPANY` | No | Multi-tenant company context |
|
|
96
|
+
| `HERALD_PROJECT` | No | Project context |
|
|
97
|
+
| `HERALD_USER` | No | User context |
|
|
85
98
|
|
|
86
|
-
##
|
|
99
|
+
## Multi-Tenant Isolation
|
|
87
100
|
|
|
88
|
-
|
|
89
|
-
|------|---------|
|
|
90
|
-
| `herald_patterns` | Query what worked before (with inheritance) |
|
|
91
|
-
| `herald_reflect` | Capture patterns and antipatterns |
|
|
92
|
-
| `herald_predict` | Generate structure from natural language |
|
|
93
|
-
| `herald_refine` | Refine predictions with feedback |
|
|
94
|
-
| `herald_feedback` | Reinforce helpful patterns |
|
|
95
|
-
|
|
96
|
-
### Pattern Capture
|
|
97
|
-
|
|
98
|
-
When something works or fails, capture it:
|
|
101
|
+
Patterns are isolated by context:
|
|
99
102
|
|
|
100
103
|
```
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
User: "The ASCII visualization approach"
|
|
104
|
-
→ Pattern captured, available in future sessions
|
|
104
|
+
Company A patterns → Only visible to Company A
|
|
105
|
+
Project X patterns → Only visible to Project X users
|
|
105
106
|
```
|
|
106
107
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
→ Antipattern captured, Claude will avoid this
|
|
108
|
+
Set context via environment or headers:
|
|
109
|
+
```bash
|
|
110
|
+
export HERALD_COMPANY=acme
|
|
111
|
+
export HERALD_PROJECT=safety-modules
|
|
112
112
|
```
|
|
113
113
|
|
|
114
|
-
##
|
|
114
|
+
## Herald Context Sync
|
|
115
115
|
|
|
116
|
-
|
|
116
|
+
Herald instances share insights across contexts:
|
|
117
117
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
118
|
+
| Tool | Purpose |
|
|
119
|
+
|------|---------|
|
|
120
|
+
| `herald_context_status` | Check status of Herald instances |
|
|
121
|
+
| `herald_share_insight` | Share pattern to other contexts |
|
|
122
|
+
| `herald_query_insights` | Query shared insights |
|
|
123
|
+
| `herald_sync` | Flush local buffer to cloud |
|
|
121
124
|
|
|
122
|
-
|
|
123
|
-
- **On prompt**: Remind to check patterns at session start
|
|
124
|
-
- **On session end**: Remind to capture patterns before leaving
|
|
125
|
+
## Chat Mode
|
|
125
126
|
|
|
126
|
-
|
|
127
|
+
For humans who prefer conversation:
|
|
127
128
|
|
|
128
|
-
|
|
129
|
+
```bash
|
|
130
|
+
herald-mcp chat
|
|
131
|
+
```
|
|
129
132
|
|
|
130
|
-
|
|
133
|
+
```
|
|
134
|
+
You: I need a permit-to-work module
|
|
135
|
+
Herald: I've designed a Permit-to-Work module with 5 sections...
|
|
131
136
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
| `.mcp.json` | MCP server configuration for Claude Code |
|
|
135
|
-
| `CLAUDE.md` | Project instructions with baked patterns |
|
|
136
|
-
| `.claude/hookify.*.local.md` | Auto-reminder rules (if --hookify) |
|
|
137
|
+
You: Add gas testing checklist
|
|
138
|
+
Herald: Added gas testing to Pre-Work Safety section...
|
|
137
139
|
|
|
138
|
-
|
|
140
|
+
You: Perfect
|
|
141
|
+
Herald: Module accepted and saved.
|
|
142
|
+
```
|
|
139
143
|
|
|
140
|
-
|
|
141
|
-
|----------|---------|-------------|
|
|
142
|
-
| `CEDA_URL` | https://getceda.com | CEDA backend URL |
|
|
143
|
-
| `HERALD_COMPANY` | folder name | Company context |
|
|
144
|
-
| `HERALD_PROJECT` | folder name | Project context |
|
|
145
|
-
| `HERALD_USER` | "default" | User context |
|
|
144
|
+
## Command Reference
|
|
146
145
|
|
|
147
|
-
|
|
146
|
+
```bash
|
|
147
|
+
herald-mcp init # Setup for Claude Desktop
|
|
148
|
+
herald-mcp chat # Interactive conversation mode
|
|
149
|
+
herald-mcp predict <signal> # Generate prediction
|
|
150
|
+
herald-mcp refine <signal> # Refine current prediction
|
|
151
|
+
herald-mcp resume # Resume last session
|
|
152
|
+
herald-mcp observe <yes|no> # Accept or reject prediction
|
|
153
|
+
herald-mcp new # Start fresh session
|
|
154
|
+
herald-mcp health # Check CEDA connection
|
|
155
|
+
herald-mcp stats # Show loaded patterns
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Architecture
|
|
148
159
|
|
|
149
160
|
```
|
|
150
161
|
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
|
|
151
|
-
│
|
|
152
|
-
│
|
|
153
|
-
│
|
|
162
|
+
│ AI Agent │────▶│ Herald │────▶│ CEDA │
|
|
163
|
+
│ (Claude/ │ │ (MCP) │ │ (Pattern │
|
|
164
|
+
│ Devin/etc) │◀────│ │◀────│ Memory) │
|
|
154
165
|
└─────────────┘ └─────────────┘ └─────────────┘
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
166
|
+
│
|
|
167
|
+
┌──────┴──────┐
|
|
168
|
+
│ Patterns │
|
|
169
|
+
│ Antipatterns│
|
|
170
|
+
│ Feedback │
|
|
171
|
+
└─────────────┘
|
|
161
172
|
```
|
|
162
173
|
|
|
163
|
-
1. **Session Start**: Claude reads `herald://patterns` resource
|
|
164
|
-
2. **During Work**: Patterns guide behavior
|
|
165
|
-
3. **Session End**: Capture new patterns with `herald_reflect`
|
|
166
|
-
4. **Next Session**: New patterns available automatically
|
|
167
|
-
|
|
168
174
|
## What is CEDA?
|
|
169
175
|
|
|
170
176
|
CEDA (Cognitive Event-Driven Architecture) is pattern memory for AI:
|
|
@@ -187,4 +193,4 @@ MIT
|
|
|
187
193
|
|
|
188
194
|
---
|
|
189
195
|
|
|
190
|
-
*Herald v1.
|
|
196
|
+
*Herald v1.20.0 — Pattern memory for AI agents*
|
package/dist/cli/init.d.ts
CHANGED
|
@@ -10,12 +10,7 @@
|
|
|
10
10
|
export interface InitOptions {
|
|
11
11
|
force?: boolean;
|
|
12
12
|
help?: boolean;
|
|
13
|
-
company?: string;
|
|
14
|
-
project?: string;
|
|
15
|
-
user?: string;
|
|
16
13
|
noClaudeMd?: boolean;
|
|
17
|
-
sync?: boolean;
|
|
18
|
-
hookify?: boolean;
|
|
19
14
|
}
|
|
20
15
|
export declare function parseInitArgs(args: string[]): InitOptions;
|
|
21
16
|
export declare function runInit(args?: string[]): Promise<void>;
|
package/dist/cli/init.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/cli/init.ts"],"names":[],"mappings":";AACA;;;;;;;GAOG;AAqDH,MAAM,WAAW,WAAW;IAC1B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/cli/init.ts"],"names":[],"mappings":";AACA;;;;;;;GAOG;AAqDH,MAAM,WAAW,WAAW;IAC1B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,WAAW,CAezD;AAED,wBAAsB,OAAO,CAAC,IAAI,GAAE,MAAM,EAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CA8HhE"}
|
package/dist/cli/init.js
CHANGED
|
@@ -10,20 +10,24 @@
|
|
|
10
10
|
import { existsSync, mkdirSync, writeFileSync, readFileSync } from "fs";
|
|
11
11
|
import { join, basename } from "path";
|
|
12
12
|
import { updateClaudeMdContent, fetchLearnedPatterns } from "./templates/claude-md.js";
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
/**
|
|
14
|
+
* CEDA-67: Simplified config - tags derived from cwd at runtime
|
|
15
|
+
* No need for HERALD_COMPANY/PROJECT - context is AI-native
|
|
16
|
+
*/
|
|
17
|
+
function buildHeraldConfig() {
|
|
15
18
|
return {
|
|
16
19
|
mcpServers: {
|
|
17
20
|
herald: {
|
|
18
21
|
command: "npx",
|
|
19
22
|
args: ["@spilno/herald-mcp@latest"],
|
|
20
23
|
env: {
|
|
21
|
-
CEDA_URL: "https://getceda.com"
|
|
22
|
-
HERALD_COMPANY
|
|
23
|
-
HERALD_PROJECT: project
|
|
24
|
+
CEDA_URL: "https://getceda.com"
|
|
25
|
+
// No HERALD_COMPANY/PROJECT - context tags derived from folder path
|
|
24
26
|
}
|
|
25
27
|
}
|
|
26
|
-
}
|
|
28
|
+
},
|
|
29
|
+
// Required for project-level MCP servers to load properly
|
|
30
|
+
enableAllProjectMcpServers: true
|
|
27
31
|
};
|
|
28
32
|
}
|
|
29
33
|
function printInitHelp() {
|
|
@@ -36,21 +40,16 @@ Usage:
|
|
|
36
40
|
|
|
37
41
|
That's it. Company and project default to folder name.
|
|
38
42
|
|
|
39
|
-
Options:
|
|
40
|
-
--
|
|
41
|
-
--hookify Generate hookify rules for auto pattern reminders
|
|
42
|
-
--company, -c Override company (default: folder name)
|
|
43
|
-
--project, -p Override project (default: folder name)
|
|
44
|
-
--user, -u Override user (default: "default")
|
|
45
|
-
--force, -f Overwrite existing config
|
|
43
|
+
Options (optional):
|
|
44
|
+
--force, -f Clean slate - overwrite entire config (not merge)
|
|
46
45
|
--no-claude-md Skip CLAUDE.md modification
|
|
47
46
|
--help, -h Show this help
|
|
48
47
|
|
|
49
|
-
|
|
48
|
+
Context is derived automatically from your folder path - no configuration needed.
|
|
49
|
+
|
|
50
|
+
Example:
|
|
51
|
+
cd my-project
|
|
50
52
|
npx @spilno/herald-mcp@latest init
|
|
51
|
-
npx @spilno/herald-mcp@latest init --sync # Just sync patterns
|
|
52
|
-
npx @spilno/herald-mcp@latest init --hookify # Add auto-reminders
|
|
53
|
-
npx @spilno/herald-mcp@latest init --company goprint
|
|
54
53
|
|
|
55
54
|
Then start Claude Code and say "herald health" to verify.
|
|
56
55
|
`);
|
|
@@ -65,140 +64,93 @@ export function parseInitArgs(args) {
|
|
|
65
64
|
else if (arg === "--force" || arg === "-f") {
|
|
66
65
|
options.force = true;
|
|
67
66
|
}
|
|
68
|
-
else if (arg === "--company" || arg === "-c") {
|
|
69
|
-
options.company = args[++i];
|
|
70
|
-
}
|
|
71
|
-
else if (arg === "--project" || arg === "-p") {
|
|
72
|
-
options.project = args[++i];
|
|
73
|
-
}
|
|
74
|
-
else if (arg === "--user" || arg === "-u") {
|
|
75
|
-
options.user = args[++i];
|
|
76
|
-
}
|
|
77
67
|
else if (arg === "--no-claude-md") {
|
|
78
68
|
options.noClaudeMd = true;
|
|
79
69
|
}
|
|
80
|
-
else if (arg === "--sync" || arg === "-s") {
|
|
81
|
-
options.sync = true;
|
|
82
|
-
}
|
|
83
|
-
else if (arg === "--hookify") {
|
|
84
|
-
options.hookify = true;
|
|
85
|
-
}
|
|
86
70
|
}
|
|
87
71
|
return options;
|
|
88
72
|
}
|
|
89
|
-
async function runSyncPatterns(cwd, claudeMdPath, options) {
|
|
90
|
-
const projectName = basename(cwd);
|
|
91
|
-
const mcpJsonPath = join(cwd, ".mcp.json");
|
|
92
|
-
// Try to get context from .mcp.json, fall back to folder name
|
|
93
|
-
let company = options.company || projectName;
|
|
94
|
-
let project = options.project || projectName;
|
|
95
|
-
let user = options.user || "default";
|
|
96
|
-
if (existsSync(mcpJsonPath)) {
|
|
97
|
-
try {
|
|
98
|
-
const mcpConfig = JSON.parse(readFileSync(mcpJsonPath, "utf-8"));
|
|
99
|
-
const heraldEnv = mcpConfig.mcpServers?.herald?.env || {};
|
|
100
|
-
company = options.company || heraldEnv.HERALD_COMPANY || projectName;
|
|
101
|
-
project = options.project || heraldEnv.HERALD_PROJECT || projectName;
|
|
102
|
-
user = options.user || heraldEnv.HERALD_USER || "default";
|
|
103
|
-
}
|
|
104
|
-
catch { /* ignore */ }
|
|
105
|
-
}
|
|
106
|
-
const context = { company, project, user };
|
|
107
|
-
const cedaUrl = "https://getceda.com";
|
|
108
|
-
console.log(`Syncing patterns for ${user}→${project}→${company}...`);
|
|
109
|
-
const learnedPatterns = await fetchLearnedPatterns(cedaUrl, company, project, user);
|
|
110
|
-
if (!learnedPatterns) {
|
|
111
|
-
console.log("Failed to fetch patterns from CEDA");
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
const totalPatterns = learnedPatterns.patterns.length + learnedPatterns.antipatterns.length;
|
|
115
|
-
console.log(`Found ${totalPatterns} patterns (${learnedPatterns.patterns.length} success, ${learnedPatterns.antipatterns.length} antipatterns)`);
|
|
116
|
-
let existingClaudeMd = null;
|
|
117
|
-
if (existsSync(claudeMdPath)) {
|
|
118
|
-
existingClaudeMd = readFileSync(claudeMdPath, "utf-8");
|
|
119
|
-
}
|
|
120
|
-
const updatedClaudeMd = updateClaudeMdContent(existingClaudeMd, context, projectName, learnedPatterns);
|
|
121
|
-
writeFileSync(claudeMdPath, updatedClaudeMd, "utf-8");
|
|
122
|
-
console.log(`✓ CLAUDE.md updated with ${totalPatterns} patterns`);
|
|
123
|
-
console.log(`\nPatterns are now baked into CLAUDE.md for offline access.`);
|
|
124
|
-
}
|
|
125
73
|
export async function runInit(args = []) {
|
|
126
74
|
const options = parseInitArgs(args);
|
|
127
75
|
if (options.help) {
|
|
128
76
|
printInitHelp();
|
|
129
77
|
return;
|
|
130
78
|
}
|
|
79
|
+
// CEDA-67: Simplified setup - no company/project config needed
|
|
131
80
|
const cwd = process.cwd();
|
|
132
81
|
const projectName = basename(cwd);
|
|
133
|
-
const
|
|
82
|
+
const claudeDir = join(cwd, ".claude");
|
|
83
|
+
const settingsPath = join(claudeDir, "settings.local.json");
|
|
134
84
|
const claudeMdPath = join(cwd, "CLAUDE.md");
|
|
135
|
-
//
|
|
136
|
-
|
|
137
|
-
return runSyncPatterns(cwd, claudeMdPath, options);
|
|
138
|
-
}
|
|
139
|
-
// Zero-config: derive from folder name, flags override
|
|
140
|
-
const company = options.company || projectName;
|
|
141
|
-
const project = options.project || projectName;
|
|
85
|
+
// Derive context tags from path for CLAUDE.md display
|
|
86
|
+
const contextTags = cwd.split("/").filter(p => p && !p.startsWith(".") && !["Users", "Documents", "home"].includes(p)).slice(-3);
|
|
142
87
|
const context = {
|
|
143
|
-
company,
|
|
144
|
-
project,
|
|
145
|
-
user:
|
|
88
|
+
company: contextTags[0] || projectName,
|
|
89
|
+
project: contextTags.slice(-1)[0] || projectName,
|
|
90
|
+
user: process.env.USER || "default",
|
|
146
91
|
};
|
|
147
|
-
// Check for old herald configs and warn
|
|
148
|
-
const
|
|
149
|
-
const oldSettingsPath = join(oldClaudeDir, "settings.local.json");
|
|
92
|
+
// Check for old herald configs and warn
|
|
93
|
+
const oldSettingsPath = join(claudeDir, "settings.json");
|
|
150
94
|
if (existsSync(oldSettingsPath)) {
|
|
151
95
|
try {
|
|
152
96
|
const oldConfig = JSON.parse(readFileSync(oldSettingsPath, "utf-8"));
|
|
153
97
|
if (oldConfig.mcpServers?.herald) {
|
|
154
|
-
console.log("⚠️ Found old Herald config in .
|
|
155
|
-
console.log(" This location is no longer supported. Migrating to .mcp.json");
|
|
98
|
+
console.log("⚠️ Found old Herald config in settings.json - will use settings.local.json instead");
|
|
156
99
|
}
|
|
157
100
|
}
|
|
158
101
|
catch { /* ignore */ }
|
|
159
102
|
}
|
|
160
|
-
if (existsSync(
|
|
103
|
+
if (existsSync(settingsPath) && !options.force) {
|
|
161
104
|
console.log(`
|
|
162
|
-
.
|
|
105
|
+
.claude/settings.local.json already exists.
|
|
163
106
|
|
|
164
107
|
To view current config:
|
|
165
|
-
cat .
|
|
108
|
+
cat .claude/settings.local.json
|
|
166
109
|
|
|
167
110
|
To overwrite:
|
|
168
111
|
npx @spilno/herald-mcp init --force
|
|
169
112
|
`);
|
|
170
113
|
return;
|
|
171
114
|
}
|
|
172
|
-
|
|
115
|
+
if (!existsSync(claudeDir)) {
|
|
116
|
+
mkdirSync(claudeDir, { recursive: true });
|
|
117
|
+
console.log("Created .claude directory");
|
|
118
|
+
}
|
|
119
|
+
const heraldConfig = buildHeraldConfig();
|
|
173
120
|
let finalConfig = heraldConfig;
|
|
174
|
-
if (existsSync(
|
|
121
|
+
if (existsSync(settingsPath) && !options.force) {
|
|
122
|
+
// Merge mode: preserve existing config, add/update Herald
|
|
175
123
|
try {
|
|
176
|
-
const existingContent = readFileSync(
|
|
124
|
+
const existingContent = readFileSync(settingsPath, "utf-8");
|
|
177
125
|
const existingConfig = JSON.parse(existingContent);
|
|
178
126
|
finalConfig = {
|
|
179
127
|
...existingConfig,
|
|
180
128
|
mcpServers: {
|
|
181
129
|
...existingConfig.mcpServers,
|
|
182
130
|
...heraldConfig.mcpServers
|
|
183
|
-
}
|
|
131
|
+
},
|
|
132
|
+
enableAllProjectMcpServers: true
|
|
184
133
|
};
|
|
185
|
-
console.log("Merging with existing .
|
|
134
|
+
console.log("Merging with existing settings.local.json");
|
|
186
135
|
}
|
|
187
136
|
catch {
|
|
188
|
-
console.log("Overwriting invalid .
|
|
137
|
+
console.log("Overwriting invalid settings.local.json");
|
|
189
138
|
}
|
|
190
139
|
}
|
|
191
|
-
|
|
192
|
-
|
|
140
|
+
else if (options.force && existsSync(settingsPath)) {
|
|
141
|
+
console.log("Overwriting existing settings.local.json (--force)");
|
|
142
|
+
}
|
|
143
|
+
writeFileSync(settingsPath, JSON.stringify(finalConfig, null, 2) + "\n", "utf-8");
|
|
144
|
+
console.log("✓ Created .claude/settings.local.json");
|
|
193
145
|
if (!options.noClaudeMd) {
|
|
194
146
|
let existingClaudeMd = null;
|
|
195
147
|
if (existsSync(claudeMdPath)) {
|
|
196
148
|
existingClaudeMd = readFileSync(claudeMdPath, "utf-8");
|
|
197
149
|
}
|
|
198
|
-
// Fetch learned patterns from CEDA
|
|
150
|
+
// Fetch learned patterns from CEDA (using derived tags as context)
|
|
199
151
|
const cedaUrl = "https://getceda.com";
|
|
200
152
|
console.log("Fetching learned patterns from CEDA...");
|
|
201
|
-
const learnedPatterns = await fetchLearnedPatterns(cedaUrl, company, project);
|
|
153
|
+
const learnedPatterns = await fetchLearnedPatterns(cedaUrl, context.company, context.project);
|
|
202
154
|
if (learnedPatterns) {
|
|
203
155
|
const totalPatterns = learnedPatterns.patterns.length + learnedPatterns.antipatterns.length;
|
|
204
156
|
if (totalPatterns > 0) {
|
|
@@ -214,27 +166,11 @@ To overwrite:
|
|
|
214
166
|
console.log("Created CLAUDE.md with Herald integration");
|
|
215
167
|
}
|
|
216
168
|
}
|
|
217
|
-
// Generate hookify rules if requested
|
|
218
|
-
if (options.hookify) {
|
|
219
|
-
const claudeDir = join(cwd, ".claude");
|
|
220
|
-
if (!existsSync(claudeDir)) {
|
|
221
|
-
mkdirSync(claudeDir, { recursive: true });
|
|
222
|
-
}
|
|
223
|
-
const hookifyRules = getHookifyRulesContent();
|
|
224
|
-
for (const rule of hookifyRules) {
|
|
225
|
-
const rulePath = join(claudeDir, rule.filename);
|
|
226
|
-
writeFileSync(rulePath, rule.content, "utf-8");
|
|
227
|
-
}
|
|
228
|
-
console.log(`✓ Created ${hookifyRules.length} hookify rules in .claude/`);
|
|
229
|
-
console.log(" - Pattern check reminder on prompts");
|
|
230
|
-
console.log(" - Pattern capture reminder on session end");
|
|
231
|
-
}
|
|
232
169
|
console.log(`
|
|
233
170
|
✓ Herald configured
|
|
234
171
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
Backend: https://getceda.com
|
|
172
|
+
Context tags: ${contextTags.join(" → ")}
|
|
173
|
+
Backend: https://getceda.com
|
|
238
174
|
|
|
239
175
|
Next: Start Claude Code in this directory.
|
|
240
176
|
Say "herald health" to verify.
|
|
@@ -242,6 +178,8 @@ Next: Start Claude Code in this directory.
|
|
|
242
178
|
Capture patterns:
|
|
243
179
|
Say "Herald reflect - that was smooth"
|
|
244
180
|
Claude asks what worked → you answer → saved.
|
|
181
|
+
|
|
182
|
+
Tags are derived from your folder path - no configuration needed.
|
|
245
183
|
`);
|
|
246
184
|
}
|
|
247
185
|
//# sourceMappingURL=init.js.map
|
package/dist/cli/init.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/cli/init.ts"],"names":[],"mappings":";AACA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AACxE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AACtC,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAsB,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"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,eAAe,EAAE,OAAO,CAAC,CAAC;QAEtD,IAAI,gBAAgB,EAAE,CAAC;YACrB,OAAO,CAAC,GAAG,CAAC,2CAA2C,CAAC,CAAC;QAC3D,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,2CAA2C,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC;IAED,OAAO,CAAC,GAAG,CAAC;;;kBAGI,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC;;;;;;;;;;;CAWxC,CAAC,CAAC;AACH,CAAC"}
|
|
@@ -13,17 +13,15 @@ export interface LearnedPatterns {
|
|
|
13
13
|
patterns: Array<{
|
|
14
14
|
insight: string;
|
|
15
15
|
reinforcement?: string;
|
|
16
|
-
scope?: string;
|
|
17
16
|
}>;
|
|
18
17
|
antipatterns: Array<{
|
|
19
18
|
insight: string;
|
|
20
19
|
warning?: string;
|
|
21
|
-
scope?: string;
|
|
22
20
|
}>;
|
|
23
21
|
}
|
|
24
22
|
export declare const HERALD_SECTION_MARKER = "## Herald Integration";
|
|
25
23
|
export declare const HERALD_SECTION_TEMPLATE = "## Herald Integration\n\nYou have Herald MCP tools available. USE THEM.\n\n### On Session Start\n- Call `herald_patterns()` to learn from past sessions\n- Review antipatterns below BEFORE starting work\n\n### Pattern Capture\n- When things go WRONG: \"Herald reflect - that was rough\"\n- When things go WELL: \"Herald reflect - that was smooth\"\n- For deep analysis: \"Herald simulate\"\n\n### Context\n- Company: {{company}}\n- Project: {{project}}\n- User: {{user}}\n\n{{learned_patterns}}\n";
|
|
26
24
|
export declare function renderHeraldSection(context: HeraldContext, learnedPatterns?: LearnedPatterns): string;
|
|
27
|
-
export declare function fetchLearnedPatterns(cedaUrl: string, company: string, project: string
|
|
25
|
+
export declare function fetchLearnedPatterns(cedaUrl: string, company: string, project: string): Promise<LearnedPatterns | null>;
|
|
28
26
|
export declare function updateClaudeMdContent(existingContent: string | null, context: HeraldContext, projectName: string, learnedPatterns?: LearnedPatterns): string;
|
|
29
27
|
//# sourceMappingURL=claude-md.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude-md.d.ts","sourceRoot":"","sources":["../../../src/cli/templates/claude-md.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,aAAa,CAAC,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"claude-md.d.ts","sourceRoot":"","sources":["../../../src/cli/templates/claude-md.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC7D,YAAY,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC5D;AAED,eAAO,MAAM,qBAAqB,0BAA0B,CAAC;AAE7D,eAAO,MAAM,uBAAuB,ofAmBnC,CAAC;AAEF,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,aAAa,EAAE,eAAe,CAAC,EAAE,eAAe,GAAG,MAAM,CA+BrG;AAED,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAsBjC;AAED,wBAAgB,qBAAqB,CACnC,e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