prinfer 0.4.0 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,112 +1,64 @@
1
+ <p align="center">
2
+ <img src="printfer-logo.webp" alt="prinfer logo" width="400">
3
+ </p>
4
+
1
5
  # prinfer
2
6
 
3
- TypeScript type inference inspection tool. Inspect the inferred types of functions and variables in your TypeScript code.
7
+ **Typehints for your AI agent.**
4
8
 
5
- ## Installation
9
+ prinfer gives AI coding assistants the ability to inspect TypeScript's inferred types — so they can write cleaner code without redundant type annotations.
6
10
 
7
- ```bash
8
- npm install prinfer
9
- ```
11
+ ## Why?
10
12
 
11
- ## CLI Usage
13
+ AI agents write TypeScript, but they can't see what the compiler infers. This leads to:
12
14
 
13
- ```bash
14
- # Basic usage
15
- prinfer src/utils.ts myFunction
15
+ - Unnecessary explicit type annotations everywhere
16
+ - Verbose code that fights against TypeScript's design
17
+ - Missed opportunities to leverage type inference
16
18
 
17
- # Find variable at specific line
18
- prinfer src/utils.ts:75 commandResult
19
+ prinfer solves this by exposing TypeScript's type inference to your agent via MCP.
19
20
 
20
- # With custom tsconfig
21
- prinfer src/utils.ts myFunction --project ./tsconfig.json
21
+ ## Quick Start
22
22
 
23
- # Show help
24
- prinfer --help
25
- ```
26
-
27
- ### Output
28
-
29
- ```
30
- (x: number, y: string) => boolean
31
- returns: boolean
23
+ ```bash
24
+ npm i -g prinfer
32
25
  ```
33
26
 
34
- ## Programmatic API
27
+ or
35
28
 
36
- ```typescript
37
- import { inferType } from "prinfer";
38
-
39
- // Basic usage
40
- const result = inferType("./src/utils.ts", "myFunction");
41
- console.log(result.signature);
42
- // => "(x: number, y: string) => boolean"
43
- console.log(result.returnType);
44
- // => "boolean"
45
-
46
- // Find variable at specific line
47
- const result2 = inferType("./src/utils.ts", "commandResult", { line: 75 });
48
- console.log(result2.signature);
49
- // => "Result<VaultAction[], CommandError>"
50
-
51
- // With custom tsconfig
52
- const result3 = inferType("./src/utils.ts", "myFunction", { project: "./tsconfig.json" });
29
+ ```bash
30
+ bun add -g prinfer
53
31
  ```
54
32
 
55
- ### API Reference
56
-
57
- #### `inferType(file, name, options?)`
33
+ That's it. On install, prinfer automatically:
58
34
 
59
- Infer the type of a function or variable in a TypeScript file.
35
+ 1. Adds itself as an MCP tool for Claude
36
+ 2. Installs a skill that teaches Claude to prefer type inference
60
37
 
61
- **Parameters:**
62
- - `file` - Path to the TypeScript file
63
- - `name` - Name of the function/variable to inspect
64
- - `options` - Optional object with:
65
- - `line` - Line number to narrow search (1-based)
66
- - `project` - Path to tsconfig.json
38
+ ## What Gets Installed
67
39
 
68
- **Returns:** `InferredTypeResult`
69
- - `signature` - The inferred type signature
70
- - `returnType` - The return type (for functions)
71
- - `line` - The line number where the symbol was found
40
+ ### MCP Server (`prinfer-mcp`)
72
41
 
73
- #### Types
42
+ Your agent gets an `infer_type` tool to check what TypeScript infers:
74
43
 
75
- ```typescript
76
- interface Options {
77
- file: string;
78
- name: string;
79
- line?: number;
80
- project?: string;
81
- }
82
-
83
- interface InferredTypeResult {
84
- signature: string;
85
- returnType?: string;
86
- line?: number;
87
- }
44
+ ```
45
+ infer_type(file: "src/utils.ts", name: "myFunction")
46
+ infer_type(file: "src/utils.ts", name: "commandResult", line: 75)
88
47
  ```
89
48
 
90
- ## MCP Server (Claude Integration)
49
+ ### Claude Skill (`~/.claude/skills/prefer-infer.md`)
91
50
 
92
- prinfer includes an MCP server for use with Claude Code or Claude Desktop.
51
+ A coding guideline that encourages your agent to:
93
52
 
94
- ### Setup for Claude Code
53
+ - Rely on type inference instead of explicit annotations
54
+ - Use prinfer to verify types before adding redundant hints
55
+ - Write idiomatic TypeScript
95
56
 
96
- Add to your `~/.claude/claude_desktop_config.json`:
57
+ Plus a `/check-type` command for quick lookups.
97
58
 
98
- ```json
99
- {
100
- "mcpServers": {
101
- "prinfer": {
102
- "command": "npx",
103
- "args": ["prinfer-mcp"]
104
- }
105
- }
106
- }
107
- ```
59
+ ## MCP Setup
108
60
 
109
- Or if installed globally (`npm i -g prinfer`):
61
+ If the auto-setup didn't work, add to `~/.claude/claude_desktop_config.json`:
110
62
 
111
63
  ```json
112
64
  {
@@ -118,21 +70,33 @@ Or if installed globally (`npm i -g prinfer`):
118
70
  }
119
71
  ```
120
72
 
121
- ### Tool Usage
73
+ ## CLI Usage
74
+
75
+ prinfer also works as a standalone CLI:
76
+
77
+ ```bash
78
+ prinfer src/utils.ts myFunction
79
+ prinfer src/utils.ts:75 commandResult
80
+ ```
122
81
 
123
- Once configured, Claude can use the `infer_type` tool:
82
+ Output:
124
83
 
125
84
  ```
126
- infer_type(file: "src/utils.ts", name: "myFunction")
127
- infer_type(file: "src/utils.ts", name: "commandResult", line: 75)
85
+ (x: number, y: string) => boolean
86
+ returns: boolean
128
87
  ```
129
88
 
130
- ### Auto-installed Skill
89
+ ## Programmatic API
131
90
 
132
- When you install prinfer globally (`npm i -g prinfer`), a Claude skill is automatically added to `~/.claude/skills/prinfer.md`. This provides:
91
+ ```typescript
92
+ import { inferType } from "prinfer";
133
93
 
134
- 1. **Coding guideline** - Encourages Claude to prefer type inference over explicit annotations
135
- 2. **`/check-type` command** - Check types directly: `/check-type src/utils.ts:75 commandResult`
94
+ const result = inferType("./src/utils.ts", "myFunction");
95
+ // => { signature: "(x: number, y: string) => boolean", returnType: "boolean", line: 4 }
96
+
97
+ // With line number for disambiguation
98
+ const result2 = inferType("./src/utils.ts", "commandResult", { line: 75 });
99
+ ```
136
100
 
137
101
  ## Requirements
138
102
 
@@ -64,13 +64,15 @@ Use the \`infer_type\` MCP tool to check the type:
64
64
  function main() {
65
65
  const homeDir = import_node_os.default.homedir();
66
66
  const skillsDir = import_node_path.default.join(homeDir, ".claude", "skills");
67
- const skillFile = import_node_path.default.join(skillsDir, "prinfer.md");
67
+ const skillFile = import_node_path.default.join(skillsDir, "prefer-infer.md");
68
68
  const claudeDir = import_node_path.default.join(homeDir, ".claude");
69
69
  if (!import_node_fs.default.existsSync(claudeDir)) {
70
70
  console.log(
71
71
  "~/.claude directory not found. Skipping skill installation."
72
72
  );
73
- console.log("To manually install, create ~/.claude/skills/prinfer.md");
73
+ console.log(
74
+ "To manually install, create ~/.claude/skills/prefer-infer.md"
75
+ );
74
76
  return;
75
77
  }
76
78
  if (!import_node_fs.default.existsSync(skillsDir)) {
@@ -78,12 +80,12 @@ function main() {
78
80
  }
79
81
  if (import_node_fs.default.existsSync(skillFile)) {
80
82
  console.log(
81
- "prinfer skill already installed at ~/.claude/skills/prinfer.md"
83
+ "prinfer skill already installed at ~/.claude/skills/prefer-infer.md"
82
84
  );
83
85
  return;
84
86
  }
85
87
  import_node_fs.default.writeFileSync(skillFile, SKILL_CONTENT);
86
- console.log("Installed prinfer skill to ~/.claude/skills/prinfer.md");
88
+ console.log("Installed prinfer skill to ~/.claude/skills/prefer-infer.md");
87
89
  console.log("You can now use /check-type to verify TypeScript types!");
88
90
  }
89
91
  main();
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/postinstall.ts"],"sourcesContent":["#!/usr/bin/env node\nimport fs from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\n\nconst SKILL_CONTENT = `# TypeScript Type Inference (prinfer)\n\n## Coding Guideline\n\nWhen writing TypeScript code, prefer relying on type inference over explicit type annotations:\n\n- Let TypeScript infer return types for functions when the implementation makes them obvious\n- Let TypeScript infer variable types from their initializers\n- Only add explicit types when:\n - The inferred type is too wide (e.g., \\`string\\` instead of a literal type)\n - The type serves as documentation for complex structures\n - You're defining a public API contract\n\nUse the \\`prinfer\\` MCP tool (\\`infer_type\\`) to verify what TypeScript infers before adding explicit types.\n\n## Commands\n\n### /check-type\n\nCheck the inferred type of a TypeScript symbol.\n\nUsage: \\`/check-type <file>:<line> <name>\\` or \\`/check-type <file> <name>\\`\n\nExamples:\n- \\`/check-type src/utils.ts:75 commandResult\\`\n- \\`/check-type src/utils.ts myFunction\\`\n\n<command-name>check-type</command-name>\n\nUse the \\`infer_type\\` MCP tool to check the type:\n1. Parse the arguments to extract file, optional line number, and symbol name\n2. Call \\`infer_type(file, name, line?)\\`\n3. Report the inferred signature and return type\n`;\n\nfunction main() {\n\tconst homeDir = os.homedir();\n\tconst skillsDir = path.join(homeDir, \".claude\", \"skills\");\n\tconst skillFile = path.join(skillsDir, \"prinfer.md\");\n\n\t// Check if ~/.claude exists\n\tconst claudeDir = path.join(homeDir, \".claude\");\n\tif (!fs.existsSync(claudeDir)) {\n\t\tconsole.log(\n\t\t\t\"~/.claude directory not found. Skipping skill installation.\",\n\t\t);\n\t\tconsole.log(\"To manually install, create ~/.claude/skills/prinfer.md\");\n\t\treturn;\n\t}\n\n\t// Create skills directory if it doesn't exist\n\tif (!fs.existsSync(skillsDir)) {\n\t\tfs.mkdirSync(skillsDir, { recursive: true });\n\t}\n\n\t// Check if skill already exists\n\tif (fs.existsSync(skillFile)) {\n\t\tconsole.log(\n\t\t\t\"prinfer skill already installed at ~/.claude/skills/prinfer.md\",\n\t\t);\n\t\treturn;\n\t}\n\n\t// Write the skill file\n\tfs.writeFileSync(skillFile, SKILL_CONTENT);\n\tconsole.log(\"Installed prinfer skill to ~/.claude/skills/prinfer.md\");\n\tconsole.log(\"You can now use /check-type to verify TypeScript types!\");\n}\n\nmain();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,qBAAe;AACf,qBAAe;AACf,uBAAiB;AAEjB,IAAM,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmCtB,SAAS,OAAO;AACf,QAAM,UAAU,eAAAA,QAAG,QAAQ;AAC3B,QAAM,YAAY,iBAAAC,QAAK,KAAK,SAAS,WAAW,QAAQ;AACxD,QAAM,YAAY,iBAAAA,QAAK,KAAK,WAAW,YAAY;AAGnD,QAAM,YAAY,iBAAAA,QAAK,KAAK,SAAS,SAAS;AAC9C,MAAI,CAAC,eAAAC,QAAG,WAAW,SAAS,GAAG;AAC9B,YAAQ;AAAA,MACP;AAAA,IACD;AACA,YAAQ,IAAI,yDAAyD;AACrE;AAAA,EACD;AAGA,MAAI,CAAC,eAAAA,QAAG,WAAW,SAAS,GAAG;AAC9B,mBAAAA,QAAG,UAAU,WAAW,EAAE,WAAW,KAAK,CAAC;AAAA,EAC5C;AAGA,MAAI,eAAAA,QAAG,WAAW,SAAS,GAAG;AAC7B,YAAQ;AAAA,MACP;AAAA,IACD;AACA;AAAA,EACD;AAGA,iBAAAA,QAAG,cAAc,WAAW,aAAa;AACzC,UAAQ,IAAI,wDAAwD;AACpE,UAAQ,IAAI,yDAAyD;AACtE;AAEA,KAAK;","names":["os","path","fs"]}
1
+ {"version":3,"sources":["../src/postinstall.ts"],"sourcesContent":["#!/usr/bin/env node\nimport fs from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\n\nconst SKILL_CONTENT = `# TypeScript Type Inference (prinfer)\n\n## Coding Guideline\n\nWhen writing TypeScript code, prefer relying on type inference over explicit type annotations:\n\n- Let TypeScript infer return types for functions when the implementation makes them obvious\n- Let TypeScript infer variable types from their initializers\n- Only add explicit types when:\n - The inferred type is too wide (e.g., \\`string\\` instead of a literal type)\n - The type serves as documentation for complex structures\n - You're defining a public API contract\n\nUse the \\`prinfer\\` MCP tool (\\`infer_type\\`) to verify what TypeScript infers before adding explicit types.\n\n## Commands\n\n### /check-type\n\nCheck the inferred type of a TypeScript symbol.\n\nUsage: \\`/check-type <file>:<line> <name>\\` or \\`/check-type <file> <name>\\`\n\nExamples:\n- \\`/check-type src/utils.ts:75 commandResult\\`\n- \\`/check-type src/utils.ts myFunction\\`\n\n<command-name>check-type</command-name>\n\nUse the \\`infer_type\\` MCP tool to check the type:\n1. Parse the arguments to extract file, optional line number, and symbol name\n2. Call \\`infer_type(file, name, line?)\\`\n3. Report the inferred signature and return type\n`;\n\nfunction main() {\n\tconst homeDir = os.homedir();\n\tconst skillsDir = path.join(homeDir, \".claude\", \"skills\");\n\tconst skillFile = path.join(skillsDir, \"prefer-infer.md\");\n\n\t// Check if ~/.claude exists\n\tconst claudeDir = path.join(homeDir, \".claude\");\n\tif (!fs.existsSync(claudeDir)) {\n\t\tconsole.log(\n\t\t\t\"~/.claude directory not found. Skipping skill installation.\",\n\t\t);\n\t\tconsole.log(\n\t\t\t\"To manually install, create ~/.claude/skills/prefer-infer.md\",\n\t\t);\n\t\treturn;\n\t}\n\n\t// Create skills directory if it doesn't exist\n\tif (!fs.existsSync(skillsDir)) {\n\t\tfs.mkdirSync(skillsDir, { recursive: true });\n\t}\n\n\t// Check if skill already exists\n\tif (fs.existsSync(skillFile)) {\n\t\tconsole.log(\n\t\t\t\"prinfer skill already installed at ~/.claude/skills/prefer-infer.md\",\n\t\t);\n\t\treturn;\n\t}\n\n\t// Write the skill file\n\tfs.writeFileSync(skillFile, SKILL_CONTENT);\n\tconsole.log(\"Installed prinfer skill to ~/.claude/skills/prefer-infer.md\");\n\tconsole.log(\"You can now use /check-type to verify TypeScript types!\");\n}\n\nmain();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,qBAAe;AACf,qBAAe;AACf,uBAAiB;AAEjB,IAAM,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmCtB,SAAS,OAAO;AACf,QAAM,UAAU,eAAAA,QAAG,QAAQ;AAC3B,QAAM,YAAY,iBAAAC,QAAK,KAAK,SAAS,WAAW,QAAQ;AACxD,QAAM,YAAY,iBAAAA,QAAK,KAAK,WAAW,iBAAiB;AAGxD,QAAM,YAAY,iBAAAA,QAAK,KAAK,SAAS,SAAS;AAC9C,MAAI,CAAC,eAAAC,QAAG,WAAW,SAAS,GAAG;AAC9B,YAAQ;AAAA,MACP;AAAA,IACD;AACA,YAAQ;AAAA,MACP;AAAA,IACD;AACA;AAAA,EACD;AAGA,MAAI,CAAC,eAAAA,QAAG,WAAW,SAAS,GAAG;AAC9B,mBAAAA,QAAG,UAAU,WAAW,EAAE,WAAW,KAAK,CAAC;AAAA,EAC5C;AAGA,MAAI,eAAAA,QAAG,WAAW,SAAS,GAAG;AAC7B,YAAQ;AAAA,MACP;AAAA,IACD;AACA;AAAA,EACD;AAGA,iBAAAA,QAAG,cAAc,WAAW,aAAa;AACzC,UAAQ,IAAI,6DAA6D;AACzE,UAAQ,IAAI,yDAAyD;AACtE;AAEA,KAAK;","names":["os","path","fs"]}
@@ -41,13 +41,15 @@ Use the \`infer_type\` MCP tool to check the type:
41
41
  function main() {
42
42
  const homeDir = os.homedir();
43
43
  const skillsDir = path.join(homeDir, ".claude", "skills");
44
- const skillFile = path.join(skillsDir, "prinfer.md");
44
+ const skillFile = path.join(skillsDir, "prefer-infer.md");
45
45
  const claudeDir = path.join(homeDir, ".claude");
46
46
  if (!fs.existsSync(claudeDir)) {
47
47
  console.log(
48
48
  "~/.claude directory not found. Skipping skill installation."
49
49
  );
50
- console.log("To manually install, create ~/.claude/skills/prinfer.md");
50
+ console.log(
51
+ "To manually install, create ~/.claude/skills/prefer-infer.md"
52
+ );
51
53
  return;
52
54
  }
53
55
  if (!fs.existsSync(skillsDir)) {
@@ -55,12 +57,12 @@ function main() {
55
57
  }
56
58
  if (fs.existsSync(skillFile)) {
57
59
  console.log(
58
- "prinfer skill already installed at ~/.claude/skills/prinfer.md"
60
+ "prinfer skill already installed at ~/.claude/skills/prefer-infer.md"
59
61
  );
60
62
  return;
61
63
  }
62
64
  fs.writeFileSync(skillFile, SKILL_CONTENT);
63
- console.log("Installed prinfer skill to ~/.claude/skills/prinfer.md");
65
+ console.log("Installed prinfer skill to ~/.claude/skills/prefer-infer.md");
64
66
  console.log("You can now use /check-type to verify TypeScript types!");
65
67
  }
66
68
  main();
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/postinstall.ts"],"sourcesContent":["#!/usr/bin/env node\nimport fs from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\n\nconst SKILL_CONTENT = `# TypeScript Type Inference (prinfer)\n\n## Coding Guideline\n\nWhen writing TypeScript code, prefer relying on type inference over explicit type annotations:\n\n- Let TypeScript infer return types for functions when the implementation makes them obvious\n- Let TypeScript infer variable types from their initializers\n- Only add explicit types when:\n - The inferred type is too wide (e.g., \\`string\\` instead of a literal type)\n - The type serves as documentation for complex structures\n - You're defining a public API contract\n\nUse the \\`prinfer\\` MCP tool (\\`infer_type\\`) to verify what TypeScript infers before adding explicit types.\n\n## Commands\n\n### /check-type\n\nCheck the inferred type of a TypeScript symbol.\n\nUsage: \\`/check-type <file>:<line> <name>\\` or \\`/check-type <file> <name>\\`\n\nExamples:\n- \\`/check-type src/utils.ts:75 commandResult\\`\n- \\`/check-type src/utils.ts myFunction\\`\n\n<command-name>check-type</command-name>\n\nUse the \\`infer_type\\` MCP tool to check the type:\n1. Parse the arguments to extract file, optional line number, and symbol name\n2. Call \\`infer_type(file, name, line?)\\`\n3. Report the inferred signature and return type\n`;\n\nfunction main() {\n\tconst homeDir = os.homedir();\n\tconst skillsDir = path.join(homeDir, \".claude\", \"skills\");\n\tconst skillFile = path.join(skillsDir, \"prinfer.md\");\n\n\t// Check if ~/.claude exists\n\tconst claudeDir = path.join(homeDir, \".claude\");\n\tif (!fs.existsSync(claudeDir)) {\n\t\tconsole.log(\n\t\t\t\"~/.claude directory not found. Skipping skill installation.\",\n\t\t);\n\t\tconsole.log(\"To manually install, create ~/.claude/skills/prinfer.md\");\n\t\treturn;\n\t}\n\n\t// Create skills directory if it doesn't exist\n\tif (!fs.existsSync(skillsDir)) {\n\t\tfs.mkdirSync(skillsDir, { recursive: true });\n\t}\n\n\t// Check if skill already exists\n\tif (fs.existsSync(skillFile)) {\n\t\tconsole.log(\n\t\t\t\"prinfer skill already installed at ~/.claude/skills/prinfer.md\",\n\t\t);\n\t\treturn;\n\t}\n\n\t// Write the skill file\n\tfs.writeFileSync(skillFile, SKILL_CONTENT);\n\tconsole.log(\"Installed prinfer skill to ~/.claude/skills/prinfer.md\");\n\tconsole.log(\"You can now use /check-type to verify TypeScript types!\");\n}\n\nmain();\n"],"mappings":";;;AACA,OAAO,QAAQ;AACf,OAAO,QAAQ;AACf,OAAO,UAAU;AAEjB,IAAM,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmCtB,SAAS,OAAO;AACf,QAAM,UAAU,GAAG,QAAQ;AAC3B,QAAM,YAAY,KAAK,KAAK,SAAS,WAAW,QAAQ;AACxD,QAAM,YAAY,KAAK,KAAK,WAAW,YAAY;AAGnD,QAAM,YAAY,KAAK,KAAK,SAAS,SAAS;AAC9C,MAAI,CAAC,GAAG,WAAW,SAAS,GAAG;AAC9B,YAAQ;AAAA,MACP;AAAA,IACD;AACA,YAAQ,IAAI,yDAAyD;AACrE;AAAA,EACD;AAGA,MAAI,CAAC,GAAG,WAAW,SAAS,GAAG;AAC9B,OAAG,UAAU,WAAW,EAAE,WAAW,KAAK,CAAC;AAAA,EAC5C;AAGA,MAAI,GAAG,WAAW,SAAS,GAAG;AAC7B,YAAQ;AAAA,MACP;AAAA,IACD;AACA;AAAA,EACD;AAGA,KAAG,cAAc,WAAW,aAAa;AACzC,UAAQ,IAAI,wDAAwD;AACpE,UAAQ,IAAI,yDAAyD;AACtE;AAEA,KAAK;","names":[]}
1
+ {"version":3,"sources":["../src/postinstall.ts"],"sourcesContent":["#!/usr/bin/env node\nimport fs from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\n\nconst SKILL_CONTENT = `# TypeScript Type Inference (prinfer)\n\n## Coding Guideline\n\nWhen writing TypeScript code, prefer relying on type inference over explicit type annotations:\n\n- Let TypeScript infer return types for functions when the implementation makes them obvious\n- Let TypeScript infer variable types from their initializers\n- Only add explicit types when:\n - The inferred type is too wide (e.g., \\`string\\` instead of a literal type)\n - The type serves as documentation for complex structures\n - You're defining a public API contract\n\nUse the \\`prinfer\\` MCP tool (\\`infer_type\\`) to verify what TypeScript infers before adding explicit types.\n\n## Commands\n\n### /check-type\n\nCheck the inferred type of a TypeScript symbol.\n\nUsage: \\`/check-type <file>:<line> <name>\\` or \\`/check-type <file> <name>\\`\n\nExamples:\n- \\`/check-type src/utils.ts:75 commandResult\\`\n- \\`/check-type src/utils.ts myFunction\\`\n\n<command-name>check-type</command-name>\n\nUse the \\`infer_type\\` MCP tool to check the type:\n1. Parse the arguments to extract file, optional line number, and symbol name\n2. Call \\`infer_type(file, name, line?)\\`\n3. Report the inferred signature and return type\n`;\n\nfunction main() {\n\tconst homeDir = os.homedir();\n\tconst skillsDir = path.join(homeDir, \".claude\", \"skills\");\n\tconst skillFile = path.join(skillsDir, \"prefer-infer.md\");\n\n\t// Check if ~/.claude exists\n\tconst claudeDir = path.join(homeDir, \".claude\");\n\tif (!fs.existsSync(claudeDir)) {\n\t\tconsole.log(\n\t\t\t\"~/.claude directory not found. Skipping skill installation.\",\n\t\t);\n\t\tconsole.log(\n\t\t\t\"To manually install, create ~/.claude/skills/prefer-infer.md\",\n\t\t);\n\t\treturn;\n\t}\n\n\t// Create skills directory if it doesn't exist\n\tif (!fs.existsSync(skillsDir)) {\n\t\tfs.mkdirSync(skillsDir, { recursive: true });\n\t}\n\n\t// Check if skill already exists\n\tif (fs.existsSync(skillFile)) {\n\t\tconsole.log(\n\t\t\t\"prinfer skill already installed at ~/.claude/skills/prefer-infer.md\",\n\t\t);\n\t\treturn;\n\t}\n\n\t// Write the skill file\n\tfs.writeFileSync(skillFile, SKILL_CONTENT);\n\tconsole.log(\"Installed prinfer skill to ~/.claude/skills/prefer-infer.md\");\n\tconsole.log(\"You can now use /check-type to verify TypeScript types!\");\n}\n\nmain();\n"],"mappings":";;;AACA,OAAO,QAAQ;AACf,OAAO,QAAQ;AACf,OAAO,UAAU;AAEjB,IAAM,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmCtB,SAAS,OAAO;AACf,QAAM,UAAU,GAAG,QAAQ;AAC3B,QAAM,YAAY,KAAK,KAAK,SAAS,WAAW,QAAQ;AACxD,QAAM,YAAY,KAAK,KAAK,WAAW,iBAAiB;AAGxD,QAAM,YAAY,KAAK,KAAK,SAAS,SAAS;AAC9C,MAAI,CAAC,GAAG,WAAW,SAAS,GAAG;AAC9B,YAAQ;AAAA,MACP;AAAA,IACD;AACA,YAAQ;AAAA,MACP;AAAA,IACD;AACA;AAAA,EACD;AAGA,MAAI,CAAC,GAAG,WAAW,SAAS,GAAG;AAC9B,OAAG,UAAU,WAAW,EAAE,WAAW,KAAK,CAAC;AAAA,EAC5C;AAGA,MAAI,GAAG,WAAW,SAAS,GAAG;AAC7B,YAAQ;AAAA,MACP;AAAA,IACD;AACA;AAAA,EACD;AAGA,KAAG,cAAc,WAAW,aAAa;AACzC,UAAQ,IAAI,6DAA6D;AACzE,UAAQ,IAAI,yDAAyD;AACtE;AAEA,KAAK;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prinfer",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "TypeScript type inference inspection tool",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",