@jackss119/shelf 1.0.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 +21 -0
- package/README.md +44 -0
- package/bin/shelf.mjs +78 -0
- package/lib/commands/shelf.mjs +953 -0
- package/lib/manifest.mjs +62 -0
- package/lib/paths.mjs +22 -0
- package/lib/prompt.mjs +17 -0
- package/lib/shelfnames.mjs +69 -0
- package/lib/transport.mjs +268 -0
- package/lib/version.mjs +33 -0
- package/package.json +40 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jackzz
|
|
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
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# shelf
|
|
2
|
+
|
|
3
|
+
个人内容货架 CLI:把技能、模板、文档、代码片段放在一个 git 仓库里,在任何设备上取用和回传。
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm i -g @jackss119/shelf
|
|
7
|
+
shelf init # 在当前项目落下 manifest + 操作手册
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
首次运行时,shelf 会自动把内容仓库 clone 到 `~/.shelf/home` 当作本地档口,之后所有命令都在本地跑(每次操作前自动拉最新)。**你不需要手动 clone 任何东西。**
|
|
11
|
+
|
|
12
|
+
## 命令
|
|
13
|
+
|
|
14
|
+
| 命令 | 作用 |
|
|
15
|
+
|---|---|
|
|
16
|
+
| `shelf` | 交互浏览货架:数字进目录 · `p 1,3-5` 拉取所选 · `a` 全部 · `..` 上级 · `q` 退出 |
|
|
17
|
+
| `shelf pull <路径...> [--dest <目录>]` | 按路径拉取到当前目录 |
|
|
18
|
+
| `shelf create <本地路径> [--to <货架目录>]` | 上架新内容:全架查重名,交互选位(`m <名>` 建目录 · `d` 放这里) |
|
|
19
|
+
| `shelf push <本地路径>` | 更新已有内容:按记账/名字自动定位,不用填地址 |
|
|
20
|
+
| `shelf sync [--dry-run]` | 按账本对账:库上新版自动更新本地;本地有改动则显示 diff 由你定方向 |
|
|
21
|
+
| `shelf init` | 初始化工作区(`.shelf.json` + `shelf-ops` 操作手册) |
|
|
22
|
+
| `shelf home [--update]` | 查看货架在哪、什么模式;`--update` 立即拉取最新 |
|
|
23
|
+
|
|
24
|
+
`atk` 是 `shelf` 的别名。
|
|
25
|
+
|
|
26
|
+
## 货架从哪来
|
|
27
|
+
|
|
28
|
+
按序解析,第一个命中的生效:
|
|
29
|
+
|
|
30
|
+
1. `SHELF_HOME` 环境变量指向的 clone
|
|
31
|
+
2. CLI 自身所在的 clone(monorepo 开发态 / `npm link`)
|
|
32
|
+
3. `~/.shelfrc` 里的 `{"home": "..."}`
|
|
33
|
+
4. 托管档口 `~/.shelf/home`(不存在就自动创建)
|
|
34
|
+
|
|
35
|
+
用别的内容仓库:设 `SHELF_REMOTE=<git地址>`,或写进 `~/.shelfrc` 的 `{"remote": "..."}`。
|
|
36
|
+
临时机器不想留档口:设 `SHELF_EPHEMERAL=1`,写操作走一次性 clone,用完即删。
|
|
37
|
+
|
|
38
|
+
## 给 AI 用
|
|
39
|
+
|
|
40
|
+
`shelf init` 会在工作区装下 `shelf-ops` 操作手册,Claude Code / Codex 读到它就知道全部命令、退出码语义和冲突处理守则。非交互环境下:`create` 需要 `--to`,`push`/`create` 的确认需要 `--yes`,异机冲突需要人工确认后加 `--force`。
|
|
41
|
+
|
|
42
|
+
## License
|
|
43
|
+
|
|
44
|
+
MIT
|
package/bin/shelf.mjs
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
cmdShelfBrowse,
|
|
4
|
+
cmdShelfPull,
|
|
5
|
+
cmdShelfPush,
|
|
6
|
+
cmdShelfCreate,
|
|
7
|
+
cmdShelfSync,
|
|
8
|
+
cmdShelfInit,
|
|
9
|
+
cmdShelfHome,
|
|
10
|
+
} from "../lib/commands/shelf.mjs";
|
|
11
|
+
|
|
12
|
+
function usage() {
|
|
13
|
+
console.log(`shelf — 个人内容货架 CLI(别名 atk)
|
|
14
|
+
|
|
15
|
+
Usage:
|
|
16
|
+
shelf 交互浏览货架(数字进目录,p 1,3-5 拉取,a 全部)
|
|
17
|
+
shelf pull <路径...> 按路径拉取,如 shelf pull skills/common/intj
|
|
18
|
+
[--dest <目录>]
|
|
19
|
+
shelf create <本地路径> 上架新货:全架查重名,交互选位(m <名> 建目录,
|
|
20
|
+
d 放下)[--to <货架目录>] [--yes]
|
|
21
|
+
shelf push <本地路径> 更新已有货:按记账/名字自动定位
|
|
22
|
+
[--yes] [--force] [--force-secret]
|
|
23
|
+
shelf sync [--dry-run] 按账本对账:库上新版自动更新本地;本地有改动
|
|
24
|
+
则显示 diff 由你决定推上库还是覆盖本地
|
|
25
|
+
shelf init 初始化工作区(.shelf.json + shelf-ops 手册)
|
|
26
|
+
shelf home [--update] 查看货架在哪、什么模式;--update 拉取最新
|
|
27
|
+
|
|
28
|
+
货架定位:SHELF_HOME 环境变量 > 本 clone > ~/.shelfrc > 托管档口 ~/.shelf/home
|
|
29
|
+
免 clone 直跑:npx -y -p github:Jackzz119/my-workspace shelf <命令>`);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const argv = process.argv.slice(2);
|
|
33
|
+
const sub = argv[0];
|
|
34
|
+
const rest = argv.slice(1);
|
|
35
|
+
|
|
36
|
+
try {
|
|
37
|
+
switch (sub) {
|
|
38
|
+
case undefined:
|
|
39
|
+
case "browse":
|
|
40
|
+
await cmdShelfBrowse();
|
|
41
|
+
break;
|
|
42
|
+
case "pull":
|
|
43
|
+
await cmdShelfPull(rest);
|
|
44
|
+
break;
|
|
45
|
+
case "create":
|
|
46
|
+
await cmdShelfCreate(rest);
|
|
47
|
+
break;
|
|
48
|
+
case "push":
|
|
49
|
+
await cmdShelfPush(rest);
|
|
50
|
+
break;
|
|
51
|
+
case "sync":
|
|
52
|
+
await cmdShelfSync(rest);
|
|
53
|
+
break;
|
|
54
|
+
case "init":
|
|
55
|
+
await cmdShelfInit(rest);
|
|
56
|
+
break;
|
|
57
|
+
case "home":
|
|
58
|
+
await cmdShelfHome(rest);
|
|
59
|
+
break;
|
|
60
|
+
case "-h":
|
|
61
|
+
case "--help":
|
|
62
|
+
case "help":
|
|
63
|
+
usage();
|
|
64
|
+
break;
|
|
65
|
+
case "skills":
|
|
66
|
+
case "list":
|
|
67
|
+
console.error(`'shelf ${sub}' 已随老版技能命令清退:浏览用 shelf,按路径拉取用 shelf pull <路径> --dest .claude/skills,保持最新用 shelf sync`);
|
|
68
|
+
process.exit(1);
|
|
69
|
+
break;
|
|
70
|
+
default:
|
|
71
|
+
console.error(`Unknown command: ${sub}\n`);
|
|
72
|
+
usage();
|
|
73
|
+
process.exit(1);
|
|
74
|
+
}
|
|
75
|
+
} catch (err) {
|
|
76
|
+
console.error(err.message || err);
|
|
77
|
+
process.exit(1);
|
|
78
|
+
}
|