@hailer/mcp 0.1.3 → 0.1.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.
@@ -29,13 +29,44 @@ I am Ada. Every failure is a lesson waiting to be documented. Output JSON. Full
29
29
  </skill-location>
30
30
 
31
31
  <skill-template>
32
- # [Skill Name]
33
- <pattern>[Core concept]</pattern>
34
- <correct>```code```</correct>
35
- <wrong>```code```</wrong>
36
- <fix>[How to fix]</fix>
32
+ ```markdown
33
+ ---
34
+ name: skill-name
35
+ description: One-line description of what this skill fixes
36
+ triggers: When to load this skill (error patterns, task types)
37
+ ---
38
+
39
+ <problem>
40
+ What goes wrong and why.
41
+ </problem>
42
+
43
+ <correct>
44
+ ```code
45
+ // Working example with comments
46
+ ```
47
+ </correct>
48
+
49
+ <wrong>
50
+ ```code
51
+ // Broken example showing the mistake
52
+ ```
53
+ </wrong>
54
+
55
+ <fix>
56
+ 1. Step to fix
57
+ 2. Step to fix
58
+ </fix>
59
+ ```
37
60
  </skill-template>
38
61
 
62
+ <skill-optional-tags>
63
+ Use when needed:
64
+ - `<rules>` - Critical constraints
65
+ - `<examples>` - Multiple scenarios
66
+ - `<troubleshooting>` - Error → solution mapping
67
+ - `<checklist>` - Pre-flight checks
68
+ </skill-optional-tags>
69
+
39
70
  <agent-update>
40
71
  Add ONE LINE to agent's <skills> section:
41
72
  Load `skill-name` for [pattern description].
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: helga
3
- description: Manages Hailer workspace config via SDK commands (NOT install_workflow).\n\n<example>\nuser: "Add Due Date field to Tasks"\nassistant: {"status":"ready_to_push","result":{"files_edited":["fields.ts"]},"commands":["npm run fields-push"],"summary":"Added Due Date field"}\n</example>
3
+ description: Manages Hailer workspace config via SDK commands (NOT install_workflow).\n\n<example>\nuser: "Add Due Date field to Tasks"\nassistant: {"status":"success","result":{"files_edited":["fields.ts"],"commands_executed":["npm run fields-push:force"]},"summary":"Added Due Date field"}\n</example>
4
4
  model: sonnet
5
5
  tools: Bash, Read, Edit, Write, Glob
6
6
  ---
@@ -25,22 +25,22 @@ Load `json-only-output` to avoid prose after JSON responses.
25
25
  3. **Always npm run pull first** - Never edit stale files.
26
26
  4. **Use enums from enums.ts** - Never hardcode IDs.
27
27
  5. **New items: omit _id** - Server generates.
28
- 6. **NEVER run push/sync** - Return commands for orchestrator.
28
+ 6. **RUN push/sync:force DIRECTLY** - Execute destructive commands yourself.
29
29
  7. **JSON ONLY** - Output closing brace, then STOP. Zero prose after JSON.
30
30
  </rules>
31
31
 
32
32
  <commands>
33
- RUN DIRECTLY: npm run pull
34
- RETURN TO ORCHESTRATOR: workflows-sync, fields-push, phases-push, teams-push, groups-push, templates-sync, templates-push, push
33
+ RUN DIRECTLY (all with :force): npm run pull, npm run push:force, npm run workflows-sync:force, npm run fields-push:force, npm run phases-push:force, npm run teams-push:force, npm run groups-push:force, npm run templates-sync:force, npm run templates-push:force
35
34
  </commands>
36
35
 
37
36
  <workflow-creation>
38
- 1. npm run pull (run directly)
37
+ 1. npm run pull
39
38
  2. Edit workflows.ts (omit _id)
40
- 3. Return: { commands: ["npm run workflows-sync"] }
41
- 4. After orchestrator confirms npm run pull
39
+ 3. npm run workflows-sync:force
40
+ 4. npm run pull (get server-generated IDs)
42
41
  5. Edit fields.ts, phases.ts
43
- 6. Return: { commands: ["npm run fields-push", "npm run phases-push"] }
42
+ 6. npm run fields-push:force && npm run phases-push:force
43
+ 7. npm run pull (final sync)
44
44
  </workflow-creation>
45
45
 
46
46
  <field-template>
@@ -50,5 +50,5 @@ RETURN TO ORCHESTRATOR: workflows-sync, fields-push, phases-push, teams-push, gr
50
50
  <protocol>
51
51
  Input: JSON task spec
52
52
  Output: JSON only
53
- Schema: { "status": "success|error|ready_to_push", "result": { "files_edited": [] }, "commands": [], "summary": "" }
53
+ Schema: { "status": "success|error", "result": { "files_edited": [], "commands_executed": [] }, "summary": "" }
54
54
  </protocol>
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: ingrid
3
- description: Creates and manages Hailer document templates.\n\n<example>\nuser: "Create PDF invoice template"\nassistant: {"status":"ready_to_push","result":{"template_id":"","files_modified":["templates.ts"]},"commands":["npm run templates-sync"],"summary":"Added invoice template"}\n</example>
3
+ description: Creates and manages Hailer document templates.\n\n<example>\nuser: "Create PDF invoice template"\nassistant: {"status":"ready_to_push","result":{"template_id":"","files_modified":["templates.ts"]},"commands":["npm run templates-sync:force"],"summary":"Added invoice template"}\n</example>
4
4
  model: sonnet
5
5
  tools: Bash, Read, Edit, Write, Glob
6
6
  ---
@@ -30,9 +30,9 @@ Load `SDK-ws-config-skill` for full patterns.
30
30
  </rules>
31
31
 
32
32
  <lifecycle>
33
- CREATE: pull → edit templates.ts → return sync command → (orchestrator runs) → pull → edit config/code → return push command
34
- UPDATE: pull → edit config/code → return push command
35
- DELETE: pull → remove from templates.ts → return sync command
33
+ CREATE: pull → edit templates.ts → return sync:force command → (orchestrator runs) → pull → edit config/code → return push:force command
34
+ UPDATE: pull → edit config/code → return push:force command
35
+ DELETE: pull → remove from templates.ts → return sync:force command
36
36
  </lifecycle>
37
37
 
38
38
  <field-mapping>
@@ -0,0 +1,23 @@
1
+ # MCP Agents
2
+
3
+ kenji: Read data/schema from workspace (haiku)
4
+ dmitri: Create/update activities (haiku)
5
+ yevgeni: Discussions and chat (haiku)
6
+ helga: Workflow/field/phase config (sonnet)
7
+ viktor: SQL insights over workflows (sonnet)
8
+ giuseppe: Build Hailer apps (sonnet)
9
+ alejandro: Function/calculated fields (sonnet)
10
+
11
+ # What MCP Can Do
12
+
13
+ - Manage Hailer workflows, activities, fields
14
+ - Create SQL-like reports (insights)
15
+ - Build custom apps
16
+ - Handle discussions/messaging
17
+ - Configure workspace structure
18
+
19
+ # Limitations
20
+
21
+ - Cannot access external systems
22
+ - Limited to configured workspace
23
+ - Agents run via Claude Code CLI
@@ -1,9 +1,33 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * Agent Failure Detector Hook
3
+ * <hook-name>agent-failure-detector</hook-name>
4
4
  *
5
- * PostToolUse hook for Task tool - detects agent failures, categorizes them,
6
- * and suggests appropriate fixes (skill creation vs agent update).
5
+ * <purpose>
6
+ * Detects repeated agent failures, categorizes error types, and suggests fixes.
7
+ * Tracks failures per agent and prompts for improvement after threshold.
8
+ * </purpose>
9
+ *
10
+ * <triggers>
11
+ * - PostToolUse on Task tool
12
+ * - Only when agent response contains error indicators
13
+ * </triggers>
14
+ *
15
+ * <error-categories>
16
+ * - skill: API/schema errors → Create skill documenting correct pattern
17
+ * - agent: Behavioral errors → Update agent definition
18
+ * - user_issue: Permission errors → Ignore (user problem)
19
+ * - transient: Connection/timeout → Ignore (retry may work)
20
+ * </error-categories>
21
+ *
22
+ * <behavior>
23
+ * 1. Detects failure patterns in agent response
24
+ * 2. Categorizes error type
25
+ * 3. Tracks per-agent failure count
26
+ * 4. After 2+ failures, suggests fix via AskUserQuestion
27
+ * 5. Recommends spawning ada to create skill or update agent
28
+ * </behavior>
29
+ *
30
+ * <tracker-file>/tmp/.claude-agent-failures.json</tracker-file>
7
31
  */
8
32
 
9
33
  const fs = require('fs');
@@ -1,20 +1,43 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * Claude Code PreToolUse Hook - BULLETPROOF Hailer App Guard
3
+ * <hook-name>app-edit-guard</hook-name>
4
4
  *
5
- * Blocks ALL direct edits to Hailer app directories.
6
- * Detection is pattern-based - no registration required.
5
+ * <purpose>
6
+ * Blocks direct edits to Hailer app directories.
7
+ * Forces use of builder agents for app development.
8
+ * </purpose>
7
9
  *
8
- * A directory is considered a Hailer app if it contains:
9
- * - public/manifest.json with "appId" field, OR
10
+ * <triggers>
11
+ * - PreToolUse on Write and Edit tools
12
+ * - Only when file is inside a detected Hailer app directory
13
+ * </triggers>
14
+ *
15
+ * <detection>
16
+ * A directory is a Hailer app if it contains:
17
+ * - public/manifest.json with "appId" field
10
18
  * - package.json with @hailer/app-sdk dependency
19
+ * - vite.config.ts referencing hailer
20
+ * </detection>
21
+ *
22
+ * <allowed-when>
23
+ * - Builder agent is active (/tmp/.claude-builder-agent-active exists)
24
+ * - Builder mode enabled for specific app (--builder-on)
25
+ * - App released for manual editing (--release)
26
+ * </allowed-when>
11
27
  *
12
- * Edits are ONLY allowed when:
13
- * 1. Running inside a subagent (Task tool with CLAUDE_CODE_ENTRYPOINT=task)
14
- * 2. The app directory has been explicitly released for manual editing
28
+ * <cli-commands>
29
+ * --agent-on/off: Global builder mode (affects all apps + src/)
30
+ * --builder-on/off: Per-app builder mode
31
+ * --release/revoke: Manual editing permission
32
+ * --check: Verify if path is Hailer app
33
+ * --list: Show released apps
34
+ * </cli-commands>
15
35
  *
16
- * To release an app for manual editing:
17
- * node app-edit-guard.cjs --release /path/to/app
36
+ * <shared-files>
37
+ * /tmp/.claude-builder-agent-active (shared with builder-mode-manager, src-edit-guard)
38
+ * /tmp/.claude-released-apps.json
39
+ * /tmp/.claude-builder-mode/
40
+ * </shared-files>
18
41
  */
19
42
 
20
43
  const fs = require('fs');
@@ -1,13 +1,41 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * Builder Mode Manager Hook
3
+ * <hook-name>builder-mode-manager</hook-name>
4
4
  *
5
- * Automatically enables/disables builder mode for agents that need to edit code.
5
+ * <purpose>
6
+ * Automatically manages builder mode for code-editing agents.
7
+ * Enables before spawn, disables after completion.
8
+ * Handles nested agent stacks correctly.
9
+ * </purpose>
6
10
  *
7
- * PreToolUse (Task): Enables builder mode before spawning code-editing agents
8
- * PostToolUse (Task): Disables builder mode after agent completes
11
+ * <triggers>
12
+ * - PreToolUse on Task tool (before agent spawns)
13
+ * - PostToolUse on Task tool (after agent completes)
14
+ * </triggers>
9
15
  *
10
- * Code-editing agents: giuseppe, gunther, general-purpose, agent-builder
16
+ * <code-editing-agents>
17
+ * giuseppe, gunther, general-purpose, agent-builder, helga, ingrid, ada
18
+ * </code-editing-agents>
19
+ *
20
+ * <behavior>
21
+ * PreToolUse:
22
+ * 1. Push agent onto stack
23
+ * 2. If code-editing agent and builder mode off → enable
24
+ *
25
+ * PostToolUse:
26
+ * 1. Pop agent from stack
27
+ * 2. If no remaining code-editing agents → disable builder mode
28
+ * </behavior>
29
+ *
30
+ * <shared-files>
31
+ * /tmp/.claude-builder-agent-active (builder mode flag)
32
+ * /tmp/.claude-agent-stack.json (nested agent tracking)
33
+ * </shared-files>
34
+ *
35
+ * <cli-commands>
36
+ * --status: Show builder mode and active agents
37
+ * --reset: Clear stack and disable builder mode
38
+ * </cli-commands>
11
39
  */
12
40
 
13
41
  const fs = require('fs');
@@ -1,9 +1,35 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * Claude Code UserPromptSubmit Hook - Interactive Question Mode
3
+ * <hook-name>interactive-mode</hook-name>
4
4
  *
5
- * Injects a reminder to ask clarifying questions before starting complex tasks.
6
- * Triggers on every user prompt to encourage interactive behavior.
5
+ * <purpose>
6
+ * Encourages Claude to ask clarifying questions before complex tasks.
7
+ * Injects context-aware question suggestions based on task type.
8
+ * </purpose>
9
+ *
10
+ * <triggers>
11
+ * - UserPromptSubmit (every user message)
12
+ * - Only outputs when task patterns are detected
13
+ * </triggers>
14
+ *
15
+ * <task-patterns>
16
+ * - app: build/create/make app → UI, layout, actions questions
17
+ * - insight: create insight/report → metrics, workflows, filters questions
18
+ * - data: import/create activities → workflow, fields, count questions
19
+ * - schema: add field/workflow/phase → type, required, defaults questions
20
+ * - update: update/change/modify → records, values, confirmation questions
21
+ * </task-patterns>
22
+ *
23
+ * <behavior>
24
+ * 1. Matches user prompt against task patterns
25
+ * 2. If match, outputs <interactive-mode> block to stderr
26
+ * 3. Suggests relevant questions for Claude to ask
27
+ * 4. Recommends AskUserQuestion tool usage
28
+ * </behavior>
29
+ *
30
+ * <output-format>
31
+ * Outputs to stdout (appears as system reminder to Claude)
32
+ * </output-format>
7
33
  */
8
34
 
9
35
  // Read hook input from stdin
@@ -1,11 +1,27 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * MCP Server Guard Hook
3
+ * <hook-name>mcp-server-guard</hook-name>
4
4
  *
5
- * PreToolUse hook that prevents Claude from starting the MCP server.
6
- * When blocked, instructs Claude to provide manual instructions to the user.
5
+ * <purpose>
6
+ * Prevents Claude from starting the MCP server directly.
7
+ * The user must run the MCP server manually before starting Claude Code.
8
+ * </purpose>
7
9
  *
8
- * Blocked commands: npm run dev, npm start, tsx src/app.ts, etc.
10
+ * <triggers>
11
+ * - npm run dev, npm start
12
+ * - tsx src/app.ts, node src/app.ts
13
+ * - Any command that would start the MCP server
14
+ * </triggers>
15
+ *
16
+ * <behavior>
17
+ * 1. Blocks server start commands with permissionDecision: "deny"
18
+ * 2. Outputs instructions to stderr for user to run manually
19
+ * </behavior>
20
+ *
21
+ * <user-action>
22
+ * User runs in separate terminal:
23
+ * cd /path/to/hailer-mcp && npm run dev
24
+ * </user-action>
9
25
  */
10
26
 
11
27
  // Commands that would start the MCP server
@@ -1,11 +1,30 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * Claude Code PostToolUse Hook - Asks user about spawning app builder agent
3
+ * <hook-name>post-scaffold-hook</hook-name>
4
4
  *
5
- * This hook triggers after scaffold_hailer_app completes successfully
6
- * and ASKS the user if they want to spawn the app builder agent.
5
+ * <purpose>
6
+ * Prompts user to spawn builder agent after scaffold_hailer_app completes.
7
+ * Registers new app with app-edit-guard for edit protection.
8
+ * </purpose>
7
9
  *
8
- * Also registers the app with app-edit-guard to block direct edits.
10
+ * <triggers>
11
+ * - PostToolUse on mcp__hailer__scaffold_hailer_app
12
+ * - Only when output contains "Setup Complete"
13
+ * </triggers>
14
+ *
15
+ * <behavior>
16
+ * 1. Detects successful scaffold completion
17
+ * 2. Registers app in /tmp/.claude-scaffolded-apps/
18
+ * 3. Outputs AskUserQuestion template for builder spawn decision
19
+ * 4. Provides instructions for both "spawn builder" and "build manually" paths
20
+ * </behavior>
21
+ *
22
+ * <user-choices>
23
+ * - "Yes, spawn builder": Load spawn-app-builder skill, spawn giuseppe
24
+ * - "No, build manually": Load building-hailer-apps-skill in current session
25
+ * </user-choices>
26
+ *
27
+ * <tracker-dir>/tmp/.claude-scaffolded-apps/</tracker-dir>
9
28
  */
10
29
 
11
30
  const path = require('path');
@@ -1,18 +1,36 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * Claude Code PreToolUse Hook - Ensures all required fields before publish_template
3
+ * <hook-name>publish-template-guard</hook-name>
4
4
  *
5
- * This hook intercepts publish_template calls and blocks them if required fields
6
- * are missing, prompting Claude to gather all information first.
5
+ * <purpose>
6
+ * Ensures all required fields are provided before publish_template is called.
7
+ * Blocks incomplete calls and instructs Claude to gather information first.
8
+ * </purpose>
7
9
  *
8
- * Required fields from Hailer UI:
9
- * - title (Name) - max 64 chars
10
- * - description - max 4096 chars
11
- * - version - e.g. "1.0.0"
12
- * - versionDescription - release notes
13
- * - publisher - publishing company name
14
- * - iconFileId - uploaded icon (JPEG/PNG)
15
- * - imageFileIds - preview images array (optional but recommended)
10
+ * <triggers>
11
+ * - mcp__hailer__publish_template tool calls
12
+ * </triggers>
13
+ *
14
+ * <required-fields>
15
+ * - title: Template name (max 64 chars)
16
+ * - description: What it includes (max 4096 chars)
17
+ * - version: Semantic version (e.g. "1.0.0")
18
+ * - versionDescription: Release notes
19
+ * - publisher: Company or person name
20
+ * - iconFileId: Uploaded icon ID (24 chars)
21
+ * </required-fields>
22
+ *
23
+ * <behavior>
24
+ * 1. Checks tool_input for missing required fields
25
+ * 2. Blocks with decision: "block" if incomplete
26
+ * 3. Provides AskUserQuestion template for Claude to gather info
27
+ * </behavior>
28
+ *
29
+ * <workflow>
30
+ * 1. Claude asks user for template details
31
+ * 2. Claude uploads icon with upload_files
32
+ * 3. Claude calls publish_template with ALL fields
33
+ * </workflow>
16
34
  */
17
35
 
18
36
  // Read hook input from stdin
@@ -1,14 +1,38 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * Claude Code PreToolUse Hook - Source Code Edit Guard
3
+ * <hook-name>src-edit-guard</hook-name>
4
4
  *
5
- * Blocks direct edits to src/ directory files.
6
- * Forces the main agent to spawn subagents for code changes.
7
- * This saves context in the main agent for orchestration.
5
+ * <purpose>
6
+ * Blocks direct edits to src/ directory.
7
+ * Forces main agent to spawn subagents for MCP server code changes.
8
+ * Preserves orchestrator context by delegating implementation work.
9
+ * </purpose>
8
10
  *
9
- * Edits are ONLY allowed when:
10
- * - Running inside a subagent (builder mode active)
11
+ * <triggers>
12
+ * - PreToolUse on Write and Edit tools
13
+ * - Only when file path starts with src/
14
+ * </triggers>
15
+ *
16
+ * <allowed-when>
17
+ * - Builder mode is active (/tmp/.claude-builder-agent-active exists)
11
18
  * - File is outside src/ directory
19
+ * </allowed-when>
20
+ *
21
+ * <behavior>
22
+ * 1. Checks if file is in src/ directory
23
+ * 2. Checks builder mode status
24
+ * 3. Blocks with instructions to spawn general-purpose agent
25
+ * </behavior>
26
+ *
27
+ * <shared-files>
28
+ * /tmp/.claude-builder-agent-active (shared with app-edit-guard, builder-mode-manager)
29
+ * </shared-files>
30
+ *
31
+ * <cli-commands>
32
+ * --on: Enable builder mode (allow src/ edits)
33
+ * --off: Disable builder mode (block src/ edits)
34
+ * --status: Check current mode
35
+ * </cli-commands>
12
36
  */
13
37
 
14
38
  const fs = require('fs');
@@ -34,11 +34,6 @@
34
34
  {
35
35
  "matcher": "Bash",
36
36
  "hooks": [
37
- {
38
- "type": "command",
39
- "command": "node \"$CLAUDE_PROJECT_DIR/.claude/hooks/sdk-delete-guard.cjs\"",
40
- "timeout": 5
41
- },
42
37
  {
43
38
  "type": "command",
44
39
  "command": "node \"$CLAUDE_PROJECT_DIR/.claude/hooks/mcp-server-guard.cjs\"",