@xiaoailazy/coexistree-skills 0.2.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/README.md ADDED
@@ -0,0 +1,76 @@
1
+ # @xiaoailazy/coexistree-skills
2
+
3
+ CoExistree **Agent Skills**:供 Cursor、Claude Code、Codex 等支持 `SKILL.md` 的 Agent 使用。与 [`@xiaoailazy/coexistree-cli`](../cli) 配合。
4
+
5
+ Skill **源文件**在本包的 `skills/` 目录;发布到 npm 后通过安装器复制到各 Agent 的技能目录。
6
+
7
+ ## 安装
8
+
9
+ ```bash
10
+ # 仅 Skill
11
+ npm install -g @xiaoailazy/coexistree-skills
12
+ coexistree-skills-install
13
+
14
+ # 或一键(CLI + Skill,见 meta 包)
15
+ npm install -g @xiaoailazy/coexistree
16
+ ```
17
+
18
+ 还需 CLI:
19
+
20
+ ```bash
21
+ npm install -g @xiaoailazy/coexistree-cli
22
+ coexistree config initial --api-key "ce_..." --system-code "order-service"
23
+ ```
24
+
25
+ ## 安装器
26
+
27
+ ```bash
28
+ coexistree-skills-install --help
29
+ ```
30
+
31
+ | 选项 | 说明 |
32
+ |------|------|
33
+ | `--targets all` | 默认:cursor、claude、codex 的个人技能目录 |
34
+ | `--targets cursor,claude` | 只装到指定 Agent |
35
+ | `--project` | 同时写入当前项目的 `.cursor/skills` 等(适合仓库内协作) |
36
+ | `--force` | 覆盖已有 `SKILL.md` |
37
+ | `--dry-run` | 预览路径 |
38
+
39
+ 环境变量:`COEXISTREE_SKILLS_TARGETS`、`COEXISTREE_SKILLS_PROJECT=1`。
40
+
41
+ ### 安装路径
42
+
43
+ | Agent | 个人目录 | 项目目录(`--project`) |
44
+ |-------|----------|-------------------------|
45
+ | Cursor | `~/.cursor/skills/` | `.cursor/skills/` |
46
+ | Claude Code | `~/.claude/skills/` | `.claude/skills/` |
47
+ | Codex | `~/.codex/skills/` | `.codex/skills/` |
48
+
49
+ 每个 skill 一个子目录,例如 `coexistree-task/SKILL.md`。
50
+
51
+ ## 包含的 Skill
52
+
53
+ | name | 用途 |
54
+ |------|------|
55
+ | `coexistree-config` | 首次 `config initial`、`config show` |
56
+ | `coexistree-task` | 产研任务:列表、拉取、上传 |
57
+ | `coexistree-ask` | 知识树提问 |
58
+
59
+ ## 仓库开发
60
+
61
+ 从 monorepo 根目录同步到本机 Cursor(不发布 npm 时):
62
+
63
+ ```bash
64
+ node packages/skills/scripts/install-skills.js --targets cursor --project
65
+ ```
66
+
67
+ **源文件以 `packages/skills/skills/` 为准**;`.cursor/skills/` 可继续 gitignore,由安装器生成。
68
+
69
+ ## 发布
70
+
71
+ ```bash
72
+ cd packages/skills
73
+ npm publish --access public
74
+ ```
75
+
76
+ 版本宜与 `@xiaoailazy/coexistree-cli` 对齐 major/minor。
package/lib/targets.js ADDED
@@ -0,0 +1,43 @@
1
+ import { join } from "path";
2
+
3
+ /** @typedef {'cursor' | 'claude' | 'codex'} AgentTargetId */
4
+
5
+ /** @type {Record<AgentTargetId, { label: string; dirSegments: string[] }>} */
6
+ export const AGENT_TARGETS = {
7
+ cursor: { label: "Cursor", dirSegments: [".cursor", "skills"] },
8
+ claude: { label: "Claude Code", dirSegments: [".claude", "skills"] },
9
+ codex: { label: "Codex", dirSegments: [".codex", "skills"] },
10
+ };
11
+
12
+ export const ALL_TARGET_IDS = /** @type {const} */ (Object.keys(AGENT_TARGETS));
13
+
14
+ /**
15
+ * @param {string | undefined} raw comma-separated, e.g. "cursor,claude" or "all"
16
+ * @returns {AgentTargetId[]}
17
+ */
18
+ export function parseTargetIds(raw) {
19
+ const value = (raw ?? "all").trim().toLowerCase();
20
+ if (value === "all") {
21
+ return [...ALL_TARGET_IDS];
22
+ }
23
+ const ids = value
24
+ .split(",")
25
+ .map((s) => s.trim())
26
+ .filter(Boolean);
27
+ const unknown = ids.filter((id) => !(id in AGENT_TARGETS));
28
+ if (unknown.length > 0) {
29
+ throw new Error(
30
+ `Unknown target(s): ${unknown.join(", ")}. Valid: ${ALL_TARGET_IDS.join(", ")}, all`,
31
+ );
32
+ }
33
+ return /** @type {AgentTargetId[]} */ (ids);
34
+ }
35
+
36
+ /**
37
+ * @param {string} baseDir home dir or project root
38
+ * @param {AgentTargetId} targetId
39
+ */
40
+ export function skillsDirForTarget(baseDir, targetId) {
41
+ const { dirSegments } = AGENT_TARGETS[targetId];
42
+ return join(baseDir, ...dirSegments);
43
+ }
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@xiaoailazy/coexistree-skills",
3
+ "version": "0.2.0",
4
+ "description": "Agent Skills for CoExistree (Cursor, Claude Code, Codex, and compatible agents)",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/xiaoailazy/coexistree.git",
10
+ "directory": "packages/skills"
11
+ },
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
15
+ "keywords": [
16
+ "coexistree",
17
+ "agent-skills",
18
+ "cursor",
19
+ "claude",
20
+ "codex"
21
+ ],
22
+ "files": [
23
+ "skills",
24
+ "scripts",
25
+ "lib",
26
+ "README.md"
27
+ ],
28
+ "engines": {
29
+ "node": ">=18"
30
+ },
31
+ "bin": {
32
+ "coexistree-skills-install": "./scripts/install-skills.js"
33
+ },
34
+ "scripts": {
35
+ "test": "node --test test/**/*.test.js",
36
+ "install-skills": "node scripts/install-skills.js"
37
+ }
38
+ }
@@ -0,0 +1,134 @@
1
+ #!/usr/bin/env node
2
+ import { cpSync, existsSync, mkdirSync, readdirSync, statSync } from "fs";
3
+ import { homedir } from "os";
4
+ import { dirname, join } from "path";
5
+ import { fileURLToPath } from "url";
6
+ import { AGENT_TARGETS, parseTargetIds, skillsDirForTarget } from "../lib/targets.js";
7
+
8
+ const __dirname = dirname(fileURLToPath(import.meta.url));
9
+ const SKILLS_SRC = join(__dirname, "..", "skills");
10
+
11
+ function printHelp() {
12
+ console.log(`coexistree-skills-install — install CoExistree Agent Skills
13
+
14
+ 用法:
15
+ coexistree-skills-install [options]
16
+
17
+ 选项:
18
+ --targets <list> 目标 Agent:cursor, claude, codex(逗号分隔),或 all(默认 all)
19
+ --project 同时安装到当前项目目录(各 Agent 的 .*/skills/)
20
+ --force 覆盖已存在的 SKILL.md
21
+ --dry-run 只打印将要复制的路径
22
+ -h, --help
23
+
24
+ 环境变量:
25
+ COEXISTREE_SKILLS_TARGETS 同 --targets
26
+ COEXISTREE_SKILLS_PROJECT=1 同 --project
27
+
28
+ 个人目录示例:
29
+ ~/.cursor/skills/coexistree-config/SKILL.md
30
+ ~/.claude/skills/coexistree-task/SKILL.md
31
+
32
+ 需配合 CLI: npm install -g @xiaoailazy/coexistree-cli
33
+ `);
34
+ }
35
+
36
+ function parseArgv(argv) {
37
+ const opts = {
38
+ targets: process.env.COEXISTREE_SKILLS_TARGETS,
39
+ project: process.env.COEXISTREE_SKILLS_PROJECT === "1",
40
+ force: false,
41
+ dryRun: false,
42
+ help: false,
43
+ };
44
+ for (let i = 0; i < argv.length; i++) {
45
+ const arg = argv[i];
46
+ if (arg === "-h" || arg === "--help") {
47
+ opts.help = true;
48
+ } else if (arg === "--project") {
49
+ opts.project = true;
50
+ } else if (arg === "--force") {
51
+ opts.force = true;
52
+ } else if (arg === "--dry-run") {
53
+ opts.dryRun = true;
54
+ } else if (arg === "--targets") {
55
+ opts.targets = argv[++i];
56
+ } else {
57
+ throw new Error(`Unknown option: ${arg}`);
58
+ }
59
+ }
60
+ return opts;
61
+ }
62
+
63
+ function listSkillNames() {
64
+ if (!existsSync(SKILLS_SRC)) {
65
+ throw new Error(`Skills source missing: ${SKILLS_SRC}`);
66
+ }
67
+ return readdirSync(SKILLS_SRC).filter((name) => {
68
+ const p = join(SKILLS_SRC, name, "SKILL.md");
69
+ return existsSync(p) && statSync(join(SKILLS_SRC, name)).isDirectory();
70
+ });
71
+ }
72
+
73
+ /**
74
+ * @param {{ destRoot: string; force: boolean; dryRun: boolean }} ctx
75
+ */
76
+ function installSkillBundle(ctx) {
77
+ const names = listSkillNames();
78
+ mkdirSync(ctx.destRoot, { recursive: true });
79
+ for (const name of names) {
80
+ const srcFile = join(SKILLS_SRC, name, "SKILL.md");
81
+ const destDir = join(ctx.destRoot, name);
82
+ const destFile = join(destDir, "SKILL.md");
83
+ if (existsSync(destFile) && !ctx.force) {
84
+ console.log(`skip (exists): ${destFile}`);
85
+ continue;
86
+ }
87
+ if (ctx.dryRun) {
88
+ console.log(`would install: ${destFile}`);
89
+ continue;
90
+ }
91
+ mkdirSync(destDir, { recursive: true });
92
+ cpSync(srcFile, destFile);
93
+ console.log(`installed: ${destFile}`);
94
+ }
95
+ }
96
+
97
+ function projectRoot() {
98
+ return process.env.INIT_CWD || process.cwd();
99
+ }
100
+
101
+ function main() {
102
+ const opts = parseArgv(process.argv.slice(2));
103
+ if (opts.help) {
104
+ printHelp();
105
+ return;
106
+ }
107
+
108
+ const targetIds = parseTargetIds(opts.targets);
109
+ const bases = [{ label: "personal", path: homedir() }];
110
+ if (opts.project) {
111
+ bases.push({ label: "project", path: projectRoot() });
112
+ }
113
+
114
+ for (const base of bases) {
115
+ for (const targetId of targetIds) {
116
+ const destRoot = skillsDirForTarget(base.path, targetId);
117
+ const agent = AGENT_TARGETS[targetId].label;
118
+ console.log(`\n# ${agent} (${base.label}) → ${destRoot}`);
119
+ installSkillBundle({
120
+ destRoot,
121
+ force: opts.force,
122
+ dryRun: opts.dryRun,
123
+ });
124
+ }
125
+ }
126
+ }
127
+
128
+ try {
129
+ main();
130
+ } catch (err) {
131
+ console.error(err instanceof Error ? err.message : String(err));
132
+ printHelp();
133
+ process.exit(1);
134
+ }
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: coexistree-ask
3
+ description: CoExistree 知识树提问。用于「问 coexistree」「系统信息查询」「coexistree 提问」。
4
+ ---
5
+
6
+ # coexistree ask
7
+
8
+ 需已完成 **`coexistree config initial`**(见 `coexistree-config` skill)。
9
+
10
+ 通过终端执行 **`coexistree`**(先 `npm install -g @xiaoailazy/coexistree-cli`)。
11
+
12
+ ## 提问
13
+
14
+ ```bash
15
+ coexistree ask --question "<问题>"
16
+ ```
17
+
18
+ - `--question`:必填,向 CoExistree 知识树提问的内容
19
+
20
+ ## 结果
21
+
22
+ - 成功:读 stdout JSON,向用户摘要。
23
+ - 失败:非 0 退出码;看 stderr 与 JSON 的 `message` / `data.error`。
@@ -0,0 +1,38 @@
1
+ ---
2
+ name: coexistree-config
3
+ description: CoExistree 配置管理:初始化 API 密钥与 system code、查看当前配置。用于「配置 coexistree」「初始化密钥」「查看配置」。
4
+ ---
5
+
6
+ # coexistree config
7
+
8
+ 通过终端执行 **`coexistree`**(先 `npm install -g @xiaoailazy/coexistree-cli`)。适用于 Cursor、Claude Code、Codex 等支持 Agent Skills 的环境。
9
+
10
+ ## 首次配置(只需一次)
11
+
12
+ 在 Web **密钥管理** 开启 Agent 密钥并复制;确认目标系统的 **system code**。
13
+
14
+ ```bash
15
+ coexistree config initial \
16
+ --api-key "<从Web复制的 ce_ 密钥>" \
17
+ --system-code "<系统code>" \
18
+ [--base-url http://localhost:8080]
19
+ ```
20
+
21
+ - `--api-key`:必填,Web 密钥管理中的 Agent 密钥(`ce_` 前缀)
22
+ - `--system-code`:必填,目标系统唯一标识
23
+ - `--base-url`:可选,默认官方/本地 API 地址
24
+
25
+ 之后**不要**再加 `--env-file`。
26
+
27
+ ## 查看配置
28
+
29
+ ```bash
30
+ coexistree config show
31
+ ```
32
+
33
+ 用于核对 api-key(脱敏)、system-code、base-url。
34
+
35
+ ## 结果
36
+
37
+ - 成功:读 stdout JSON,向用户摘要。
38
+ - 失败:非 0 退出码;看 stderr 与 JSON 的 `message` / `data.error`。
@@ -0,0 +1,34 @@
1
+ ---
2
+ name: coexistree-task
3
+ description: CoExistree 产研任务:创建、列表、拉取、上传文档。
4
+ ---
5
+
6
+ # coexistree task
7
+
8
+ 前置:`coexistree config initial`。通过终端执行 **`coexistree`**(先 `npm install -g @xiaoailazy/coexistree-cli`)。
9
+
10
+ ## 约定
11
+
12
+ - **upload** 必须带 1 个 `.md` 路径;设计稿用 Agent 刚写完的文件,不确定则问用户。
13
+ - **pull** 默认写入 `docs/superpowers/{prd|specs|testcases}/{suggestedBasename}-{prd|design|testcase}-{documentId}.md`。
14
+ - 文档不会自动进知识树;须在 Web 对任务「应用变更」。
15
+
16
+ ## 命令
17
+
18
+ | 意图 | 命令 |
19
+ |------|------|
20
+ | 待开发任务 | `task list --scope pending-development` |
21
+ | 待补测试用例 | `task list --scope needs-test-case` |
22
+ | 读需求 | `task pull --task-id <id> --doc-type REQUIREMENT` |
23
+ | 读设计/用例 | `task pull --task-id <id> --doc-type DESIGN\|TEST_CASE [--document-id <id>]` |
24
+ | 上传设计 | `task upload --task-id <id> --doc-type DESIGN <file.md>` |
25
+ | 上传用例 | `task upload --task-id <id> --doc-type TEST_CASE <file.md>` |
26
+ | 创建任务 | `task create --title "<标题>" [--summary "<说明>"] <requirement.md>` |
27
+
28
+ `task list` 支持 `--page`、`--size`(默认 `0`、`5`)。
29
+
30
+ ## 流程
31
+
32
+ `list` → `pull REQUIREMENT` → 写设计 → `upload DESIGN` →(可选)`upload TEST_CASE`
33
+
34
+ stdout 为 JSON `{ success, code, message, data }`;失败时非 0 退出。