@spilno/herald-mcp 1.28.2 → 1.29.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 +78 -71
- package/dist/cli/init.d.ts +5 -0
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +115 -53
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/templates/claude-md.d.ts +3 -1
- package/dist/cli/templates/claude-md.d.ts.map +1 -1
- package/dist/cli/templates/claude-md.js +42 -11
- package/dist/cli/templates/claude-md.js.map +1 -1
- package/dist/cli/templates/hookify-rules.d.ts +22 -0
- package/dist/cli/templates/hookify-rules.d.ts.map +1 -0
- package/dist/cli/templates/hookify-rules.js +57 -0
- package/dist/cli/templates/hookify-rules.js.map +1 -0
- package/dist/index.js +480 -150
- package/dist/index.js.map +1 -1
- package/dist/sanitization.d.ts +68 -0
- package/dist/sanitization.d.ts.map +1 -0
- package/dist/sanitization.js +236 -0
- package/dist/sanitization.js.map +1 -0
- package/dist/sanitization.spec.d.ts +2 -0
- package/dist/sanitization.spec.d.ts.map +1 -0
- package/dist/sanitization.spec.js +90 -0
- package/dist/sanitization.spec.js.map +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -22,9 +22,12 @@ cd your-project
|
|
|
22
22
|
npx @spilno/herald-mcp init
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
**
|
|
25
|
+
**What this does:**
|
|
26
|
+
1. Creates `.mcp.json` with Herald MCP configuration
|
|
27
|
+
2. Fetches learned patterns from CEDA (if any exist)
|
|
28
|
+
3. Creates/updates `CLAUDE.md` with patterns baked in
|
|
26
29
|
|
|
27
|
-
|
|
30
|
+
Company and project default to your folder name. Zero config.
|
|
28
31
|
|
|
29
32
|
## Init Options
|
|
30
33
|
|
|
@@ -34,23 +37,63 @@ npx @spilno/herald-mcp init [options]
|
|
|
34
37
|
|
|
35
38
|
| Option | Description |
|
|
36
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") |
|
|
37
45
|
| `--force`, `-f` | Overwrite existing config |
|
|
38
|
-
| `--no-claude-md` | Skip CLAUDE.md modification |
|
|
39
46
|
| `--help`, `-h` | Show help |
|
|
40
47
|
|
|
41
|
-
|
|
48
|
+
**Examples:**
|
|
49
|
+
```bash
|
|
50
|
+
# Basic setup (zero config)
|
|
51
|
+
npx @spilno/herald-mcp init
|
|
52
|
+
|
|
53
|
+
# Sync latest patterns to CLAUDE.md
|
|
54
|
+
npx @spilno/herald-mcp init --sync
|
|
55
|
+
|
|
56
|
+
# Add auto-reminder hooks
|
|
57
|
+
npx @spilno/herald-mcp init --hookify
|
|
58
|
+
|
|
59
|
+
# Custom context
|
|
60
|
+
npx @spilno/herald-mcp init --company acme --project safety
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Pattern Inheritance
|
|
64
|
+
|
|
65
|
+
Patterns cascade from specific to broad:
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
user (your personal patterns)
|
|
69
|
+
↓ inherits from
|
|
70
|
+
project (team patterns)
|
|
71
|
+
↓ inherits from
|
|
72
|
+
company (org-wide patterns)
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
More specific patterns take precedence. If you have a pattern and your company has the same one, yours wins.
|
|
76
|
+
|
|
77
|
+
## MCP Resources
|
|
78
|
+
|
|
79
|
+
Herald exposes patterns as MCP resources (auto-readable by Claude Code):
|
|
80
|
+
|
|
81
|
+
| Resource | Description |
|
|
82
|
+
|----------|-------------|
|
|
83
|
+
| `herald://patterns` | Learned patterns for current context |
|
|
84
|
+
| `herald://context` | Current configuration (company/project/user) |
|
|
42
85
|
|
|
43
86
|
## Core Tools
|
|
44
87
|
|
|
45
88
|
| Tool | Purpose |
|
|
46
89
|
|------|---------|
|
|
47
|
-
| `herald_patterns` | Query what worked before |
|
|
90
|
+
| `herald_patterns` | Query what worked before (with inheritance) |
|
|
48
91
|
| `herald_reflect` | Capture patterns and antipatterns |
|
|
49
92
|
| `herald_predict` | Generate structure from natural language |
|
|
50
93
|
| `herald_refine` | Refine predictions with feedback |
|
|
51
94
|
| `herald_feedback` | Reinforce helpful patterns |
|
|
52
95
|
|
|
53
|
-
|
|
96
|
+
### Pattern Capture
|
|
54
97
|
|
|
55
98
|
When something works or fails, capture it:
|
|
56
99
|
|
|
@@ -59,86 +102,49 @@ User: "Herald reflect - that was smooth"
|
|
|
59
102
|
Claude: "What specifically worked?"
|
|
60
103
|
User: "The ASCII visualization approach"
|
|
61
104
|
→ Pattern captured, available in future sessions
|
|
105
|
+
```
|
|
62
106
|
|
|
107
|
+
```
|
|
63
108
|
User: "Herald reflect - that was rough"
|
|
64
109
|
Claude: "What went wrong?"
|
|
65
110
|
User: "Forgot to check existing tests before refactoring"
|
|
66
111
|
→ Antipattern captured, Claude will avoid this
|
|
67
112
|
```
|
|
68
113
|
|
|
69
|
-
##
|
|
114
|
+
## Hookify Integration
|
|
70
115
|
|
|
71
|
-
|
|
116
|
+
Add auto-reminders with `--hookify`:
|
|
72
117
|
|
|
118
|
+
```bash
|
|
119
|
+
npx @spilno/herald-mcp init --hookify
|
|
73
120
|
```
|
|
74
|
-
~/Documents/acme-corp/safety-app
|
|
75
|
-
↓
|
|
76
|
-
Tags: ["acme-corp", "safety-app"]
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
Patterns are matched by **tag overlap**, not rigid hierarchy:
|
|
80
|
-
- Your patterns in `project-a` can help in `project-b` if they share tags
|
|
81
|
-
- No need to configure company/project/user upfront
|
|
82
|
-
- Structure emerges from usage, not configuration
|
|
83
121
|
|
|
84
|
-
|
|
122
|
+
This creates rules in `.claude/` that:
|
|
123
|
+
- **On prompt**: Remind to check patterns at session start
|
|
124
|
+
- **On session end**: Remind to capture patterns before leaving
|
|
85
125
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
```
|
|
89
|
-
CREATOR → Only you see it
|
|
90
|
-
↓
|
|
91
|
-
TAGS → Users with overlapping context tags see it
|
|
92
|
-
↓
|
|
93
|
-
GLOBAL → Everyone sees it (anonymized)
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
Reach expands when others validate your patterns work for them too.
|
|
126
|
+
Requires [hookify plugin](https://github.com/anthropics/claude-code/tree/main/plugins/hookify).
|
|
97
127
|
|
|
98
128
|
## Configuration
|
|
99
129
|
|
|
100
|
-
### Files Created
|
|
130
|
+
### Files Created
|
|
101
131
|
|
|
102
132
|
| File | Purpose |
|
|
103
133
|
|------|---------|
|
|
104
|
-
| `.
|
|
105
|
-
| `CLAUDE.md` | Project instructions with
|
|
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) |
|
|
106
137
|
|
|
107
138
|
### Environment Variables
|
|
108
139
|
|
|
109
140
|
| Variable | Default | Description |
|
|
110
141
|
|----------|---------|-------------|
|
|
111
|
-
| `CEDA_URL` |
|
|
112
|
-
| `
|
|
113
|
-
|
|
114
|
-
|
|
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 |
|
|
115
146
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
If `herald health` shows an old version after updating:
|
|
119
|
-
|
|
120
|
-
```bash
|
|
121
|
-
# Clear npx cache
|
|
122
|
-
rm -rf ~/.npm/_npx/*
|
|
123
|
-
|
|
124
|
-
# Verify latest version
|
|
125
|
-
npm view @spilno/herald-mcp version
|
|
126
|
-
|
|
127
|
-
# Restart Claude Code
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
The `@latest` tag can be cached by npx. Clearing the cache forces a fresh fetch.
|
|
131
|
-
|
|
132
|
-
### Verify installation
|
|
133
|
-
|
|
134
|
-
```bash
|
|
135
|
-
# Check what npm registry has
|
|
136
|
-
npm view @spilno/herald-mcp version
|
|
137
|
-
|
|
138
|
-
# Should match what herald health shows
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
## Architecture
|
|
147
|
+
## How It Works
|
|
142
148
|
|
|
143
149
|
```
|
|
144
150
|
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
|
|
@@ -148,16 +154,17 @@ npm view @spilno/herald-mcp version
|
|
|
148
154
|
└─────────────┘ └─────────────┘ └─────────────┘
|
|
149
155
|
│ │
|
|
150
156
|
│ ┌──────┴──────┐
|
|
151
|
-
│ │
|
|
152
|
-
└───────────▶│
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
Context derived from folder path → Tags
|
|
157
|
-
Patterns matched by tag overlap
|
|
158
|
-
Reach expands through adoption
|
|
157
|
+
│ │ Patterns │
|
|
158
|
+
└───────────▶│ Antipatterns│
|
|
159
|
+
(auto-reads │ Inheritance │
|
|
160
|
+
resources) └─────────────┘
|
|
159
161
|
```
|
|
160
162
|
|
|
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
|
+
|
|
161
168
|
## What is CEDA?
|
|
162
169
|
|
|
163
170
|
CEDA (Cognitive Event-Driven Architecture) is pattern memory for AI:
|
|
@@ -180,4 +187,4 @@ MIT
|
|
|
180
187
|
|
|
181
188
|
---
|
|
182
189
|
|
|
183
|
-
*Herald v1.
|
|
190
|
+
*Herald v1.25.0 — Pattern memory for AI agents*
|
package/dist/cli/init.d.ts
CHANGED
|
@@ -10,7 +10,12 @@
|
|
|
10
10
|
export interface InitOptions {
|
|
11
11
|
force?: boolean;
|
|
12
12
|
help?: boolean;
|
|
13
|
+
company?: string;
|
|
14
|
+
project?: string;
|
|
15
|
+
user?: string;
|
|
13
16
|
noClaudeMd?: boolean;
|
|
17
|
+
sync?: boolean;
|
|
18
|
+
hookify?: boolean;
|
|
14
19
|
}
|
|
15
20
|
export declare function parseInitArgs(args: string[]): InitOptions;
|
|
16
21
|
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,UAAU,CAAC,EAAE,OAAO,CAAC;
|
|
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,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,WAAW,CAyBzD;AA+CD,wBAAsB,OAAO,CAAC,IAAI,GAAE,MAAM,EAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAyIhE"}
|
package/dist/cli/init.js
CHANGED
|
@@ -10,24 +10,20 @@
|
|
|
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
|
-
|
|
15
|
-
* No need for HERALD_COMPANY/PROJECT - context is AI-native
|
|
16
|
-
*/
|
|
17
|
-
function buildHeraldConfig() {
|
|
13
|
+
import { getHookifyRulesContent } from "./templates/hookify-rules.js";
|
|
14
|
+
function buildHeraldConfig(company, project) {
|
|
18
15
|
return {
|
|
19
16
|
mcpServers: {
|
|
20
17
|
herald: {
|
|
21
18
|
command: "npx",
|
|
22
19
|
args: ["@spilno/herald-mcp@latest"],
|
|
23
20
|
env: {
|
|
24
|
-
CEDA_URL: "https://getceda.com"
|
|
25
|
-
|
|
21
|
+
CEDA_URL: "https://getceda.com",
|
|
22
|
+
HERALD_COMPANY: company,
|
|
23
|
+
HERALD_PROJECT: project
|
|
26
24
|
}
|
|
27
25
|
}
|
|
28
|
-
}
|
|
29
|
-
// Required for project-level MCP servers to load properly
|
|
30
|
-
enableAllProjectMcpServers: true
|
|
26
|
+
}
|
|
31
27
|
};
|
|
32
28
|
}
|
|
33
29
|
function printInitHelp() {
|
|
@@ -40,16 +36,21 @@ Usage:
|
|
|
40
36
|
|
|
41
37
|
That's it. Company and project default to folder name.
|
|
42
38
|
|
|
43
|
-
Options
|
|
44
|
-
--
|
|
39
|
+
Options:
|
|
40
|
+
--sync, -s Sync patterns to CLAUDE.md (quick update, no full init)
|
|
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
|
|
45
46
|
--no-claude-md Skip CLAUDE.md modification
|
|
46
47
|
--help, -h Show this help
|
|
47
48
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
Example:
|
|
51
|
-
cd my-project
|
|
49
|
+
Examples:
|
|
52
50
|
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
|
|
53
54
|
|
|
54
55
|
Then start Claude Code and say "herald health" to verify.
|
|
55
56
|
`);
|
|
@@ -64,93 +65,140 @@ export function parseInitArgs(args) {
|
|
|
64
65
|
else if (arg === "--force" || arg === "-f") {
|
|
65
66
|
options.force = true;
|
|
66
67
|
}
|
|
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
|
+
}
|
|
67
77
|
else if (arg === "--no-claude-md") {
|
|
68
78
|
options.noClaudeMd = true;
|
|
69
79
|
}
|
|
80
|
+
else if (arg === "--sync" || arg === "-s") {
|
|
81
|
+
options.sync = true;
|
|
82
|
+
}
|
|
83
|
+
else if (arg === "--hookify") {
|
|
84
|
+
options.hookify = true;
|
|
85
|
+
}
|
|
70
86
|
}
|
|
71
87
|
return options;
|
|
72
88
|
}
|
|
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
|
+
}
|
|
73
125
|
export async function runInit(args = []) {
|
|
74
126
|
const options = parseInitArgs(args);
|
|
75
127
|
if (options.help) {
|
|
76
128
|
printInitHelp();
|
|
77
129
|
return;
|
|
78
130
|
}
|
|
79
|
-
// CEDA-67: Simplified setup - no company/project config needed
|
|
80
131
|
const cwd = process.cwd();
|
|
81
132
|
const projectName = basename(cwd);
|
|
82
|
-
const
|
|
83
|
-
const settingsPath = join(claudeDir, "settings.local.json");
|
|
133
|
+
const mcpJsonPath = join(cwd, ".mcp.json");
|
|
84
134
|
const claudeMdPath = join(cwd, "CLAUDE.md");
|
|
85
|
-
//
|
|
86
|
-
|
|
135
|
+
// Quick sync mode: just update CLAUDE.md with latest patterns
|
|
136
|
+
if (options.sync) {
|
|
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;
|
|
87
142
|
const context = {
|
|
88
|
-
company
|
|
89
|
-
project
|
|
90
|
-
user:
|
|
143
|
+
company,
|
|
144
|
+
project,
|
|
145
|
+
user: options.user || "default",
|
|
91
146
|
};
|
|
92
|
-
// Check for old herald configs and warn
|
|
93
|
-
const
|
|
147
|
+
// Check for old herald configs and warn about migration
|
|
148
|
+
const oldClaudeDir = join(cwd, ".claude");
|
|
149
|
+
const oldSettingsPath = join(oldClaudeDir, "settings.local.json");
|
|
94
150
|
if (existsSync(oldSettingsPath)) {
|
|
95
151
|
try {
|
|
96
152
|
const oldConfig = JSON.parse(readFileSync(oldSettingsPath, "utf-8"));
|
|
97
153
|
if (oldConfig.mcpServers?.herald) {
|
|
98
|
-
console.log("⚠️ Found old Herald config in
|
|
154
|
+
console.log("⚠️ Found old Herald config in .claude/settings.local.json");
|
|
155
|
+
console.log(" This location is no longer supported. Migrating to .mcp.json");
|
|
99
156
|
}
|
|
100
157
|
}
|
|
101
158
|
catch { /* ignore */ }
|
|
102
159
|
}
|
|
103
|
-
if (existsSync(
|
|
160
|
+
if (existsSync(mcpJsonPath) && !options.force) {
|
|
104
161
|
console.log(`
|
|
105
|
-
.
|
|
162
|
+
.mcp.json already exists.
|
|
106
163
|
|
|
107
164
|
To view current config:
|
|
108
|
-
cat .
|
|
165
|
+
cat .mcp.json
|
|
109
166
|
|
|
110
167
|
To overwrite:
|
|
111
168
|
npx @spilno/herald-mcp init --force
|
|
112
169
|
`);
|
|
113
170
|
return;
|
|
114
171
|
}
|
|
115
|
-
|
|
116
|
-
mkdirSync(claudeDir, { recursive: true });
|
|
117
|
-
console.log("Created .claude directory");
|
|
118
|
-
}
|
|
119
|
-
const heraldConfig = buildHeraldConfig();
|
|
172
|
+
const heraldConfig = buildHeraldConfig(company, project);
|
|
120
173
|
let finalConfig = heraldConfig;
|
|
121
|
-
if (existsSync(
|
|
122
|
-
// Merge mode: preserve existing config, add/update Herald
|
|
174
|
+
if (existsSync(mcpJsonPath)) {
|
|
123
175
|
try {
|
|
124
|
-
const existingContent = readFileSync(
|
|
176
|
+
const existingContent = readFileSync(mcpJsonPath, "utf-8");
|
|
125
177
|
const existingConfig = JSON.parse(existingContent);
|
|
126
178
|
finalConfig = {
|
|
127
179
|
...existingConfig,
|
|
128
180
|
mcpServers: {
|
|
129
181
|
...existingConfig.mcpServers,
|
|
130
182
|
...heraldConfig.mcpServers
|
|
131
|
-
}
|
|
132
|
-
enableAllProjectMcpServers: true
|
|
183
|
+
}
|
|
133
184
|
};
|
|
134
|
-
console.log("Merging with existing
|
|
185
|
+
console.log("Merging with existing .mcp.json");
|
|
135
186
|
}
|
|
136
187
|
catch {
|
|
137
|
-
console.log("Overwriting invalid
|
|
188
|
+
console.log("Overwriting invalid .mcp.json");
|
|
138
189
|
}
|
|
139
190
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
143
|
-
writeFileSync(settingsPath, JSON.stringify(finalConfig, null, 2) + "\n", "utf-8");
|
|
144
|
-
console.log("✓ Created .claude/settings.local.json");
|
|
191
|
+
writeFileSync(mcpJsonPath, JSON.stringify(finalConfig, null, 2) + "\n", "utf-8");
|
|
192
|
+
console.log("✓ Created .mcp.json");
|
|
145
193
|
if (!options.noClaudeMd) {
|
|
146
194
|
let existingClaudeMd = null;
|
|
147
195
|
if (existsSync(claudeMdPath)) {
|
|
148
196
|
existingClaudeMd = readFileSync(claudeMdPath, "utf-8");
|
|
149
197
|
}
|
|
150
|
-
// Fetch learned patterns from CEDA
|
|
198
|
+
// Fetch learned patterns from CEDA
|
|
151
199
|
const cedaUrl = "https://getceda.com";
|
|
152
200
|
console.log("Fetching learned patterns from CEDA...");
|
|
153
|
-
const learnedPatterns = await fetchLearnedPatterns(cedaUrl,
|
|
201
|
+
const learnedPatterns = await fetchLearnedPatterns(cedaUrl, company, project);
|
|
154
202
|
if (learnedPatterns) {
|
|
155
203
|
const totalPatterns = learnedPatterns.patterns.length + learnedPatterns.antipatterns.length;
|
|
156
204
|
if (totalPatterns > 0) {
|
|
@@ -166,11 +214,27 @@ To overwrite:
|
|
|
166
214
|
console.log("Created CLAUDE.md with Herald integration");
|
|
167
215
|
}
|
|
168
216
|
}
|
|
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
|
+
}
|
|
169
232
|
console.log(`
|
|
170
233
|
✓ Herald configured
|
|
171
234
|
|
|
172
|
-
|
|
173
|
-
|
|
235
|
+
Company: ${company}
|
|
236
|
+
Project: ${project}
|
|
237
|
+
Backend: https://getceda.com
|
|
174
238
|
|
|
175
239
|
Next: Start Claude Code in this directory.
|
|
176
240
|
Say "herald health" to verify.
|
|
@@ -178,8 +242,6 @@ Next: Start Claude Code in this directory.
|
|
|
178
242
|
Capture patterns:
|
|
179
243
|
Say "Herald reflect - that was smooth"
|
|
180
244
|
Claude asks what worked → you answer → saved.
|
|
181
|
-
|
|
182
|
-
Tags are derived from your folder path - no configuration needed.
|
|
183
245
|
`);
|
|
184
246
|
}
|
|
185
247
|
//# 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
|
+
{"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;AAC3G,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAEtE,SAAS,iBAAiB,CAAC,OAAe,EAAE,OAAe;IACzD,OAAO;QACL,UAAU,EAAE;YACV,MAAM,EAAE;gBACN,OAAO,EAAE,KAAK;gBACd,IAAI,EAAE,CAAC,2BAA2B,CAAC;gBACnC,GAAG,EAAE;oBACH,QAAQ,EAAE,qBAAqB;oBAC/B,cAAc,EAAE,OAAO;oBACvB,cAAc,EAAE,OAAO;iBACxB;aACF;SACF;KACF,CAAC;AACJ,CAAC;AAED,SAAS,aAAa;IACpB,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;CA0Bb,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AO;cACP,OAAO;;;;;;;;;CASpB,CAAC,CAAC;AACH,CAAC"}
|
|
@@ -13,15 +13,17 @@ export interface LearnedPatterns {
|
|
|
13
13
|
patterns: Array<{
|
|
14
14
|
insight: string;
|
|
15
15
|
reinforcement?: string;
|
|
16
|
+
scope?: string;
|
|
16
17
|
}>;
|
|
17
18
|
antipatterns: Array<{
|
|
18
19
|
insight: string;
|
|
19
20
|
warning?: string;
|
|
21
|
+
scope?: string;
|
|
20
22
|
}>;
|
|
21
23
|
}
|
|
22
24
|
export declare const HERALD_SECTION_MARKER = "## Herald Integration";
|
|
23
25
|
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";
|
|
24
26
|
export declare function renderHeraldSection(context: HeraldContext, learnedPatterns?: LearnedPatterns): string;
|
|
25
|
-
export declare function fetchLearnedPatterns(cedaUrl: string, company: string, project: string): Promise<LearnedPatterns | null>;
|
|
27
|
+
export declare function fetchLearnedPatterns(cedaUrl: string, company: string, project: string, user?: string): Promise<LearnedPatterns | null>;
|
|
26
28
|
export declare function updateClaudeMdContent(existingContent: string | null, context: HeraldContext, projectName: string, learnedPatterns?: LearnedPatterns): string;
|
|
27
29
|
//# 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,IAA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
|
@@ -29,10 +29,12 @@ export function renderHeraldSection(context, learnedPatterns) {
|
|
|
29
29
|
let learnedSection = "";
|
|
30
30
|
if (learnedPatterns && (learnedPatterns.antipatterns.length > 0 || learnedPatterns.patterns.length > 0)) {
|
|
31
31
|
learnedSection = "### Learned from Past Sessions\n\n";
|
|
32
|
+
learnedSection += `*Inheritance: ${context.user}→${context.project}→${context.company}*\n\n`;
|
|
32
33
|
if (learnedPatterns.antipatterns.length > 0) {
|
|
33
34
|
learnedSection += "**Antipatterns (AVOID THESE):**\n";
|
|
34
35
|
learnedPatterns.antipatterns.slice(0, 5).forEach((ap, i) => {
|
|
35
|
-
|
|
36
|
+
const scopeTag = ap.scope ? ` [${ap.scope}]` : "";
|
|
37
|
+
learnedSection += `${i + 1}. ${ap.insight}${scopeTag}`;
|
|
36
38
|
if (ap.warning)
|
|
37
39
|
learnedSection += ` → ${ap.warning}`;
|
|
38
40
|
learnedSection += "\n";
|
|
@@ -42,7 +44,8 @@ export function renderHeraldSection(context, learnedPatterns) {
|
|
|
42
44
|
if (learnedPatterns.patterns.length > 0) {
|
|
43
45
|
learnedSection += "**Patterns (DO THESE):**\n";
|
|
44
46
|
learnedPatterns.patterns.slice(0, 5).forEach((p, i) => {
|
|
45
|
-
|
|
47
|
+
const scopeTag = p.scope ? ` [${p.scope}]` : "";
|
|
48
|
+
learnedSection += `${i + 1}. ${p.insight}${scopeTag}`;
|
|
46
49
|
if (p.reinforcement)
|
|
47
50
|
learnedSection += ` → ${p.reinforcement}`;
|
|
48
51
|
learnedSection += "\n";
|
|
@@ -55,17 +58,45 @@ export function renderHeraldSection(context, learnedPatterns) {
|
|
|
55
58
|
.replace("{{user}}", context.user)
|
|
56
59
|
.replace("{{learned_patterns}}", learnedSection);
|
|
57
60
|
}
|
|
58
|
-
export async function fetchLearnedPatterns(cedaUrl, company, project) {
|
|
61
|
+
export async function fetchLearnedPatterns(cedaUrl, company, project, user = "default") {
|
|
59
62
|
try {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
// Cascade: user → project → company (more specific wins)
|
|
64
|
+
const queries = [
|
|
65
|
+
`${cedaUrl}/api/herald/reflections?company=${company}&project=${project}&user=${user}&limit=10`,
|
|
66
|
+
`${cedaUrl}/api/herald/reflections?company=${company}&project=${project}&limit=10`,
|
|
67
|
+
`${cedaUrl}/api/herald/reflections?company=${company}&limit=10`,
|
|
68
|
+
];
|
|
69
|
+
const seenInsights = new Set();
|
|
70
|
+
const patterns = [];
|
|
71
|
+
const antipatterns = [];
|
|
72
|
+
const scopes = ["user", "project", "company"];
|
|
73
|
+
for (let i = 0; i < queries.length; i++) {
|
|
74
|
+
try {
|
|
75
|
+
const response = await fetch(queries[i]);
|
|
76
|
+
if (!response.ok)
|
|
77
|
+
continue;
|
|
78
|
+
const data = await response.json();
|
|
79
|
+
const scope = scopes[i];
|
|
80
|
+
for (const p of data.patterns || []) {
|
|
81
|
+
const key = p.insight.toLowerCase().trim();
|
|
82
|
+
if (!seenInsights.has(key)) {
|
|
83
|
+
seenInsights.add(key);
|
|
84
|
+
patterns.push({ ...p, scope });
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
for (const ap of data.antipatterns || []) {
|
|
88
|
+
const key = ap.insight.toLowerCase().trim();
|
|
89
|
+
if (!seenInsights.has(key)) {
|
|
90
|
+
seenInsights.add(key);
|
|
91
|
+
antipatterns.push({ ...ap, scope });
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
// Continue to next level
|
|
97
|
+
}
|
|
63
98
|
}
|
|
64
|
-
|
|
65
|
-
return {
|
|
66
|
-
patterns: data.patterns || [],
|
|
67
|
-
antipatterns: data.antipatterns || [],
|
|
68
|
-
};
|
|
99
|
+
return { patterns, antipatterns };
|
|
69
100
|
}
|
|
70
101
|
catch {
|
|
71
102
|
return null;
|