skill-author-card 1.6.2 → 1.6.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.
- package/.author-card/show-card.sh +45 -5
- package/README.md +67 -36
- package/inject-to-skill.sh +20 -17
- package/package.json +3 -3
- package/skill.md +42 -32
- package/templates/show-card-standalone.sh +43 -3
- package/.author-card/.shown +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
# Standalone Author Card - Bundled with your skill, no external dependencies
|
|
3
|
-
# Version: 1.6.
|
|
3
|
+
# Version: 1.6.3
|
|
4
4
|
# Generated by: skill-author-card
|
|
5
5
|
|
|
6
6
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
@@ -16,6 +16,44 @@ truncate_str() {
|
|
|
16
16
|
fi
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
state_slug() {
|
|
20
|
+
local raw="${REPO:-$SKILL_NAME}"
|
|
21
|
+
local slug
|
|
22
|
+
slug=$(printf "%s" "$raw" | tr '/: ' '---' | tr -cd '[:alnum:]._-')
|
|
23
|
+
if [ -z "$slug" ]; then
|
|
24
|
+
slug="skill-author-card"
|
|
25
|
+
fi
|
|
26
|
+
echo "$slug"
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
state_root_dir() {
|
|
30
|
+
if [ -n "$AUTHOR_CARD_STATE_DIR" ]; then
|
|
31
|
+
echo "$AUTHOR_CARD_STATE_DIR"
|
|
32
|
+
return 0
|
|
33
|
+
fi
|
|
34
|
+
|
|
35
|
+
if [ -n "$XDG_STATE_HOME" ]; then
|
|
36
|
+
echo "$XDG_STATE_HOME/author-card"
|
|
37
|
+
return 0
|
|
38
|
+
fi
|
|
39
|
+
|
|
40
|
+
if [ -n "$XDG_CONFIG_HOME" ]; then
|
|
41
|
+
echo "$XDG_CONFIG_HOME/author-card"
|
|
42
|
+
return 0
|
|
43
|
+
fi
|
|
44
|
+
|
|
45
|
+
echo "$HOME/.config/author-card"
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
shown_file_path() {
|
|
49
|
+
if [ -n "$AUTHOR_CARD_SHOWN" ]; then
|
|
50
|
+
echo "$AUTHOR_CARD_SHOWN"
|
|
51
|
+
return 0
|
|
52
|
+
fi
|
|
53
|
+
|
|
54
|
+
echo "$(state_root_dir)/shown/$(state_slug).shown"
|
|
55
|
+
}
|
|
56
|
+
|
|
19
57
|
# Parse arguments
|
|
20
58
|
MESSAGE=""
|
|
21
59
|
NO_PROMPT=false
|
|
@@ -33,7 +71,7 @@ done
|
|
|
33
71
|
# Hardcoded configuration (injected during skill setup)
|
|
34
72
|
# These values are replaced by inject-to-skill.sh
|
|
35
73
|
SKILL_NAME="skill-author-card"
|
|
36
|
-
VERSION="1.6.
|
|
74
|
+
VERSION="1.6.3"
|
|
37
75
|
REPO="Yonsun-w/skill-author-card"
|
|
38
76
|
NAME="yonsun_W"
|
|
39
77
|
GITHUB="Yonsun-w"
|
|
@@ -51,9 +89,10 @@ SHOW_PROMOTION="true"
|
|
|
51
89
|
# Exit early if frequency is "never"
|
|
52
90
|
[ "$FREQUENCY" = "never" ] && exit 0
|
|
53
91
|
|
|
92
|
+
SHOWN_FILE="$(shown_file_path)"
|
|
93
|
+
|
|
54
94
|
# For "once" frequency, check if already shown
|
|
55
95
|
if [ "$FREQUENCY" = "once" ]; then
|
|
56
|
-
SHOWN_FILE="$SCRIPT_DIR/.shown"
|
|
57
96
|
if [ -f "$SHOWN_FILE" ]; then
|
|
58
97
|
# Already shown, exit silently
|
|
59
98
|
exit 0
|
|
@@ -105,7 +144,7 @@ echo "│ │"
|
|
|
105
144
|
|
|
106
145
|
# Message
|
|
107
146
|
if [ -n "$MESSAGE" ]; then
|
|
108
|
-
printf "│ ⭐ %-50s │\n" "$MESSAGE"
|
|
147
|
+
printf "│ ⭐ %-50s │\n" "$(truncate_str "$MESSAGE" 50)"
|
|
109
148
|
else
|
|
110
149
|
[ -n "$REPO" ] && printf "│ ⭐ %-50s │\n" "喜欢?去 GitHub 点个 star!"
|
|
111
150
|
fi
|
|
@@ -137,5 +176,6 @@ fi
|
|
|
137
176
|
# ============================================================================
|
|
138
177
|
|
|
139
178
|
if [ "$FREQUENCY" = "once" ]; then
|
|
140
|
-
|
|
179
|
+
mkdir -p "$(dirname "$SHOWN_FILE")"
|
|
180
|
+
touch "$SHOWN_FILE"
|
|
141
181
|
fi
|
package/README.md
CHANGED
|
@@ -1,37 +1,41 @@
|
|
|
1
1
|
# skill-author-card
|
|
2
2
|
|
|
3
|
-
给 skill 或项目源码注入一个本地作者卡片。
|
|
3
|
+
给 skill 或项目源码注入一个本地作者卡片。
|
|
4
|
+
Inject a local author card into a skill or project source tree.
|
|
4
5
|
|
|
5
|
-
它会在目标项目里生成 `.author-card/show-card.sh`,并把一条调用命令追加到目标 `SKILL.md` 或 `skill.md`
|
|
6
|
+
它会在目标项目里生成 `.author-card/show-card.sh`,并把一条调用命令追加到目标 `SKILL.md` 或 `skill.md` 末尾。作者信息和 once 状态都保存在当前用户本机,不会写入远端服务,也不会污染项目仓库。
|
|
7
|
+
It generates `.author-card/show-card.sh` inside the target project and appends a command to the target `SKILL.md` or `skill.md`. Author data and once-state stay on the current user's machine, are not uploaded to any remote service, and do not pollute the project repository.
|
|
6
8
|
|
|
7
|
-
## 功能
|
|
9
|
+
## 功能 | Features
|
|
8
10
|
|
|
9
|
-
- 初始化本地作者信息
|
|
10
|
-
- 给 skill 或项目源码注入作者卡片
|
|
11
|
-
- 自动读取 git remote 或项目元数据中的 GitHub 仓库地址
|
|
12
|
-
- 支持 `Claude Code`、`Cursor`、`Windsurf`、`Codex` 和 generic shell 环境
|
|
11
|
+
- 初始化本地作者信息 / Initialize local author profile data
|
|
12
|
+
- 给 skill 或项目源码注入作者卡片 / Inject an author card into a skill or project source tree
|
|
13
|
+
- 自动读取 git remote 或项目元数据中的 GitHub 仓库地址 / Auto-detect the GitHub repository from git remote or project metadata
|
|
14
|
+
- 支持 `Claude Code`、`Cursor`、`Windsurf`、`Codex` 和 generic shell 环境 / Support `Claude Code`, `Cursor`, `Windsurf`, `Codex`, and generic shell environments
|
|
13
15
|
|
|
14
|
-
## 安装
|
|
16
|
+
## 安装 | Installation
|
|
15
17
|
|
|
16
18
|
```bash
|
|
17
19
|
npm install -g skill-author-card
|
|
18
20
|
```
|
|
19
21
|
|
|
20
|
-
安装后会暴露 `skill-author-card` CLI
|
|
22
|
+
安装后会暴露 `skill-author-card` CLI,并包含以下脚本。
|
|
23
|
+
After installation, the package exposes the `skill-author-card` CLI and includes these scripts:
|
|
21
24
|
|
|
22
25
|
- `init-profile.sh`
|
|
23
26
|
- `inject-to-skill.sh`
|
|
24
27
|
- `show-card.sh`
|
|
25
28
|
|
|
26
|
-
## 快速开始
|
|
29
|
+
## 快速开始 | Quick Start
|
|
27
30
|
|
|
28
|
-
### 1. 初始化作者信息
|
|
31
|
+
### 1. 初始化作者信息 | Initialize the author profile
|
|
29
32
|
|
|
30
33
|
```bash
|
|
31
34
|
init-profile.sh
|
|
32
35
|
```
|
|
33
36
|
|
|
34
|
-
|
|
37
|
+
会在本地配置目录写入作者资料。常见位置如下。
|
|
38
|
+
This writes author data to a local config directory. Common locations:
|
|
35
39
|
|
|
36
40
|
- Claude Code: `~/.claude/skills/.author-profile.json`
|
|
37
41
|
- Cursor: `~/.cursor/.author-profile.json`
|
|
@@ -39,41 +43,61 @@ init-profile.sh
|
|
|
39
43
|
- Codex: `~/.codex/.author-profile.json`
|
|
40
44
|
- Generic: `~/.config/author-card/profile.json`
|
|
41
45
|
|
|
42
|
-
### 2. 注入到目标项目
|
|
46
|
+
### 2. 注入到目标项目 | Inject into a target project
|
|
43
47
|
|
|
44
48
|
```bash
|
|
45
49
|
inject-to-skill.sh /absolute/path/to/your-project
|
|
46
50
|
```
|
|
47
51
|
|
|
48
|
-
|
|
52
|
+
注入器会执行以下操作。
|
|
53
|
+
The injector will:
|
|
49
54
|
|
|
50
|
-
- 创建 `.author-card/show-card.sh`
|
|
51
|
-
- 在目标 `SKILL.md` 或 `skill.md` 末尾添加 `Author Card` 段落
|
|
52
|
-
- 向目标 `.gitignore` 追加 `.author-card/.shown`
|
|
55
|
+
- 创建 `.author-card/show-card.sh` / Create `.author-card/show-card.sh`
|
|
56
|
+
- 在目标 `SKILL.md` 或 `skill.md` 末尾添加 `Author Card` 段落 / Append an `Author Card` section to the target `SKILL.md` or `skill.md`
|
|
53
57
|
|
|
54
|
-
它不会再修改目标项目的 `package.json
|
|
58
|
+
它不会再修改目标项目的 `package.json`,也不会在目标项目里写入 once 状态文件。
|
|
59
|
+
It no longer modifies the target project's `package.json`, and it does not store once-state inside the target project.
|
|
55
60
|
|
|
56
|
-
### 3. 预览卡片
|
|
61
|
+
### 3. 预览卡片 | Preview the card
|
|
57
62
|
|
|
58
63
|
```bash
|
|
59
64
|
/absolute/path/to/your-project/.author-card/show-card.sh --no-prompt --frequency always
|
|
60
65
|
```
|
|
61
66
|
|
|
62
|
-
`--frequency always` 适合预览;默认注入命令使用 `--frequency once`,避免重复打扰用户。
|
|
67
|
+
`--frequency always` 适合预览;默认注入命令使用 `--frequency once`,避免重复打扰用户。
|
|
68
|
+
Use `--frequency always` for previews. The injected command defaults to `--frequency once` to avoid repeatedly interrupting users.
|
|
63
69
|
|
|
64
|
-
## 生成后的调用
|
|
70
|
+
## 生成后的调用 | Injected Command
|
|
65
71
|
|
|
66
|
-
注入后的目标 skill
|
|
72
|
+
注入后的目标 skill 文件末尾会追加以下命令。
|
|
73
|
+
The target skill file will receive this command near the end:
|
|
67
74
|
|
|
68
75
|
```bash
|
|
69
76
|
.author-card/show-card.sh --frequency once
|
|
70
77
|
```
|
|
71
78
|
|
|
72
|
-
这条命令应该保留在主任务逻辑之后,让作者卡片只在任务成功完成后展示。
|
|
79
|
+
这条命令应该保留在主任务逻辑之后,让作者卡片只在任务成功完成后展示。
|
|
80
|
+
Keep this command after the main task logic so the author card only appears after the task succeeds.
|
|
73
81
|
|
|
74
|
-
##
|
|
82
|
+
## Once 状态设计 | Once-State Design
|
|
75
83
|
|
|
76
|
-
|
|
84
|
+
`--frequency once` 的状态不再写入项目目录,也不会生成 `.author-card/.shown`。
|
|
85
|
+
The `--frequency once` state is no longer stored in the project tree, and it does not create `.author-card/.shown`.
|
|
86
|
+
|
|
87
|
+
状态会写到当前用户的本地配置或状态目录,例如:
|
|
88
|
+
The state is written to the current user's local config/state directory, for example:
|
|
89
|
+
|
|
90
|
+
- `~/.config/author-card/shown/...`
|
|
91
|
+
- `$XDG_STATE_HOME/author-card/shown/...`
|
|
92
|
+
- 自定义环境变量 `AUTHOR_CARD_STATE_DIR` 或 `AUTHOR_CARD_SHOWN` / Custom `AUTHOR_CARD_STATE_DIR` or `AUTHOR_CARD_SHOWN`
|
|
93
|
+
|
|
94
|
+
这意味着你可以先在本机预览卡片,再把源码推到远端;其他用户下载、安装或打包后,仍然会在他们自己的机器上看到第一次展示。
|
|
95
|
+
This means you can preview the card locally before pushing. Other users who download, install, or package the project will still get their own first-time display on their own machines.
|
|
96
|
+
|
|
97
|
+
## 仓库检测 | Repository Detection
|
|
98
|
+
|
|
99
|
+
作者卡片会优先从下面几种来源提取仓库地址。
|
|
100
|
+
The author card tries these sources in order:
|
|
77
101
|
|
|
78
102
|
1. `git remote get-url origin`
|
|
79
103
|
2. `package.json.repository`
|
|
@@ -81,9 +105,10 @@ inject-to-skill.sh /absolute/path/to/your-project
|
|
|
81
105
|
4. `Cargo.toml`
|
|
82
106
|
5. `go.mod`
|
|
83
107
|
|
|
84
|
-
如果没有检测到 GitHub 仓库,卡片仍然会生成,只是不会显示仓库链接。
|
|
108
|
+
如果没有检测到 GitHub 仓库,卡片仍然会生成,只是不会显示仓库链接。
|
|
109
|
+
If no GitHub repository is detected, the card is still generated, but the repository link is omitted.
|
|
85
110
|
|
|
86
|
-
## 示例输出
|
|
111
|
+
## 示例输出 | Example Output
|
|
87
112
|
|
|
88
113
|
```text
|
|
89
114
|
┌─────────────────────────────────────────────────────────┐
|
|
@@ -99,23 +124,28 @@ inject-to-skill.sh /absolute/path/to/your-project
|
|
|
99
124
|
└─────────────────────────────────────────────────────────┘
|
|
100
125
|
```
|
|
101
126
|
|
|
102
|
-
## 开发
|
|
127
|
+
## 开发 | Development
|
|
103
128
|
|
|
104
|
-
运行测试:
|
|
129
|
+
运行测试:
|
|
130
|
+
Run the test suite:
|
|
105
131
|
|
|
106
132
|
```bash
|
|
107
133
|
npm test
|
|
108
134
|
```
|
|
109
135
|
|
|
110
|
-
|
|
136
|
+
当前测试覆盖以下内容。
|
|
137
|
+
The current test suite covers:
|
|
111
138
|
|
|
112
|
-
- 注入命令是否正确写入目标 `SKILL.md`
|
|
113
|
-
- 平台与配置路径检测
|
|
114
|
-
- `show-card.sh` 对对象格式 `package.json.repository` 的解析
|
|
139
|
+
- 注入命令是否正确写入目标 `SKILL.md` / Whether the injected command is written correctly to the target `SKILL.md`
|
|
140
|
+
- 平台与配置路径检测 / Platform and config path detection
|
|
141
|
+
- `show-card.sh` 对对象格式 `package.json.repository` 的解析 / Parsing object-style `package.json.repository` values in `show-card.sh`
|
|
142
|
+
- once 状态不会写回目标项目目录 / Ensuring once-state is not written back into the target project tree
|
|
143
|
+
- npm 打包不会带上本地 once 状态文件 / Ensuring npm packages do not include local once-state artifacts
|
|
115
144
|
|
|
116
|
-
## 发布
|
|
145
|
+
## 发布 | Release
|
|
117
146
|
|
|
118
|
-
|
|
147
|
+
发布前建议执行:
|
|
148
|
+
Recommended steps before publishing:
|
|
119
149
|
|
|
120
150
|
```bash
|
|
121
151
|
npm test
|
|
@@ -124,7 +154,8 @@ git push origin main
|
|
|
124
154
|
npm publish --access public
|
|
125
155
|
```
|
|
126
156
|
|
|
127
|
-
如果旧版本不再推荐使用,优先用 `npm deprecate` 标记,不要随意 `unpublish` 已存在的稳定版本。
|
|
157
|
+
如果旧版本不再推荐使用,优先用 `npm deprecate` 标记,不要随意 `unpublish` 已存在的稳定版本。
|
|
158
|
+
If older versions should no longer be used, prefer `npm deprecate` instead of unpublishing stable versions.
|
|
128
159
|
|
|
129
160
|
## License
|
|
130
161
|
|
package/inject-to-skill.sh
CHANGED
|
@@ -272,28 +272,31 @@ fi
|
|
|
272
272
|
echo ""
|
|
273
273
|
|
|
274
274
|
# Update .gitignore
|
|
275
|
-
if [
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
275
|
+
if [ -f ".gitignore" ]; then
|
|
276
|
+
# Remove legacy rules from older versions. Once-state now lives in a
|
|
277
|
+
# user-level config/state directory rather than in the project tree.
|
|
278
|
+
if grep -q ".author-card/config.json" .gitignore 2>/dev/null || grep -q ".author-card/.shown" .gitignore 2>/dev/null; then
|
|
279
|
+
if sed --version >/dev/null 2>&1; then
|
|
280
|
+
sed -i \
|
|
281
|
+
-e '/.author-card\/config.json/d' \
|
|
282
|
+
-e '/.author-card\/.shown/d' \
|
|
283
|
+
-e '/# Author card local config/d' \
|
|
284
|
+
-e '/# Author card shown state (user-specific)/d' \
|
|
285
|
+
.gitignore
|
|
286
|
+
else
|
|
287
|
+
sed -i '' \
|
|
288
|
+
-e '/.author-card\/config.json/d' \
|
|
289
|
+
-e '/.author-card\/.shown/d' \
|
|
290
|
+
-e '/# Author card local config/d' \
|
|
291
|
+
-e '/# Author card shown state (user-specific)/d' \
|
|
292
|
+
.gitignore
|
|
293
|
+
fi
|
|
285
294
|
fi
|
|
286
295
|
fi
|
|
287
296
|
|
|
288
|
-
# Add .shown file to gitignore (user-specific state)
|
|
289
|
-
if ! grep -q ".author-card/.shown" .gitignore 2>/dev/null; then
|
|
290
|
-
echo "" >> .gitignore
|
|
291
|
-
echo "# Author card shown state (user-specific)" >> .gitignore
|
|
292
|
-
echo ".author-card/.shown" >> .gitignore
|
|
293
|
-
fi
|
|
294
|
-
|
|
295
297
|
echo ""
|
|
296
298
|
success "完成! Author card 已添加到 $SKILL_NAME"
|
|
297
299
|
echo ""
|
|
300
|
+
info "once 状态会写入当前用户的配置目录,不会污染项目仓库或打包产物"
|
|
298
301
|
info "下一步: git add . && git commit -m 'feat: add author card' && git push"
|
|
299
302
|
echo ""
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "skill-author-card",
|
|
3
|
-
"version": "1.6.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.6.3",
|
|
4
|
+
"description": "给 skill 或项目源码注入本地作者卡片 / Inject a local author card into a skill or project source tree.",
|
|
5
5
|
"main": "skill.md",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"postinstall": "node postinstall.js",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"files": [
|
|
39
39
|
"SKILL.md",
|
|
40
40
|
"skill.md",
|
|
41
|
-
".author-card",
|
|
41
|
+
".author-card/show-card.sh",
|
|
42
42
|
"bin",
|
|
43
43
|
"postinstall.js",
|
|
44
44
|
"preuninstall.js",
|
package/skill.md
CHANGED
|
@@ -1,73 +1,83 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: skill-author-card
|
|
3
|
-
description: Add an author card to a skill or project source tree. Use when the user wants to inject an author card, initialize author profile data, or preview the generated card.
|
|
3
|
+
description: Add an author card to a skill or project source tree. Use when the user wants to inject an author card, initialize author profile data, or preview the generated card. 支持中文和英文场景。
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Skill Author Card
|
|
7
7
|
|
|
8
|
-
Use this skill when the user wants to
|
|
8
|
+
Use this skill when the user wants to add an author card to a skill or project source tree.
|
|
9
|
+
当用户想给 skill 或项目源码添加作者卡片时,使用这个 skill。
|
|
9
10
|
|
|
10
|
-
- initialize local author profile data
|
|
11
|
-
- inject an author card into a skill or project source directory
|
|
12
|
-
- preview the generated card before committing changes
|
|
11
|
+
- initialize local author profile data / 初始化本地作者资料
|
|
12
|
+
- inject an author card into a skill or project source directory / 向 skill 或项目源码目录注入作者卡片
|
|
13
|
+
- preview the generated card before committing changes / 在提交前预览生成的卡片
|
|
13
14
|
|
|
14
|
-
This skill edits source trees. Work on the user's checked-out project, not on already-installed skills unless they explicitly ask for that.
|
|
15
|
+
This skill edits source trees. Work on the user's checked-out project, not on already-installed skills unless they explicitly ask for that.
|
|
16
|
+
这个 skill 作用于源码目录。除非用户明确要求,否则不要修改已经安装好的 skill。
|
|
15
17
|
|
|
16
18
|
## Workflow
|
|
17
19
|
|
|
18
|
-
### 1. Resolve the target
|
|
20
|
+
### 1. Resolve the target | 确定目标目录
|
|
19
21
|
|
|
20
|
-
- If the user gave an absolute or relative path, use it.
|
|
21
|
-
- If they only gave a project name, inspect the current workspace for a matching directory first.
|
|
22
|
-
- If multiple matches remain or the target is still ambiguous, ask one concise question before editing.
|
|
22
|
+
- If the user gave an absolute or relative path, use it. / 如果用户给了绝对路径或相对路径,直接使用。
|
|
23
|
+
- If they only gave a project name, inspect the current workspace for a matching directory first. / 如果只给了项目名,先在当前工作区查找匹配目录。
|
|
24
|
+
- If multiple matches remain or the target is still ambiguous, ask one concise question before editing. / 如果仍然有多个候选或目标不明确,编辑前只问一个简短问题。
|
|
23
25
|
|
|
24
|
-
### 2. Initialize author profile when missing
|
|
26
|
+
### 2. Initialize author profile when missing | 缺失时初始化作者资料
|
|
25
27
|
|
|
26
|
-
Run the bundled initializer from this skill directory
|
|
28
|
+
Run the bundled initializer from this skill directory.
|
|
29
|
+
从当前 skill 目录运行内置初始化脚本:
|
|
27
30
|
|
|
28
31
|
```bash
|
|
29
32
|
./init-profile.sh
|
|
30
33
|
```
|
|
31
34
|
|
|
32
|
-
Only do this when the author profile file does not already exist or the user explicitly asks to reset it.
|
|
35
|
+
Only do this when the author profile file does not already exist or the user explicitly asks to reset it.
|
|
36
|
+
仅在作者资料文件不存在,或用户明确要求重置时执行。
|
|
33
37
|
|
|
34
|
-
### 3. Inject the author card
|
|
38
|
+
### 3. Inject the author card | 注入作者卡片
|
|
35
39
|
|
|
36
|
-
Run the injector against the target source directory
|
|
40
|
+
Run the injector against the target source directory.
|
|
41
|
+
对目标源码目录执行注入脚本:
|
|
37
42
|
|
|
38
43
|
```bash
|
|
39
44
|
./inject-to-skill.sh /absolute/path/to/target
|
|
40
45
|
```
|
|
41
46
|
|
|
42
|
-
The injector will:
|
|
47
|
+
The injector will:
|
|
48
|
+
注入器会:
|
|
43
49
|
|
|
44
|
-
- create `.author-card/show-card.sh` inside the target project
|
|
45
|
-
- append an `Author Card` section to the target `SKILL.md` or `skill.md`
|
|
46
|
-
- add `.author-card/.shown` to the target `.gitignore`
|
|
50
|
+
- create `.author-card/show-card.sh` inside the target project / 在目标项目内创建 `.author-card/show-card.sh`
|
|
51
|
+
- append an `Author Card` section to the target `SKILL.md` or `skill.md` / 在目标 `SKILL.md` 或 `skill.md` 末尾追加 `Author Card` 段落
|
|
47
52
|
|
|
48
|
-
It should not modify unrelated files such as `package.json
|
|
53
|
+
It should not modify unrelated files such as `package.json`, and it should not store once-state inside the target project.
|
|
54
|
+
不要修改 `package.json` 之类的无关文件,也不要把 once 状态写进目标项目目录。
|
|
49
55
|
|
|
50
|
-
### 4. Preview the result
|
|
56
|
+
### 4. Preview the result | 预览结果
|
|
51
57
|
|
|
52
|
-
After injection, preview the generated card directly from the target project
|
|
58
|
+
After injection, preview the generated card directly from the target project.
|
|
59
|
+
注入完成后,直接在目标项目内预览生成的卡片:
|
|
53
60
|
|
|
54
61
|
```bash
|
|
55
62
|
/absolute/path/to/target/.author-card/show-card.sh --no-prompt --frequency always
|
|
56
63
|
```
|
|
57
64
|
|
|
58
|
-
Use `--frequency always` for previews so the card still renders after a previous run.
|
|
65
|
+
Use `--frequency always` for previews so the card still renders after a previous run.
|
|
66
|
+
预览时使用 `--frequency always`,这样即使之前展示过也还能再次渲染。
|
|
59
67
|
|
|
60
|
-
### 5. Report the exact outcome
|
|
68
|
+
### 5. Report the exact outcome | 明确反馈结果
|
|
61
69
|
|
|
62
|
-
Tell the user:
|
|
70
|
+
Tell the user:
|
|
71
|
+
向用户说明:
|
|
63
72
|
|
|
64
|
-
- which directory was modified
|
|
65
|
-
- which files were created or changed
|
|
66
|
-
- whether repository metadata was detected automatically
|
|
67
|
-
- any follow-up they may want, such as reviewing the diff or committing the change
|
|
73
|
+
- which directory was modified / 修改了哪个目录
|
|
74
|
+
- which files were created or changed / 创建或修改了哪些文件
|
|
75
|
+
- whether repository metadata was detected automatically / 是否自动识别到了仓库元数据
|
|
76
|
+
- any follow-up they may want, such as reviewing the diff or committing the change / 用户接下来可能要做的事,比如看 diff 或提交改动
|
|
68
77
|
|
|
69
78
|
## Notes
|
|
70
79
|
|
|
71
|
-
- Keep the author card call at the end of the target skill file so it runs only after the main task succeeds.
|
|
72
|
-
- Prefer the bundled scripts in this skill directory. Do not rewrite the injection logic manually unless the scripts fail and need patching.
|
|
73
|
-
- If repository detection fails, still inject the card and tell the user the GitHub link will be omitted until the target project has git or package metadata.
|
|
80
|
+
- Keep the author card call at the end of the target skill file so it runs only after the main task succeeds. / 把作者卡片调用保留在目标 skill 文件末尾,确保主任务成功后再展示。
|
|
81
|
+
- Prefer the bundled scripts in this skill directory. Do not rewrite the injection logic manually unless the scripts fail and need patching. / 优先使用当前 skill 自带脚本;除非脚本失效需要修补,否则不要手写重做注入逻辑。
|
|
82
|
+
- If repository detection fails, still inject the card and tell the user the GitHub link will be omitted until the target project has git or package metadata. / 如果仓库检测失败,仍然要完成注入,并告知用户在目标项目补齐 git 或包元数据前不会显示 GitHub 链接。
|
|
83
|
+
- The once-state must live in a user-level config or state directory so packaged downstream skills remain safe for other users. / once 状态必须保存在用户级配置或状态目录里,这样被注入后的其他 skill 再打包分发时也不会影响别的用户。
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
# Standalone Author Card - Bundled with your skill, no external dependencies
|
|
3
|
-
# Version: 1.6.
|
|
3
|
+
# Version: 1.6.3
|
|
4
4
|
# Generated by: skill-author-card
|
|
5
5
|
|
|
6
6
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
@@ -16,6 +16,44 @@ truncate_str() {
|
|
|
16
16
|
fi
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
state_slug() {
|
|
20
|
+
local raw="${REPO:-$SKILL_NAME}"
|
|
21
|
+
local slug
|
|
22
|
+
slug=$(printf "%s" "$raw" | tr '/: ' '---' | tr -cd '[:alnum:]._-')
|
|
23
|
+
if [ -z "$slug" ]; then
|
|
24
|
+
slug="skill-author-card"
|
|
25
|
+
fi
|
|
26
|
+
echo "$slug"
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
state_root_dir() {
|
|
30
|
+
if [ -n "$AUTHOR_CARD_STATE_DIR" ]; then
|
|
31
|
+
echo "$AUTHOR_CARD_STATE_DIR"
|
|
32
|
+
return 0
|
|
33
|
+
fi
|
|
34
|
+
|
|
35
|
+
if [ -n "$XDG_STATE_HOME" ]; then
|
|
36
|
+
echo "$XDG_STATE_HOME/author-card"
|
|
37
|
+
return 0
|
|
38
|
+
fi
|
|
39
|
+
|
|
40
|
+
if [ -n "$XDG_CONFIG_HOME" ]; then
|
|
41
|
+
echo "$XDG_CONFIG_HOME/author-card"
|
|
42
|
+
return 0
|
|
43
|
+
fi
|
|
44
|
+
|
|
45
|
+
echo "$HOME/.config/author-card"
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
shown_file_path() {
|
|
49
|
+
if [ -n "$AUTHOR_CARD_SHOWN" ]; then
|
|
50
|
+
echo "$AUTHOR_CARD_SHOWN"
|
|
51
|
+
return 0
|
|
52
|
+
fi
|
|
53
|
+
|
|
54
|
+
echo "$(state_root_dir)/shown/$(state_slug).shown"
|
|
55
|
+
}
|
|
56
|
+
|
|
19
57
|
# Parse arguments
|
|
20
58
|
MESSAGE=""
|
|
21
59
|
NO_PROMPT=false
|
|
@@ -51,9 +89,10 @@ SHOW_PROMOTION="__SHOW_PROMOTION__"
|
|
|
51
89
|
# Exit early if frequency is "never"
|
|
52
90
|
[ "$FREQUENCY" = "never" ] && exit 0
|
|
53
91
|
|
|
92
|
+
SHOWN_FILE="$(shown_file_path)"
|
|
93
|
+
|
|
54
94
|
# For "once" frequency, check if already shown
|
|
55
95
|
if [ "$FREQUENCY" = "once" ]; then
|
|
56
|
-
SHOWN_FILE="$SCRIPT_DIR/.shown"
|
|
57
96
|
if [ -f "$SHOWN_FILE" ]; then
|
|
58
97
|
# Already shown, exit silently
|
|
59
98
|
exit 0
|
|
@@ -137,5 +176,6 @@ fi
|
|
|
137
176
|
# ============================================================================
|
|
138
177
|
|
|
139
178
|
if [ "$FREQUENCY" = "once" ]; then
|
|
140
|
-
|
|
179
|
+
mkdir -p "$(dirname "$SHOWN_FILE")"
|
|
180
|
+
touch "$SHOWN_FILE"
|
|
141
181
|
fi
|
package/.author-card/.shown
DELETED
|
File without changes
|