ts-abbr-skill 1.0.0 → 1.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 aShu-guo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -20,27 +20,41 @@
20
20
  <a href="https://github.com/aShu-guo/ts-abbreviation-skill/stargazers"><img src="https://img.shields.io/github/stars/aShu-guo/ts-abbreviation-skill?style=flat-square&logo=github" alt="GitHub stars"></a>
21
21
  </p>
22
22
 
23
- A Claude Code skill that makes generated/refactored TypeScript naming follow a shared abbreviation dictionary (`business` → `biz`, `context` → `ctx`, `configuration` → `cfg`, ...) instead of verbose full words.
23
+ An agent skill that makes generated/refactored TypeScript naming follow a shared abbreviation dictionary (`business` → `biz`, `context` → `ctx`, `configuration` → `cfg`, ...) instead of verbose full words. Works with **Claude Code**, **Codex**, and [any agent supported by the `skills` CLI](https://github.com/vercel-labs/skills).
24
24
 
25
25
  ## Install
26
26
 
27
+ ### Option A — universal installer (recommended)
28
+
29
+ Works with Claude Code, Codex, and 70+ other agents via [`skills`](https://github.com/vercel-labs/skills):
30
+
31
+ ```bash
32
+ npx skills add aShu-guo/ts-abbreviation-skill
33
+ ```
34
+
35
+ ### Option B — dedicated installer
36
+
27
37
  ```bash
28
38
  npx ts-abbr-skill
29
39
  ```
30
40
 
31
- You'll be asked where to install:
41
+ You'll be asked which agent(s) to install for (Claude Code, Codex — more than one can be selected) and where:
42
+
43
+ | Agent | Project path | Global path |
44
+ |-------|--------------|-------------|
45
+ | Claude Code | `./.claude/skills/ts-abbr-skill/` | `~/.claude/skills/ts-abbr-skill/` |
46
+ | Codex | `./.agents/skills/ts-abbr-skill/` | `~/.codex/skills/ts-abbr-skill/` |
32
47
 
33
- - **Project** `./.claude/skills/ts-abbr-skill/` (recommended for team-shared conventions, commit this to your repo)
34
- - **Global** — `~/.claude/skills/ts-abbr-skill/` (applies to all your projects)
48
+ Project scope is recommended for team-shared conventions commit it to your repo. Global scope applies to all your projects.
35
49
 
36
- Both can be selected at once. Re-running the installer is safe: your customized `config/default.config.json` and `dictionary/default.json` are never overwritten.
50
+ Re-running the installer is safe: your customized `config/default.config.json` and `dictionary/default.json` at the target are never overwritten.
37
51
 
38
52
  ## What it does
39
53
 
40
- - **When generating new code**: Claude checks the abbreviation dictionary before naming local variables/parameters and uses the abbreviated form when a match exists.
54
+ - **When generating new code**: the agent checks the abbreviation dictionary before naming local variables/parameters and uses the abbreviated form when a match exists.
41
55
  - **When refactoring existing code**: batch renames go through an AST-aware rename script (`ts-morph`-based), never plain-text find/replace, so cross-file references stay correct. A `tsc --noEmit` check is required afterward before the rename is considered done.
42
56
 
43
- See [`skill/SKILL.md`](skill/SKILL.md) for the full rules Claude follows.
57
+ See [`skills/ts-abbr-skill/SKILL.md`](skills/ts-abbr-skill/SKILL.md) for the full rules the agent follows.
44
58
 
45
59
  ## Built-in Dictionary (excerpt)
46
60
 
@@ -61,7 +75,7 @@ See [`skill/SKILL.md`](skill/SKILL.md) for the full rules Claude follows.
61
75
  | application | app |
62
76
  | ... | ... |
63
77
 
64
- Full dictionary: [`skill/dictionary/default.json`](skill/dictionary/default.json)
78
+ Full dictionary: [`skills/ts-abbr-skill/dictionary/default.json`](skills/ts-abbr-skill/dictionary/default.json)
65
79
 
66
80
  ## Customize
67
81
 
@@ -73,7 +87,7 @@ Full dictionary: [`skill/dictionary/default.json`](skill/dictionary/default.json
73
87
 
74
88
  `scope` accepts `variable`, `parameter`, `localFunction`, `class`. `exported` controls whether public/exported symbols are eligible (default `false`).
75
89
 
76
- **Project-specific additions** — add `.claude/ts-abbr.local.json` at your repo root; entries are merged on top of the default dictionary:
90
+ **Project-specific additions** — add `.ts-abbr-skill.local.json` at your repo root; entries are merged on top of the default dictionary:
77
91
 
78
92
  ```json
79
93
  {
@@ -93,7 +107,7 @@ node dist/cli.js # try the installer locally
93
107
  For iterating on skill content, use a symlink instead of rebuilding:
94
108
 
95
109
  ```bash
96
- ln -sfn /path/to/ts-abbreviation-skill/skill \
110
+ ln -sfn /path/to/ts-abbreviation-skill/skills/ts-abbr-skill \
97
111
  your-test-project/.claude/skills/ts-abbr-skill
98
112
  ```
99
113
 
package/README.zh-CN.md CHANGED
@@ -20,27 +20,41 @@
20
20
  <a href="https://github.com/aShu-guo/ts-abbreviation-skill/stargazers"><img src="https://img.shields.io/github/stars/aShu-guo/ts-abbreviation-skill?style=flat-square&logo=github" alt="GitHub stars"></a>
21
21
  </p>
22
22
 
23
- 一个 Claude Code Skill,让生成/重构的 TypeScript 代码命名遵循统一的缩写词典(`business` → `biz`、`context` → `ctx`、`configuration` → `cfg` 等),而不是冗长的全称。
23
+ 一个 Agent Skill,让生成/重构的 TypeScript 代码命名遵循统一的缩写词典(`business` → `biz`、`context` → `ctx`、`configuration` → `cfg` 等),而不是冗长的全称。支持 **Claude Code**、**Codex**,以及 [`skills` CLI 支持的所有 agent](https://github.com/vercel-labs/skills)。
24
24
 
25
25
  ## 安装
26
26
 
27
+ ### 方式 A — 通用安装器(推荐)
28
+
29
+ 通过 [`skills`](https://github.com/vercel-labs/skills) 支持 Claude Code、Codex 及 70+ 其他 agent:
30
+
31
+ ```bash
32
+ npx skills add aShu-guo/ts-abbreviation-skill
33
+ ```
34
+
35
+ ### 方式 B — 专属安装器
36
+
27
37
  ```bash
28
38
  npx ts-abbr-skill
29
39
  ```
30
40
 
31
- 安装时会询问装到哪里:
41
+ 会依次询问要为哪些 agent 安装(Claude Code、Codex,可多选)以及装到哪里:
42
+
43
+ | Agent | 项目级路径 | 全局路径 |
44
+ |-------|-----------|---------|
45
+ | Claude Code | `./.claude/skills/ts-abbr-skill/` | `~/.claude/skills/ts-abbr-skill/` |
46
+ | Codex | `./.agents/skills/ts-abbr-skill/` | `~/.codex/skills/ts-abbr-skill/` |
32
47
 
33
- - **项目级** — `./.claude/skills/ts-abbr-skill/`(推荐团队共享,提交到仓库)
34
- - **全局** — `~/.claude/skills/ts-abbr-skill/`(适用于你所有的项目)
48
+ 项目级推荐团队共享,提交到仓库;全局适用于你所有的项目。
35
49
 
36
- 两个选项可以同时勾选。重复运行安装器是安全的:目标路径下已存在的 `config/default.config.json` 和 `dictionary/default.json` 不会被覆盖。
50
+ 重复运行安装器是安全的:目标路径下已存在的 `config/default.config.json` 和 `dictionary/default.json` 不会被覆盖。
37
51
 
38
52
  ## 效果
39
53
 
40
- - **生成新代码时**:Claude 在命名局部变量/参数之前查缩写词典,有匹配则使用缩写形式。
54
+ - **生成新代码时**:agent 在命名局部变量/参数之前查缩写词典,有匹配则使用缩写形式。
41
55
  - **重构已有代码时**:批量改名强制走基于 AST 的重命名脚本(`ts-morph`),不允许纯文本替换,避免误改字符串字面量和跨作用域同名变量。改名后必须跑 `tsc --noEmit` 校验,不通过不算完成。
42
56
 
43
- 完整规则见 [`skill/SKILL.md`](skill/SKILL.md)。
57
+ 完整规则见 [`skills/ts-abbr-skill/SKILL.md`](skills/ts-abbr-skill/SKILL.md)。
44
58
 
45
59
  ## 内置词典摘录
46
60
 
@@ -61,7 +75,7 @@ npx ts-abbr-skill
61
75
  | application | app |
62
76
  | ... | ... |
63
77
 
64
- 完整词典见 [`skill/dictionary/default.json`](skill/dictionary/default.json)。
78
+ 完整词典见 [`skills/ts-abbr-skill/dictionary/default.json`](skills/ts-abbr-skill/dictionary/default.json)。
65
79
 
66
80
  ## 自定义
67
81
 
@@ -73,7 +87,7 @@ npx ts-abbr-skill
73
87
 
74
88
  `scope` 可选值:`variable`、`parameter`、`localFunction`、`class`。`exported` 控制是否对导出/公共符号生效(默认 `false`)。
75
89
 
76
- **添加项目专属缩写** — 在仓库根目录放 `.claude/ts-abbr.local.json`,词条会合并覆盖默认词典:
90
+ **添加项目专属缩写** — 在仓库根目录放 `.ts-abbr-skill.local.json`,词条会合并覆盖默认词典:
77
91
 
78
92
  ```json
79
93
  {
@@ -93,7 +107,7 @@ node dist/cli.js # 本地测试安装器
93
107
  迭代调试 Skill 内容时,用 symlink 代替每次重新构建:
94
108
 
95
109
  ```bash
96
- ln -sfn /path/to/ts-abbreviation-skill/skill \
110
+ ln -sfn /path/to/ts-abbreviation-skill/skills/ts-abbr-skill \
97
111
  your-test-project/.claude/skills/ts-abbr-skill
98
112
  ```
99
113
 
package/dist/cli.js CHANGED
@@ -9,13 +9,22 @@ import os from "os";
9
9
  import path from "path";
10
10
  import { fileURLToPath } from "url";
11
11
  var __dirname = path.dirname(fileURLToPath(import.meta.url));
12
- var SKILL_NAME = "ts-abbreviation-skill";
12
+ var SKILL_NAME = "ts-abbr-skill";
13
13
  var PROTECTED_RELATIVE_PATHS = ["config/default.config.json", "dictionary/default.json"];
14
+ var AGENT_SKILLS_DIR = {
15
+ "claude-code": { project: ".claude/skills", global: ".claude/skills" },
16
+ codex: { project: ".agents/skills", global: ".codex/skills" }
17
+ };
18
+ var AGENT_LABELS = {
19
+ "claude-code": "Claude Code",
20
+ codex: "Codex"
21
+ };
14
22
  function getSkillSourceDir() {
15
- return path.join(__dirname, "..", "skill");
23
+ return path.join(__dirname, "..", "skills", SKILL_NAME);
16
24
  }
17
- function getTargetDir(scope, cwd) {
18
- const base = scope === "project" ? path.join(cwd, ".claude", "skills") : path.join(os.homedir(), ".claude", "skills");
25
+ function getTargetDir(agent, scope, cwd) {
26
+ const relDir = AGENT_SKILLS_DIR[agent][scope];
27
+ const base = scope === "project" ? path.join(cwd, relDir) : path.join(os.homedir(), relDir);
19
28
  return path.join(base, SKILL_NAME);
20
29
  }
21
30
  function copyRecursive(srcDir, destDir, protectedRelPaths, relPrefix = "") {
@@ -37,23 +46,37 @@ function copyRecursive(srcDir, destDir, protectedRelPaths, relPrefix = "") {
37
46
  }
38
47
  return skipped;
39
48
  }
40
- function installSkill(scope, cwd = process.cwd()) {
49
+ function installSkill(agent, scope, cwd = process.cwd()) {
41
50
  const srcDir = getSkillSourceDir();
42
- const targetDir = getTargetDir(scope, cwd);
51
+ const targetDir = getTargetDir(agent, scope, cwd);
43
52
  const skippedExisting = copyRecursive(srcDir, targetDir, new Set(PROTECTED_RELATIVE_PATHS));
44
53
  return { targetDir, skippedExisting };
45
54
  }
46
55
 
47
56
  // src/cli.ts
48
57
  async function main() {
49
- console.log("ts-abbreviation-skill installer\n");
58
+ console.log("ts-abbr-skill installer\n");
59
+ const { agents } = await prompts({
60
+ type: "multiselect",
61
+ name: "agents",
62
+ message: "Which AI coding agent(s) should this skill be installed for?",
63
+ choices: [
64
+ { title: AGENT_LABELS["claude-code"], value: "claude-code", selected: true },
65
+ { title: AGENT_LABELS["codex"], value: "codex" }
66
+ ],
67
+ min: 1
68
+ });
69
+ if (!agents || agents.length === 0) {
70
+ console.log("No agent selected, aborting.");
71
+ process.exit(1);
72
+ }
50
73
  const { scopes } = await prompts({
51
74
  type: "multiselect",
52
75
  name: "scopes",
53
76
  message: "Where should this skill be installed?",
54
77
  choices: [
55
- { title: "This project (./.claude/skills/)", value: "project", selected: true },
56
- { title: "Global (~/.claude/skills/)", value: "global" }
78
+ { title: "This project", value: "project", selected: true },
79
+ { title: "Global (all your projects)", value: "global" }
57
80
  ],
58
81
  min: 1
59
82
  });
@@ -61,18 +84,20 @@ async function main() {
61
84
  console.log("No install scope selected, aborting.");
62
85
  process.exit(1);
63
86
  }
64
- for (const scope of scopes) {
65
- const { targetDir, skippedExisting } = installSkill(scope);
66
- console.log(`
67
- \u2714 Installed to ${targetDir}`);
68
- if (skippedExisting.length > 0) {
69
- console.log(` Kept existing customizations (not overwritten): ${skippedExisting.join(", ")}`);
87
+ for (const agent of agents) {
88
+ for (const scope of scopes) {
89
+ const { targetDir, skippedExisting } = installSkill(agent, scope);
90
+ console.log(`
91
+ \u2714 Installed for ${AGENT_LABELS[agent]} to ${targetDir}`);
92
+ if (skippedExisting.length > 0) {
93
+ console.log(` Kept existing customizations (not overwritten): ${skippedExisting.join(", ")}`);
94
+ }
70
95
  }
71
96
  }
72
97
  console.log("\nNext steps:");
73
- console.log(" - Restart/reopen Claude Code so it picks up the new skill.");
98
+ console.log(" - Restart/reopen your AI coding agent so it picks up the new skill.");
74
99
  console.log(" - Customize scope/exported in <target>/config/default.config.json if needed.");
75
- console.log(" - Add project-specific abbreviations via .claude/ts-abbreviation.local.json in your repo.");
100
+ console.log(" - Add project-specific abbreviations via .ts-abbr-skill.local.json in your repo.");
76
101
  }
77
102
  main().catch((err) => {
78
103
  console.error(err);
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "ts-abbr-skill",
3
- "version": "1.0.0",
4
- "description": "Claude Code skill that applies a configurable abbreviation dictionary (business→biz, context→ctx, ...) to TypeScript variable/parameter naming.",
3
+ "version": "1.1.0",
4
+ "description": "Agent skill (Claude Code, Codex, and more) that applies a configurable abbreviation dictionary (business→biz, context→ctx, ...) to TypeScript variable/parameter naming.",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "ts-abbr-skill": "dist/cli.js"
8
8
  },
9
9
  "files": [
10
10
  "dist",
11
- "skill"
11
+ "skills"
12
12
  ],
13
13
  "scripts": {
14
14
  "build": "tsup",
@@ -16,12 +16,18 @@
16
16
  },
17
17
  "keywords": [
18
18
  "claude-code",
19
+ "codex",
20
+ "agent-skills",
19
21
  "skill",
20
22
  "typescript",
21
23
  "naming",
22
24
  "abbreviation"
23
25
  ],
24
26
  "license": "MIT",
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "https://github.com/aShu-guo/ts-abbreviation-skill.git"
30
+ },
25
31
  "dependencies": {
26
32
  "prompts": "^2.4.2"
27
33
  },
@@ -1,5 +1,5 @@
1
1
  ---
2
- name: ts-abbreviation-skill
2
+ name: ts-abbr-skill
3
3
  description: Use when writing or refactoring TypeScript variable, parameter, function, or class names — applies a configurable abbreviation dictionary (business→biz, context→ctx, configuration→cfg, etc.) so generated and refactored code matches the team's naming conventions.
4
4
  ---
5
5
 
@@ -13,7 +13,7 @@ Generated TypeScript code tends to use full, verbose English words for local nam
13
13
 
14
14
  Before naming anything, resolve config and dictionary by merging, most specific first:
15
15
 
16
- 1. Project override: `.claude/ts-abbreviation.local.json` in the current repo root (if present) — entries here are merged on top of the default dictionary/config, not a full replacement.
16
+ 1. Project override: `.ts-abbr-skill.local.json` in the current repo root (if present) — entries here are merged on top of the default dictionary/config, not a full replacement.
17
17
  2. Default config/dictionary shipped with this skill: `config/default.config.json`, `dictionary/default.json`.
18
18
 
19
19
  Default config (`config/default.config.json`):
@@ -27,7 +27,7 @@ Default config (`config/default.config.json`):
27
27
  - `scope`: which kinds of identifiers this applies to. Possible values: `variable`, `parameter`, `localFunction`, `class`. Only apply abbreviations to kinds listed here.
28
28
  - `exported`: whether exported/public symbols (exported consts, public class members, public function names) are in scope. Default `false` — never abbreviate a symbol that's part of a public API unless the project config explicitly sets `exported: true`.
29
29
 
30
- If the project has no `.claude/ts-abbreviation.local.json`, use the defaults as-is.
30
+ If the project has no `.ts-abbr-skill.local.json`, use the defaults as-is.
31
31
 
32
32
  ## Mode 1: Generating New Code
33
33
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-07/schema#",
3
- "title": "ts-abbreviation-skill config",
3
+ "title": "ts-abbr-skill config",
4
4
  "type": "object",
5
5
  "additionalProperties": false,
6
6
  "properties": {