@thebushidocollective/han 1.49.1 → 1.49.3

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.
Files changed (36) hide show
  1. package/dist/lib/build-info.generated.d.ts +1 -1
  2. package/dist/lib/build-info.generated.js +1 -1
  3. package/dist/lib/commands/mcp/index.d.ts.map +1 -1
  4. package/dist/lib/commands/mcp/index.js +12 -1
  5. package/dist/lib/commands/mcp/index.js.map +1 -1
  6. package/dist/lib/commands/mcp/metrics.d.ts +5 -0
  7. package/dist/lib/commands/mcp/metrics.d.ts.map +1 -0
  8. package/dist/lib/commands/mcp/metrics.js +386 -0
  9. package/dist/lib/commands/mcp/metrics.js.map +1 -0
  10. package/dist/lib/commands/metrics/display-plain.d.ts +6 -0
  11. package/dist/lib/commands/metrics/display-plain.d.ts.map +1 -0
  12. package/dist/lib/commands/metrics/display-plain.js +261 -0
  13. package/dist/lib/commands/metrics/display-plain.js.map +1 -0
  14. package/dist/lib/commands/metrics/display.d.ts +12 -0
  15. package/dist/lib/commands/metrics/display.d.ts.map +1 -0
  16. package/dist/lib/commands/metrics/display.js +110 -0
  17. package/dist/lib/commands/metrics/display.js.map +1 -0
  18. package/dist/lib/commands/metrics/index.d.ts +6 -0
  19. package/dist/lib/commands/metrics/index.d.ts.map +1 -0
  20. package/dist/lib/commands/metrics/index.js +48 -0
  21. package/dist/lib/commands/metrics/index.js.map +1 -0
  22. package/dist/lib/commands/metrics/show.d.ts +11 -0
  23. package/dist/lib/commands/metrics/show.d.ts.map +1 -0
  24. package/dist/lib/commands/metrics/show.js +50 -0
  25. package/dist/lib/commands/metrics/show.js.map +1 -0
  26. package/dist/lib/main.js +2 -0
  27. package/dist/lib/main.js.map +1 -1
  28. package/dist/lib/metrics/storage.d.ts +55 -0
  29. package/dist/lib/metrics/storage.d.ts.map +1 -0
  30. package/dist/lib/metrics/storage.js +281 -0
  31. package/dist/lib/metrics/storage.js.map +1 -0
  32. package/dist/lib/metrics/types.d.ts +95 -0
  33. package/dist/lib/metrics/types.d.ts.map +1 -0
  34. package/dist/lib/metrics/types.js +2 -0
  35. package/dist/lib/metrics/types.js.map +1 -0
  36. package/package.json +8 -6
@@ -1,3 +1,3 @@
1
- export declare const HAN_VERSION = "1.49.1";
1
+ export declare const HAN_VERSION = "1.49.3";
2
2
  export declare const DETECT_PLUGINS_PROMPT = "<!--\nThis prompt template is dynamically enhanced in shared.ts with:\n1. GIT REPOSITORY section - Remote URL to determine hosting platform (GitHub, GitLab, etc.)\n2. CURRENTLY INSTALLED PLUGINS section - List of plugins already installed (if any)\n3. CODEBASE STATISTICS section - File extensions and config file names from codebase-analyzer.ts\n4. AVAILABLE PLUGINS IN MARKETPLACE section - Plugin list from marketplace.json\n\nThese sections are appended to this base prompt at runtime.\n-->\n\n# Han Plugin Installer Assistant\n\nYou are a Han plugin installer assistant. Your goal is to analyze the current codebase and recommend appropriate Claude Code plugins from the Han marketplace.\n\nThe available plugins from the marketplace are provided below. ONLY recommend plugins from this list.\n\n## Plugin Categories\n\n- **jutsu-\\*** (\u6B66\u5668 weapons): Skills for specific technologies and frameworks\n- **do-\\*** (\u9053 disciplines): Specialized agents for development practices and workflows\n- **hashi-\\*** (\u5148\u751F teachers): MCP servers for external integrations\n- **bushido**: Core quality principles (ALWAYS recommend this)\n\n## Your Analysis Process\n\n### STEP 1: Analyze currently installed plugins (if provided)\n\n- Check if CURRENTLY INSTALLED PLUGINS section is provided in the prompt\n- If provided, you should:\n - **Understand why each plugin was likely added**: Look at plugin descriptions and infer original use case\n - Example: `jutsu-typescript` suggests TypeScript development\n - Example: `hashi-github` suggests GitHub integration needs\n - Example: `do-frontend-development` suggests frontend focus\n - **Determine if each plugin is still relevant**:\n - Use the codebase statistics and configuration files to verify if the technology/practice is still in use\n - A plugin is still relevant if its associated technology/practice is actively used in the codebase\n - A plugin may be irrelevant if:\n - The technology was removed (e.g., no more .ts files but jutsu-typescript is installed)\n - The project migrated to a different platform (e.g., moved from GitHub to GitLab)\n - The framework changed (e.g., migrated from React to Vue)\n - **Keep relevant plugins in your recommendations**: If a plugin is still relevant, include it in your final list\n - **Exclude irrelevant plugins**: If a plugin is no longer needed, do not include it in your recommendations\n\n### STEP 2: Check git repository hosting platform (if provided)\n\n- Check if GIT REPOSITORY section is provided in the prompt\n- If provided, examine the remote URL to determine the hosting platform:\n - URLs containing `github.com` \u2192 recommend `hashi-github`\n - URLs containing `gitlab.com` or other GitLab instances \u2192 recommend `hashi-gitlab`\n - This helps integrate Claude Code with the project's issue tracking, PRs/MRs, and CI/CD\n\n### STEP 3: Review pre-computed codebase statistics (if provided)\n\n- Check if CODEBASE STATISTICS section is provided in the prompt\n- If provided, you have:\n - **File extension counts** (e.g., .ts: 456, .py: 123) - interpret these as technologies\n - .ts, .tsx, .jsx = TypeScript/JavaScript\n - .py = Python\n - .rs = Rust\n - .go = Go\n - .rb = Ruby\n - .ex, .exs = Elixir\n - .vue = Vue.js\n - etc.\n - **Config file names** (e.g., package.json, Cargo.toml, go.mod) - these reveal frameworks and tools\n- If statistics are NOT provided, use Glob to discover file types\n - Example: glob(\"\\*_/_.ts\") to find TypeScript files\n - Example: glob(\"\\*_/_.py\") to find Python files\n\n### STEP 4: Examine key configuration files\n\n- Config files are already identified in the statistics (if provided)\n- Use Read tool to examine important config files:\n - package.json - reveals Node.js frameworks, dependencies\n - Cargo.toml - reveals Rust dependencies\n - go.mod - reveals Go dependencies\n - requirements.txt, pyproject.toml - reveals Python dependencies\n - mix.exs - reveals Elixir dependencies\n- Use Grep to search for framework-specific patterns\n - Example: grep(\"import.\\*react\") to confirm React usage\n - Example: grep(\"from django\") to confirm Django usage\n\n### STEP 5: Identify technologies and patterns\n\n- Programming languages (TypeScript, Python, Go, Rust, Ruby, etc.)\n- Frameworks and libraries (React, Vue, Django, Rails, etc.)\n- Testing frameworks (Jest, Pytest, RSpec, etc.)\n- Build tools and infrastructure (Docker, Kubernetes, etc.)\n- Development practices (API development, frontend development, mobile, etc.)\n- Content patterns (blog posts, documentation, CMS usage)\n- CI/CD configurations\n- Accessibility tooling\n\n### STEP 6: Match findings to available plugins\n\n- Look at the plugin descriptions and keywords below\n- Cross-reference detected technologies with available jutsu-\\* plugins\n- Cross-reference development practices with available do-\\* plugins\n- Cross-reference integrations with available hashi-\\* plugins\n- ONLY recommend plugins from the list provided\n- Aim for 3-8 total plugins that best match the codebase\n- Always include \"bushido\" as it's the core plugin\n\n## Output Format\n\nReturn ONLY a JSON array of recommended plugin names from the available plugins list:\n\n```json\n[\"bushido\", \"jutsu-typescript\", \"jutsu-react\", \"do-frontend-development\"]\n```\n\n**CRITICAL**: Only recommend plugins that appear in the AVAILABLE PLUGINS list below. Never recommend plugins not in the list.\n";
3
3
  //# sourceMappingURL=build-info.generated.d.ts.map
@@ -1,4 +1,4 @@
1
1
  // Auto-generated by build-bundle.js - DO NOT EDIT
2
- export const HAN_VERSION = "1.49.1";
2
+ export const HAN_VERSION = "1.49.3";
3
3
  export const DETECT_PLUGINS_PROMPT = "<!--\nThis prompt template is dynamically enhanced in shared.ts with:\n1. GIT REPOSITORY section - Remote URL to determine hosting platform (GitHub, GitLab, etc.)\n2. CURRENTLY INSTALLED PLUGINS section - List of plugins already installed (if any)\n3. CODEBASE STATISTICS section - File extensions and config file names from codebase-analyzer.ts\n4. AVAILABLE PLUGINS IN MARKETPLACE section - Plugin list from marketplace.json\n\nThese sections are appended to this base prompt at runtime.\n-->\n\n# Han Plugin Installer Assistant\n\nYou are a Han plugin installer assistant. Your goal is to analyze the current codebase and recommend appropriate Claude Code plugins from the Han marketplace.\n\nThe available plugins from the marketplace are provided below. ONLY recommend plugins from this list.\n\n## Plugin Categories\n\n- **jutsu-\\*** (武器 weapons): Skills for specific technologies and frameworks\n- **do-\\*** (道 disciplines): Specialized agents for development practices and workflows\n- **hashi-\\*** (先生 teachers): MCP servers for external integrations\n- **bushido**: Core quality principles (ALWAYS recommend this)\n\n## Your Analysis Process\n\n### STEP 1: Analyze currently installed plugins (if provided)\n\n- Check if CURRENTLY INSTALLED PLUGINS section is provided in the prompt\n- If provided, you should:\n - **Understand why each plugin was likely added**: Look at plugin descriptions and infer original use case\n - Example: `jutsu-typescript` suggests TypeScript development\n - Example: `hashi-github` suggests GitHub integration needs\n - Example: `do-frontend-development` suggests frontend focus\n - **Determine if each plugin is still relevant**:\n - Use the codebase statistics and configuration files to verify if the technology/practice is still in use\n - A plugin is still relevant if its associated technology/practice is actively used in the codebase\n - A plugin may be irrelevant if:\n - The technology was removed (e.g., no more .ts files but jutsu-typescript is installed)\n - The project migrated to a different platform (e.g., moved from GitHub to GitLab)\n - The framework changed (e.g., migrated from React to Vue)\n - **Keep relevant plugins in your recommendations**: If a plugin is still relevant, include it in your final list\n - **Exclude irrelevant plugins**: If a plugin is no longer needed, do not include it in your recommendations\n\n### STEP 2: Check git repository hosting platform (if provided)\n\n- Check if GIT REPOSITORY section is provided in the prompt\n- If provided, examine the remote URL to determine the hosting platform:\n - URLs containing `github.com` → recommend `hashi-github`\n - URLs containing `gitlab.com` or other GitLab instances → recommend `hashi-gitlab`\n - This helps integrate Claude Code with the project's issue tracking, PRs/MRs, and CI/CD\n\n### STEP 3: Review pre-computed codebase statistics (if provided)\n\n- Check if CODEBASE STATISTICS section is provided in the prompt\n- If provided, you have:\n - **File extension counts** (e.g., .ts: 456, .py: 123) - interpret these as technologies\n - .ts, .tsx, .jsx = TypeScript/JavaScript\n - .py = Python\n - .rs = Rust\n - .go = Go\n - .rb = Ruby\n - .ex, .exs = Elixir\n - .vue = Vue.js\n - etc.\n - **Config file names** (e.g., package.json, Cargo.toml, go.mod) - these reveal frameworks and tools\n- If statistics are NOT provided, use Glob to discover file types\n - Example: glob(\"\\*_/_.ts\") to find TypeScript files\n - Example: glob(\"\\*_/_.py\") to find Python files\n\n### STEP 4: Examine key configuration files\n\n- Config files are already identified in the statistics (if provided)\n- Use Read tool to examine important config files:\n - package.json - reveals Node.js frameworks, dependencies\n - Cargo.toml - reveals Rust dependencies\n - go.mod - reveals Go dependencies\n - requirements.txt, pyproject.toml - reveals Python dependencies\n - mix.exs - reveals Elixir dependencies\n- Use Grep to search for framework-specific patterns\n - Example: grep(\"import.\\*react\") to confirm React usage\n - Example: grep(\"from django\") to confirm Django usage\n\n### STEP 5: Identify technologies and patterns\n\n- Programming languages (TypeScript, Python, Go, Rust, Ruby, etc.)\n- Frameworks and libraries (React, Vue, Django, Rails, etc.)\n- Testing frameworks (Jest, Pytest, RSpec, etc.)\n- Build tools and infrastructure (Docker, Kubernetes, etc.)\n- Development practices (API development, frontend development, mobile, etc.)\n- Content patterns (blog posts, documentation, CMS usage)\n- CI/CD configurations\n- Accessibility tooling\n\n### STEP 6: Match findings to available plugins\n\n- Look at the plugin descriptions and keywords below\n- Cross-reference detected technologies with available jutsu-\\* plugins\n- Cross-reference development practices with available do-\\* plugins\n- Cross-reference integrations with available hashi-\\* plugins\n- ONLY recommend plugins from the list provided\n- Aim for 3-8 total plugins that best match the codebase\n- Always include \"bushido\" as it's the core plugin\n\n## Output Format\n\nReturn ONLY a JSON array of recommended plugin names from the available plugins list:\n\n```json\n[\"bushido\", \"jutsu-typescript\", \"jutsu-react\", \"do-frontend-development\"]\n```\n\n**CRITICAL**: Only recommend plugins that appear in the AVAILABLE PLUGINS list below. Never recommend plugins not in the list.\n";
4
4
  //# sourceMappingURL=build-info.generated.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../lib/commands/mcp/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGzC,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAY1D"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../lib/commands/mcp/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIzC,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAyB1D"}
@@ -1,6 +1,7 @@
1
+ import { startMetricsMcpServer } from "./metrics.js";
1
2
  import { startMcpServer } from "./server.js";
2
3
  export function registerMcpCommands(program) {
3
- program
4
+ const mcpCommand = program
4
5
  .command("mcp")
5
6
  .description("Start the Han MCP server.\n" +
6
7
  "Exposes tools for running hook commands from installed plugins.\n\n" +
@@ -9,5 +10,15 @@ export function registerMcpCommands(program) {
9
10
  .action(async () => {
10
11
  await startMcpServer();
11
12
  });
13
+ // Add metrics subcommand
14
+ mcpCommand
15
+ .command("metrics")
16
+ .description("Start the Han Metrics MCP server.\n" +
17
+ "Enables agent task tracking with self-reporting and objective validation.\n\n" +
18
+ "This command is typically invoked by Claude Code when the hashi-han-metrics plugin is installed.\n" +
19
+ "It uses stdio for JSON-RPC communication.")
20
+ .action(async () => {
21
+ await startMetricsMcpServer();
22
+ });
12
23
  }
13
24
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../lib/commands/mcp/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,UAAU,mBAAmB,CAAC,OAAgB;IACnD,OAAO;SACL,OAAO,CAAC,KAAK,CAAC;SACd,WAAW,CACX,6BAA6B;QAC5B,qEAAqE;QACrE,4FAA4F;QAC5F,2CAA2C,CAC5C;SACA,MAAM,CAAC,KAAK,IAAI,EAAE;QAClB,MAAM,cAAc,EAAE,CAAC;IACxB,CAAC,CAAC,CAAC;AACL,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../lib/commands/mcp/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,UAAU,mBAAmB,CAAC,OAAgB;IACnD,MAAM,UAAU,GAAG,OAAO;SACxB,OAAO,CAAC,KAAK,CAAC;SACd,WAAW,CACX,6BAA6B;QAC5B,qEAAqE;QACrE,4FAA4F;QAC5F,2CAA2C,CAC5C;SACA,MAAM,CAAC,KAAK,IAAI,EAAE;QAClB,MAAM,cAAc,EAAE,CAAC;IACxB,CAAC,CAAC,CAAC;IAEJ,yBAAyB;IACzB,UAAU;SACR,OAAO,CAAC,SAAS,CAAC;SAClB,WAAW,CACX,qCAAqC;QACpC,+EAA+E;QAC/E,oGAAoG;QACpG,2CAA2C,CAC5C;SACA,MAAM,CAAC,KAAK,IAAI,EAAE;QAClB,MAAM,qBAAqB,EAAE,CAAC;IAC/B,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Start the metrics MCP server
3
+ */
4
+ export declare function startMetricsMcpServer(): Promise<void>;
5
+ //# sourceMappingURL=metrics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../../../../lib/commands/mcp/metrics.ts"],"names":[],"mappings":"AAiaA;;GAEG;AACH,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC,CA4C3D"}
@@ -0,0 +1,386 @@
1
+ import { createInterface } from "node:readline";
2
+ import { MetricsStorage } from "../../metrics/storage.js";
3
+ // Lazy-load storage to avoid loading better-sqlite3 native bindings
4
+ // at module import time (which breaks basic CLI commands in CI)
5
+ let storage = null;
6
+ function getStorage() {
7
+ if (!storage) {
8
+ storage = new MetricsStorage();
9
+ }
10
+ return storage;
11
+ }
12
+ /**
13
+ * Define all metrics tools
14
+ */
15
+ const METRICS_TOOLS = [
16
+ {
17
+ name: "start_task",
18
+ description: "Start tracking a new task. Returns a task_id for future updates. Use this when beginning work on a feature, fix, or refactoring.",
19
+ annotations: {
20
+ title: "Start Task",
21
+ readOnlyHint: false,
22
+ destructiveHint: false,
23
+ idempotentHint: false,
24
+ openWorldHint: false,
25
+ },
26
+ inputSchema: {
27
+ type: "object",
28
+ properties: {
29
+ description: {
30
+ type: "string",
31
+ description: "Clear description of the task being performed",
32
+ },
33
+ type: {
34
+ type: "string",
35
+ enum: ["implementation", "fix", "refactor", "research"],
36
+ description: "Type of task being performed",
37
+ },
38
+ estimated_complexity: {
39
+ type: "string",
40
+ enum: ["simple", "moderate", "complex"],
41
+ description: "Optional estimated complexity of the task",
42
+ },
43
+ },
44
+ required: ["description", "type"],
45
+ },
46
+ },
47
+ {
48
+ name: "update_task",
49
+ description: "Update a task with progress notes or status changes. Use this to log incremental progress.",
50
+ annotations: {
51
+ title: "Update Task",
52
+ readOnlyHint: false,
53
+ destructiveHint: false,
54
+ idempotentHint: true,
55
+ openWorldHint: false,
56
+ },
57
+ inputSchema: {
58
+ type: "object",
59
+ properties: {
60
+ task_id: {
61
+ type: "string",
62
+ description: "The task ID returned from start_task",
63
+ },
64
+ status: {
65
+ type: "string",
66
+ description: "Optional status update",
67
+ },
68
+ notes: {
69
+ type: "string",
70
+ description: "Progress notes or observations",
71
+ },
72
+ },
73
+ required: ["task_id"],
74
+ },
75
+ },
76
+ {
77
+ name: "complete_task",
78
+ description: "Mark a task as completed with outcome assessment. Use this when finishing a task successfully or partially.",
79
+ annotations: {
80
+ title: "Complete Task",
81
+ readOnlyHint: false,
82
+ destructiveHint: false,
83
+ idempotentHint: true,
84
+ openWorldHint: false,
85
+ },
86
+ inputSchema: {
87
+ type: "object",
88
+ properties: {
89
+ task_id: {
90
+ type: "string",
91
+ description: "The task ID returned from start_task",
92
+ },
93
+ outcome: {
94
+ type: "string",
95
+ enum: ["success", "partial", "failure"],
96
+ description: "Outcome of the task",
97
+ },
98
+ confidence: {
99
+ type: "number",
100
+ minimum: 0,
101
+ maximum: 1,
102
+ description: "Confidence level (0-1) in the success of this task. Used for calibration.",
103
+ },
104
+ files_modified: {
105
+ type: "array",
106
+ items: { type: "string" },
107
+ description: "Optional list of files modified during this task",
108
+ },
109
+ tests_added: {
110
+ type: "number",
111
+ description: "Optional count of tests added",
112
+ },
113
+ notes: {
114
+ type: "string",
115
+ description: "Optional completion notes",
116
+ },
117
+ },
118
+ required: ["task_id", "outcome", "confidence"],
119
+ },
120
+ },
121
+ {
122
+ name: "fail_task",
123
+ description: "Mark a task as failed with detailed reason and attempted solutions. Use when unable to complete a task.",
124
+ annotations: {
125
+ title: "Fail Task",
126
+ readOnlyHint: false,
127
+ destructiveHint: false,
128
+ idempotentHint: true,
129
+ openWorldHint: false,
130
+ },
131
+ inputSchema: {
132
+ type: "object",
133
+ properties: {
134
+ task_id: {
135
+ type: "string",
136
+ description: "The task ID returned from start_task",
137
+ },
138
+ reason: {
139
+ type: "string",
140
+ description: "Reason for failure",
141
+ },
142
+ confidence: {
143
+ type: "number",
144
+ minimum: 0,
145
+ maximum: 1,
146
+ description: "Optional confidence in the failure assessment",
147
+ },
148
+ attempted_solutions: {
149
+ type: "array",
150
+ items: { type: "string" },
151
+ description: "Optional list of solutions that were attempted",
152
+ },
153
+ notes: {
154
+ type: "string",
155
+ description: "Optional additional notes",
156
+ },
157
+ },
158
+ required: ["task_id", "reason"],
159
+ },
160
+ },
161
+ {
162
+ name: "query_metrics",
163
+ description: "Query task metrics and performance data. Use this to generate reports or analyze agent performance over time.",
164
+ annotations: {
165
+ title: "Query Metrics",
166
+ readOnlyHint: true,
167
+ destructiveHint: false,
168
+ idempotentHint: true,
169
+ openWorldHint: false,
170
+ },
171
+ inputSchema: {
172
+ type: "object",
173
+ properties: {
174
+ period: {
175
+ type: "string",
176
+ enum: ["day", "week", "month"],
177
+ description: "Optional time period to filter by",
178
+ },
179
+ task_type: {
180
+ type: "string",
181
+ enum: ["implementation", "fix", "refactor", "research"],
182
+ description: "Optional filter by task type",
183
+ },
184
+ outcome: {
185
+ type: "string",
186
+ enum: ["success", "partial", "failure"],
187
+ description: "Optional filter by outcome",
188
+ },
189
+ },
190
+ },
191
+ },
192
+ ];
193
+ function handleInitialize() {
194
+ return {
195
+ protocolVersion: "2024-11-05",
196
+ capabilities: {
197
+ tools: {},
198
+ },
199
+ serverInfo: {
200
+ name: "han-metrics",
201
+ version: "1.0.0",
202
+ },
203
+ };
204
+ }
205
+ function handleToolsList() {
206
+ return {
207
+ tools: METRICS_TOOLS,
208
+ };
209
+ }
210
+ async function handleToolsCall(params) {
211
+ try {
212
+ const args = params.arguments || {};
213
+ switch (params.name) {
214
+ case "start_task": {
215
+ const taskParams = args;
216
+ const result = getStorage().startTask(taskParams);
217
+ return {
218
+ content: [
219
+ {
220
+ type: "text",
221
+ text: JSON.stringify(result, null, 2),
222
+ },
223
+ ],
224
+ };
225
+ }
226
+ case "update_task": {
227
+ const taskParams = args;
228
+ const result = getStorage().updateTask(taskParams);
229
+ return {
230
+ content: [
231
+ {
232
+ type: "text",
233
+ text: JSON.stringify(result, null, 2),
234
+ },
235
+ ],
236
+ };
237
+ }
238
+ case "complete_task": {
239
+ const taskParams = args;
240
+ const result = getStorage().completeTask(taskParams);
241
+ return {
242
+ content: [
243
+ {
244
+ type: "text",
245
+ text: JSON.stringify(result, null, 2),
246
+ },
247
+ ],
248
+ };
249
+ }
250
+ case "fail_task": {
251
+ const taskParams = args;
252
+ const result = getStorage().failTask(taskParams);
253
+ return {
254
+ content: [
255
+ {
256
+ type: "text",
257
+ text: JSON.stringify(result, null, 2),
258
+ },
259
+ ],
260
+ };
261
+ }
262
+ case "query_metrics": {
263
+ const taskParams = args;
264
+ const result = getStorage().queryMetrics(taskParams);
265
+ return {
266
+ content: [
267
+ {
268
+ type: "text",
269
+ text: JSON.stringify(result, null, 2),
270
+ },
271
+ ],
272
+ };
273
+ }
274
+ default:
275
+ throw {
276
+ code: -32602,
277
+ message: `Unknown tool: ${params.name}`,
278
+ };
279
+ }
280
+ }
281
+ catch (error) {
282
+ const message = error instanceof Error ? error.message : String(error);
283
+ return {
284
+ content: [
285
+ {
286
+ type: "text",
287
+ text: `Error executing ${params.name}: ${message}`,
288
+ },
289
+ ],
290
+ isError: true,
291
+ };
292
+ }
293
+ }
294
+ async function handleRequest(request) {
295
+ try {
296
+ let result;
297
+ switch (request.method) {
298
+ case "initialize":
299
+ result = handleInitialize();
300
+ break;
301
+ case "initialized":
302
+ // Notification, no response needed
303
+ return { jsonrpc: "2.0", id: request.id, result: {} };
304
+ case "ping":
305
+ // Simple ping/pong for health checks
306
+ result = {};
307
+ break;
308
+ case "tools/list":
309
+ result = handleToolsList();
310
+ break;
311
+ case "tools/call":
312
+ result = await handleToolsCall(request.params);
313
+ break;
314
+ default:
315
+ throw {
316
+ code: -32601,
317
+ message: `Method not found: ${request.method}`,
318
+ };
319
+ }
320
+ return {
321
+ jsonrpc: "2.0",
322
+ id: request.id,
323
+ result,
324
+ };
325
+ }
326
+ catch (error) {
327
+ const errorObj = typeof error === "object" && error !== null && "code" in error
328
+ ? error
329
+ : { code: -32603, message: String(error) };
330
+ return {
331
+ jsonrpc: "2.0",
332
+ id: request.id,
333
+ error: errorObj,
334
+ };
335
+ }
336
+ }
337
+ function sendResponse(response) {
338
+ const json = JSON.stringify(response);
339
+ process.stdout.write(`${json}\n`);
340
+ }
341
+ /**
342
+ * Start the metrics MCP server
343
+ */
344
+ export async function startMetricsMcpServer() {
345
+ // Setup cleanup handlers for graceful shutdown
346
+ process.on("SIGINT", () => {
347
+ if (storage) {
348
+ storage.close();
349
+ }
350
+ process.exit(0);
351
+ });
352
+ process.on("SIGTERM", () => {
353
+ if (storage) {
354
+ storage.close();
355
+ }
356
+ process.exit(0);
357
+ });
358
+ const rl = createInterface({
359
+ input: process.stdin,
360
+ terminal: false,
361
+ });
362
+ for await (const line of rl) {
363
+ if (!line.trim())
364
+ continue;
365
+ try {
366
+ const request = JSON.parse(line);
367
+ const response = await handleRequest(request);
368
+ // Only send response if there's an id (not a notification)
369
+ if (request.id !== undefined) {
370
+ sendResponse(response);
371
+ }
372
+ }
373
+ catch (error) {
374
+ // JSON parse error
375
+ sendResponse({
376
+ jsonrpc: "2.0",
377
+ error: {
378
+ code: -32700,
379
+ message: "Parse error",
380
+ data: String(error),
381
+ },
382
+ });
383
+ }
384
+ }
385
+ }
386
+ //# sourceMappingURL=metrics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../../../lib/commands/mcp/metrics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AA8C1D,oEAAoE;AACpE,gEAAgE;AAChE,IAAI,OAAO,GAA0B,IAAI,CAAC;AAE1C,SAAS,UAAU;IAClB,IAAI,CAAC,OAAO,EAAE,CAAC;QACd,OAAO,GAAG,IAAI,cAAc,EAAE,CAAC;IAChC,CAAC;IACD,OAAO,OAAO,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,MAAM,aAAa,GAAc;IAChC;QACC,IAAI,EAAE,YAAY;QAClB,WAAW,EACV,kIAAkI;QACnI,WAAW,EAAE;YACZ,KAAK,EAAE,YAAY;YACnB,YAAY,EAAE,KAAK;YACnB,eAAe,EAAE,KAAK;YACtB,cAAc,EAAE,KAAK;YACrB,aAAa,EAAE,KAAK;SACpB;QACD,WAAW,EAAE;YACZ,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACX,WAAW,EAAE;oBACZ,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,+CAA+C;iBAC5D;gBACD,IAAI,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,IAAI,EAAE,CAAC,gBAAgB,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,CAAC;oBACvD,WAAW,EAAE,8BAA8B;iBAC3C;gBACD,oBAAoB,EAAE;oBACrB,IAAI,EAAE,QAAQ;oBACd,IAAI,EAAE,CAAC,QAAQ,EAAE,UAAU,EAAE,SAAS,CAAC;oBACvC,WAAW,EAAE,2CAA2C;iBACxD;aACD;YACD,QAAQ,EAAE,CAAC,aAAa,EAAE,MAAM,CAAC;SACjC;KACD;IACD;QACC,IAAI,EAAE,aAAa;QACnB,WAAW,EACV,4FAA4F;QAC7F,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AAE,OAAO,CAAC,KAAK;QACpB,QAAQ,EAAE,KAAK;KACf,CAAC,CAAC;IAEH,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,EAAE,EAAE,CAAC;QAC7B,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;YAAE,SAAS;QAE3B,IAAI,CAAC;YACJ,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAmB,CAAC;YACnD,MAAM,QAAQ,GAAG,MAAM,aAAa,CAAC,OAAO,CAAC,CAAC;YAE9C,2DAA2D;YAC3D,IAAI,OAAO,CAAC,EAAE,KAAK,SAAS,EAAE,CAAC;gBAC9B,YAAY,CAAC,QAAQ,CAAC,CAAC;YACxB,CAAC;QACF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,mBAAmB;YACnB,YAAY,CAAC;gBACZ,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE;oBACN,IAAI,EAAE,CAAC,KAAK;oBACZ,OAAO,EAAE,aAAa;oBACtB,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC;iBACnB;aACD,CAAC,CAAC;QACJ,CAAC;IACF,CAAC;AACF,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { MetricsResult } from "../../metrics/types.js";
2
+ /**
3
+ * Render plain text metrics display (for compiled binaries where Ink doesn't work)
4
+ */
5
+ export declare function renderPlainText(result: MetricsResult, showCalibration: boolean): void;
6
+ //# sourceMappingURL=display-plain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"display-plain.d.ts","sourceRoot":"","sources":["../../../../lib/commands/metrics/display-plain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAiS5D;;GAEG;AACH,wBAAgB,eAAe,CAC9B,MAAM,EAAE,aAAa,EACrB,eAAe,EAAE,OAAO,GACtB,IAAI,CA4DN"}