@wry-smile/lexid 0.0.0-stage → 0.1.1
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 +21 -0
- package/README.md +211 -2
- package/README.zh-CN.md +178 -0
- package/dist/dictionaries-DqOja3dc.mjs +6574 -0
- package/dist/dictionaries-DwfVfnJX.cjs +6741 -0
- package/dist/dictionaries.cjs +30 -0
- package/dist/dictionaries.d.cts +2 -0
- package/dist/dictionaries.d.mts +2 -0
- package/dist/dictionaries.mjs +2 -0
- package/dist/index-BGuJLQZS.d.mts +19 -0
- package/dist/index-CBG7Ua1f.d.mts +87 -0
- package/dist/index-CvKRlqot.d.cts +87 -0
- package/dist/index-kBjONiKH.d.cts +19 -0
- package/dist/index.cjs +126 -0
- package/dist/index.d.cts +16 -0
- package/dist/index.d.mts +16 -0
- package/dist/index.mjs +87 -0
- package/dist/patterns-DC47BwpJ.cjs +285 -0
- package/dist/patterns-H0XRwCVB.mjs +250 -0
- package/dist/patterns.cjs +8 -0
- package/dist/patterns.d.cts +2 -0
- package/dist/patterns.d.mts +2 -0
- package/dist/patterns.mjs +2 -0
- package/dist/random.cjs +43 -0
- package/dist/random.d.cts +6 -0
- package/dist/random.d.mts +6 -0
- package/dist/random.mjs +42 -0
- package/dist/types-BsCTggdZ.d.mts +37 -0
- package/dist/types-DKjF96ZA.d.cts +37 -0
- package/package.json +97 -3
- package/skills/lexid/SKILL.md +65 -0
- package/skills/lexid/references/api.md +69 -0
- package/skills/lexid/references/customization.md +66 -0
- package/skills/lexid/references/dictionaries.md +33 -0
- package/skills/lexid/references/examples.md +54 -0
- package/skills/lexid/references/patterns.md +45 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 wry-smile
|
|
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
|
@@ -1,3 +1,212 @@
|
|
|
1
|
-
#
|
|
1
|
+
# LexID
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Composable human-readable identifiers.
|
|
4
|
+
|
|
5
|
+
Semantic dictionaries. Composable patterns. Secure randomness.
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { lexid } from '@wry-smile/lexid'
|
|
9
|
+
|
|
10
|
+
lexid()
|
|
11
|
+
// silent-cloud-engine-a7k2m9
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
[简体中文](README.zh-CN.md)
|
|
15
|
+
|
|
16
|
+
LexID is a TypeScript and JavaScript library for Node.js 22+ and modern browsers.
|
|
17
|
+
It creates public-facing resource IDs, service names, workspace slugs, and test
|
|
18
|
+
names from real words, with zero third-party runtime dependencies.
|
|
19
|
+
|
|
20
|
+
Use the same ESM import in Node.js and in ES2022-capable browsers. Browser
|
|
21
|
+
projects can resolve the package with a bundler or an import map. LexID uses
|
|
22
|
+
`crypto.getRandomValues()` on both platforms, including browsers on plain HTTP.
|
|
23
|
+
Generation reports an error if the runtime lacks this secure random source.
|
|
24
|
+
|
|
25
|
+
## Install
|
|
26
|
+
|
|
27
|
+
After the npm release, run `pnpm add @wry-smile/lexid` or `npm install @wry-smile/lexid`. For local
|
|
28
|
+
development, build and install the tarball produced by `pnpm pack`.
|
|
29
|
+
|
|
30
|
+
## CommonJS
|
|
31
|
+
|
|
32
|
+
Use `require` to load the CommonJS build.
|
|
33
|
+
|
|
34
|
+
```cjs
|
|
35
|
+
const { lexid } = require('@wry-smile/lexid')
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Generate identifiers
|
|
39
|
+
|
|
40
|
+
By default, `lexid()` selects one of 39 templates uniformly. Identifiers have
|
|
41
|
+
four or five total segments, ending in six lowercase alphanumeric characters.
|
|
42
|
+
The default separator is `-` and the complete identifier can contain up to
|
|
43
|
+
63 characters. These defaults fit ordinary DNS labels.
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
import { isLexid, lexid, lexids } from '@wry-smile/lexid'
|
|
47
|
+
import { fourWordPatterns, pickPattern } from '@wry-smile/lexid/patterns'
|
|
48
|
+
|
|
49
|
+
const id = lexid({ segments: pickPattern(fourWordPatterns) })
|
|
50
|
+
isLexid(id) // true
|
|
51
|
+
const names = lexids(20)
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Use `threeWordPatterns` for three word segments or `fourWordPatterns` for four.
|
|
55
|
+
The default suffix adds one segment. `defaultPatterns` combines both collections. A custom template is an ordered array of dictionaries, and
|
|
56
|
+
`pickPattern` selects among templates with nonempty dictionaries.
|
|
57
|
+
|
|
58
|
+
Define a custom template set with ordinary arrays.
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
import {
|
|
62
|
+
adjectives,
|
|
63
|
+
animals,
|
|
64
|
+
colors,
|
|
65
|
+
domains,
|
|
66
|
+
lexid,
|
|
67
|
+
pickPattern,
|
|
68
|
+
technologies,
|
|
69
|
+
} from '@wry-smile/lexid'
|
|
70
|
+
|
|
71
|
+
const patterns = [
|
|
72
|
+
[adjectives, technologies, domains],
|
|
73
|
+
[adjectives, colors, animals],
|
|
74
|
+
]
|
|
75
|
+
lexid({ segments: pickPattern(patterns) })
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Compose dictionaries and customize output
|
|
79
|
+
|
|
80
|
+
Use the 28 [built-in dictionaries](skills/lexid/references/dictionaries.md)
|
|
81
|
+
from the root entry or `@wry-smile/lexid/dictionaries`. Mix them with your own arrays
|
|
82
|
+
using `filter` and spread. Each dictionary must contain at least one word.
|
|
83
|
+
Use a single-item dictionary to fix a segment. By default, the suffix adds one segment
|
|
84
|
+
to any number of word segments.
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
import { adjectives, domains, isLexid, lexid, technologies } from '@wry-smile/lexid'
|
|
88
|
+
|
|
89
|
+
const id = lexid({
|
|
90
|
+
segments: [
|
|
91
|
+
adjectives.filter((word) => word.startsWith('s')),
|
|
92
|
+
[...technologies, 'iot'],
|
|
93
|
+
domains.filter((word) => word.length <= 8),
|
|
94
|
+
['prime'],
|
|
95
|
+
],
|
|
96
|
+
separator: '_',
|
|
97
|
+
maxLength: 63,
|
|
98
|
+
suffix: ({ words, random }) => words[0].charAt(0) + random.alphanumeric(7),
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
isLexid(id, { separator: '_' }) // true
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
The allowed separators are `-`, `_`, `.`, and `~`. Use lowercase ASCII
|
|
105
|
+
letters for words and lowercase ASCII letters or digits for the synchronous
|
|
106
|
+
suffix. Overlong results throw. To ensure every result fits, bound the length
|
|
107
|
+
of each dictionary candidate and the suffix before generating.
|
|
108
|
+
|
|
109
|
+
`isLexid` checks structure and length. Match its separator and maximum length
|
|
110
|
+
to the generation settings. See the [API reference](skills/lexid/references/api.md)
|
|
111
|
+
for the public types, defaults, and errors.
|
|
112
|
+
|
|
113
|
+
## Arrange word segments
|
|
114
|
+
|
|
115
|
+
For English-style names, put broad descriptors first and the object being
|
|
116
|
+
named last. For operational names, put the field you scan or sort by first,
|
|
117
|
+
such as the environment or service.
|
|
118
|
+
|
|
119
|
+
| Goal | Dictionary order | Example |
|
|
120
|
+
| ---------------------- | --------------------------------------- | ---------------------- |
|
|
121
|
+
| Readable resource name | `adjectives`, `technologies`, `domains` | `silent-cloud-engine` |
|
|
122
|
+
| Nature-inspired name | `colors`, `nature`, `animals` | `silver-forest-wolf` |
|
|
123
|
+
| Group by environment | `['staging']`, `domains`, `modifiers` | `staging-worker-prime` |
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
import { domains, lexid, modifiers } from '@wry-smile/lexid'
|
|
127
|
+
|
|
128
|
+
lexid({
|
|
129
|
+
segments: [['staging'], domains.filter((word) => word.length <= 6), modifiers],
|
|
130
|
+
suffix: false,
|
|
131
|
+
})
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Omit the suffix
|
|
135
|
+
|
|
136
|
+
Set `suffix: false` to generate only the word segments. Use `hasSuffix: false` to validate names in this format.
|
|
137
|
+
|
|
138
|
+
```ts
|
|
139
|
+
import { isLexid, lexid } from '@wry-smile/lexid'
|
|
140
|
+
|
|
141
|
+
const id = lexid({ segments: [['cloud'], ['engine']], suffix: false })
|
|
142
|
+
// cloud-engine
|
|
143
|
+
isLexid(id, { hasSuffix: false }) // true
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Use secure random tools directly
|
|
147
|
+
|
|
148
|
+
```ts
|
|
149
|
+
import { random } from '@wry-smile/lexid/random'
|
|
150
|
+
|
|
151
|
+
random.int(100)
|
|
152
|
+
random.pick(['cloud', 'mesh'])
|
|
153
|
+
random.alphanumeric(8)
|
|
154
|
+
random.string('23456789abcdef', 8)
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
`random` also offers `numeric`, `alphabetic`, and `hexadecimal`. The
|
|
158
|
+
`@wry-smile/lexid/random` and `@wry-smile/lexid/dictionaries` entries load without the generator
|
|
159
|
+
or default templates. Bundlers can tree-shake unused exports. Default
|
|
160
|
+
generation still needs every dictionary referenced by the default templates.
|
|
161
|
+
|
|
162
|
+
## Agent Integration Skill
|
|
163
|
+
|
|
164
|
+
The [Integration Skill](skills/lexid/SKILL.md) teaches coding agents how to
|
|
165
|
+
import and compose the library. Once the Skill is available in the GitHub
|
|
166
|
+
repository, install it with the [Skills installer](https://github.com/vercel-labs/skills).
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
pnpm dlx skills add wry-smile/lexid --skill lexid
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
For a local checkout, run `pnpm dlx skills add /path/to/lexid --skill lexid`
|
|
173
|
+
from the application project. The current Skills installer requires Node.js
|
|
174
|
+
22.20 or later. Install the npm library separately.
|
|
175
|
+
|
|
176
|
+
## Uniqueness and security
|
|
177
|
+
|
|
178
|
+
Treat generated values as public names. Keep secrets and sensitive data out
|
|
179
|
+
of identifiers, and enforce authorization independently. For uniqueness,
|
|
180
|
+
use a database UNIQUE constraint and bounded retries on collisions.
|
|
181
|
+
Custom suffix security depends on the callback.
|
|
182
|
+
|
|
183
|
+
## Development
|
|
184
|
+
|
|
185
|
+
Use Node.js 22+ and the pnpm version in `package.json`.
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
pnpm install --frozen-lockfile
|
|
189
|
+
pnpm format:check
|
|
190
|
+
pnpm lint
|
|
191
|
+
pnpm typecheck
|
|
192
|
+
pnpm test
|
|
193
|
+
pnpm build
|
|
194
|
+
pnpm pack
|
|
195
|
+
pnpm test:package ./wry-smile-lexid-0.1.0.tgz
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
Run `pnpm format` to apply formatting with Oxfmt.
|
|
199
|
+
|
|
200
|
+
Keep dictionaries sorted and frozen. Add or update tests when changing a
|
|
201
|
+
public contract. Keep the Skill examples aligned with the exported API.
|
|
202
|
+
|
|
203
|
+
## Publishing
|
|
204
|
+
|
|
205
|
+
From a clean, up-to-date checkout, use `pnpm release:publish` to build, check,
|
|
206
|
+
and publish the current version to npm as a public scoped package. Add
|
|
207
|
+
`--dry-run` to preview the publish. For later releases, first run `pnpm release`
|
|
208
|
+
to select a version and create a local commit and tag with Bumpp.
|
|
209
|
+
|
|
210
|
+
## License
|
|
211
|
+
|
|
212
|
+
[MIT](LICENSE)
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# LexID
|
|
2
|
+
|
|
3
|
+
可组合、易读的语义化标识符。
|
|
4
|
+
|
|
5
|
+
分类词库,可组合模板,密码学安全随机数。
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { lexid } from '@wry-smile/lexid'
|
|
9
|
+
|
|
10
|
+
lexid()
|
|
11
|
+
// silent-cloud-engine-a7k2m9
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
[English](README.md)
|
|
15
|
+
|
|
16
|
+
LexID 是适用于 Node.js 22+ 和现代浏览器的 TypeScript / JavaScript 库。它使用真实英文词汇生成资源 ID、容器和服务名称、工作空间 URL 标识及测试数据,第三方运行时依赖为零。
|
|
17
|
+
|
|
18
|
+
Node.js 和支持 ES2022 的浏览器使用相同的 ESM 入口。浏览器项目可以通过打包器或导入映射解析包名。两个平台都使用 `crypto.getRandomValues()`,普通 HTTP 页面也可使用。若运行环境缺少该安全随机源,生成时会抛出明确错误。
|
|
19
|
+
|
|
20
|
+
## 安装
|
|
21
|
+
|
|
22
|
+
库发布到 npm 后,可运行 `pnpm add @wry-smile/lexid` 或 `npm install @wry-smile/lexid`。本地开发时,可先构建,再安装 `pnpm pack` 生成的压缩包。
|
|
23
|
+
|
|
24
|
+
## CommonJS
|
|
25
|
+
|
|
26
|
+
使用 `require` 加载 CommonJS 构建。
|
|
27
|
+
|
|
28
|
+
```cjs
|
|
29
|
+
const { lexid } = require('@wry-smile/lexid')
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## 默认生成与语义模板
|
|
33
|
+
|
|
34
|
+
`lexid()` 从 39 套默认模板中等概率选择一套,生成四段或五段标识符。最后一段为六位小写字母数字后缀。默认用 `-` 连接,总长度上限为 63 个字符,符合普通 DNS 标签格式。
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import { isLexid, lexid, lexids } from '@wry-smile/lexid'
|
|
38
|
+
import { threeWordPatterns, pickPattern } from '@wry-smile/lexid/patterns'
|
|
39
|
+
|
|
40
|
+
const id = lexid({ segments: pickPattern(threeWordPatterns) })
|
|
41
|
+
isLexid(id) // true
|
|
42
|
+
const names = lexids(20)
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
`threeWordPatterns` 和 `fourWordPatterns` 分别提供三个和四个单词段。启用后缀时,总段数加一。`defaultPatterns` 包含两组默认模板。自定义模板是有序词库数组,`pickPattern` 会跳过空模板和包含空词库的模板。
|
|
46
|
+
|
|
47
|
+
用普通数组定义自己的模板集合。
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
import {
|
|
51
|
+
adjectives,
|
|
52
|
+
animals,
|
|
53
|
+
colors,
|
|
54
|
+
domains,
|
|
55
|
+
lexid,
|
|
56
|
+
pickPattern,
|
|
57
|
+
technologies,
|
|
58
|
+
} from '@wry-smile/lexid'
|
|
59
|
+
|
|
60
|
+
const patterns = [
|
|
61
|
+
[adjectives, technologies, domains],
|
|
62
|
+
[adjectives, colors, animals],
|
|
63
|
+
]
|
|
64
|
+
lexid({ segments: pickPattern(patterns) })
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## 组合词库与自定义规则
|
|
68
|
+
|
|
69
|
+
从根入口或 `@wry-smile/lexid/dictionaries` 导入 28 个[内置词库](skills/lexid/references/dictionaries.md)。可以用 `filter` 根据字符位置或长度筛选,用展开运算符合并词库,也可以直接传入自己的数组。`segments[i]` 是第 `i + 1` 段的候选词库,每段独立抽词。词库至少包含一个单词。单元素数组可固定一段,启用后缀时,总段数等于词库数加一。
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
import { adjectives, domains, isLexid, lexid, technologies } from '@wry-smile/lexid'
|
|
73
|
+
|
|
74
|
+
const id = lexid({
|
|
75
|
+
segments: [
|
|
76
|
+
adjectives.filter((word) => word.startsWith('s')),
|
|
77
|
+
[...technologies, 'iot'],
|
|
78
|
+
domains.filter((word) => word.length <= 8),
|
|
79
|
+
['prime'],
|
|
80
|
+
],
|
|
81
|
+
separator: '_',
|
|
82
|
+
maxLength: 63,
|
|
83
|
+
suffix: ({ words, random }) => words[0].charAt(0) + random.alphanumeric(7),
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
isLexid(id, { separator: '_' }) // true
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
保留内置语义模板时,可以先对模板集合 `map`,逐段 `filter` 候选词,再调用 `pickPattern`。例如给 `fourWordPatterns` 的四个单词段分别设置长度上限。后缀独立配置。参见[逐段筛选内置模板](skills/lexid/references/customization.md#filter-built-in-templates-by-position)。
|
|
90
|
+
|
|
91
|
+
连接符支持 `-`、`_`、`.` 和 `~`。单词段只允许小写 ASCII 字母,后缀回调须同步返回小写 ASCII 字母数字。结果超长会抛出错误。若所有结果都必须满足上限,请提前限制每段单词和后缀长度。
|
|
92
|
+
|
|
93
|
+
`isLexid` 校验结构和长度。使用自定义格式时,请传入与生成时相同的连接符和上限。[API 参考](skills/lexid/references/api.md)列出了导出类型、默认值和错误行为。
|
|
94
|
+
|
|
95
|
+
## 单词段怎么排列
|
|
96
|
+
|
|
97
|
+
想让名字读起来像英文短语,可以先放修饰词或背景词,最后放要描述的对象。如果主要在列表里查找或排序,就把最常用的筛选字段放在第一段,比如环境或服务名。
|
|
98
|
+
|
|
99
|
+
| 用途 | 词库顺序 | 示例 |
|
|
100
|
+
| ------------ | ----------------------------------------- | ---------------------- |
|
|
101
|
+
| 易读的资源名 | `adjectives` → `technologies` → `domains` | `silent-cloud-engine` |
|
|
102
|
+
| 自然风格 | `colors` → `nature` → `animals` | `silver-forest-wolf` |
|
|
103
|
+
| 按环境归类 | `['staging']` → `domains` → `modifiers` | `staging-worker-prime` |
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
import { domains, lexid, modifiers } from '@wry-smile/lexid'
|
|
107
|
+
|
|
108
|
+
lexid({
|
|
109
|
+
segments: [['staging'], domains.filter((word) => word.length <= 6), modifiers],
|
|
110
|
+
suffix: false,
|
|
111
|
+
})
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## 省略后缀
|
|
115
|
+
|
|
116
|
+
设置 `suffix: false` 可只生成单词段。校验这类名称时,传入 `hasSuffix: false`。
|
|
117
|
+
|
|
118
|
+
```ts
|
|
119
|
+
import { isLexid, lexid } from '@wry-smile/lexid'
|
|
120
|
+
|
|
121
|
+
const id = lexid({ segments: [['cloud'], ['engine']], suffix: false })
|
|
122
|
+
// cloud-engine
|
|
123
|
+
isLexid(id, { hasSuffix: false }) // true
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## 独立随机工具
|
|
127
|
+
|
|
128
|
+
```ts
|
|
129
|
+
import { random } from '@wry-smile/lexid/random'
|
|
130
|
+
|
|
131
|
+
random.int(100)
|
|
132
|
+
random.pick(['cloud', 'mesh'])
|
|
133
|
+
random.alphanumeric(8)
|
|
134
|
+
random.string('23456789abcdef', 8)
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
`random` 还提供 `numeric`、`alphabetic` 和 `hexadecimal`。随机工具和词库子入口可独立加载。支持 Tree Shaking 的打包器可以移除未使用的导出,默认生成仍依赖默认模板引用的所有词库。
|
|
138
|
+
|
|
139
|
+
## Agent 集成 Skill
|
|
140
|
+
|
|
141
|
+
[集成 Skill](skills/lexid/SKILL.md)为编码 Agent 提供安装、API 选择和 TypeScript 集成示例。Skill 提交到 GitHub 仓库后,可通过 [Skills 安装工具](https://github.com/vercel-labs/skills)安装。
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
pnpm dlx skills add wry-smile/lexid --skill lexid
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
使用本地检出时,在应用项目中运行 `pnpm dlx skills add /path/to/lexid --skill lexid`。当前 Skills 安装工具需要 Node.js 22.20 或更高版本。应用项目中的 LexID 依赖需要独立安装。
|
|
148
|
+
|
|
149
|
+
## 唯一性与安全
|
|
150
|
+
|
|
151
|
+
把生成结果视作公开名称。凭证和敏感信息应独立存储,资源权限应独立校验。业务需要唯一标识时,使用数据库 UNIQUE 约束,并在标识冲突时有界重试。自定义后缀的随机安全性取决于回调实现。
|
|
152
|
+
|
|
153
|
+
## 开发与贡献
|
|
154
|
+
|
|
155
|
+
使用 Node.js 22+ 和 `package.json` 指定的 pnpm 版本。
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
pnpm install --frozen-lockfile
|
|
159
|
+
pnpm format:check
|
|
160
|
+
pnpm lint
|
|
161
|
+
pnpm typecheck
|
|
162
|
+
pnpm test
|
|
163
|
+
pnpm build
|
|
164
|
+
pnpm pack
|
|
165
|
+
pnpm test:package ./wry-smile-lexid-0.1.0.tgz
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
运行 `pnpm format` 可用 Oxfmt 格式化代码。
|
|
169
|
+
|
|
170
|
+
维护词库时保持排序、去重和不可变。修改公共契约时同步更新测试和 Skill 示例。
|
|
171
|
+
|
|
172
|
+
## 发布
|
|
173
|
+
|
|
174
|
+
在工作区干净且与远端同步后,运行 `pnpm release:publish`。命令会执行检查和构建,并把当前版本作为公开 scoped 包发布到 npm。附加 `--dry-run` 可预览发布。后续版本先运行 `pnpm release`,通过 Bumpp 选择版本,并在本地创建版本提交和标签。
|
|
175
|
+
|
|
176
|
+
## 许可证
|
|
177
|
+
|
|
178
|
+
[MIT](LICENSE)
|