dingtalk-workspace-cli 0.0.48-beta.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/README.md +4 -0
- package/assets/dws-darwin-amd64.tar.gz +0 -0
- package/assets/dws-darwin-arm64.tar.gz +0 -0
- package/assets/dws-linux-amd64.tar.gz +0 -0
- package/assets/dws-linux-arm64.tar.gz +0 -0
- package/assets/dws-skills.zip +0 -0
- package/assets/dws-windows-amd64.zip +0 -0
- package/assets/dws-windows-arm64.zip +0 -0
- package/bin/dws.js +25 -0
- package/install.js +198 -0
- package/package.json +37 -0
package/README.md
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/bin/dws.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
const path = require("path");
|
|
7
|
+
const childProcess = require("child_process");
|
|
8
|
+
|
|
9
|
+
const binaryPath = path.join(__dirname, "..", "vendor", process.platform === "win32" ? "dws.exe" : "dws");
|
|
10
|
+
|
|
11
|
+
if (!fs.existsSync(binaryPath)) {
|
|
12
|
+
console.error(`dws binary not found at ${binaryPath}. Reinstall the package.`);
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const result = childProcess.spawnSync(binaryPath, process.argv.slice(2), {
|
|
17
|
+
stdio: "inherit",
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
if (result.error) {
|
|
21
|
+
console.error(result.error.message);
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
process.exit(result.status === null ? 1 : result.status);
|
package/install.js
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
const os = require("os");
|
|
7
|
+
const path = require("path");
|
|
8
|
+
const childProcess = require("child_process");
|
|
9
|
+
|
|
10
|
+
// Canonical list: keep scripts/install.sh, scripts/install.ps1, scripts/install-skills.sh in sync.
|
|
11
|
+
const AGENT_DIRS = [
|
|
12
|
+
".agents/skills",
|
|
13
|
+
".claude/skills",
|
|
14
|
+
".cursor/skills",
|
|
15
|
+
".qoder/skills",
|
|
16
|
+
".qoderwork/skills",
|
|
17
|
+
".gemini/skills",
|
|
18
|
+
".codex/skills",
|
|
19
|
+
".github/skills",
|
|
20
|
+
".windsurf/skills",
|
|
21
|
+
".augment/skills",
|
|
22
|
+
".cline/skills",
|
|
23
|
+
".amp/skills",
|
|
24
|
+
".kiro/skills",
|
|
25
|
+
".trae/skills",
|
|
26
|
+
".openclaw/skills",
|
|
27
|
+
".hermes/skills",
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
const PLATFORM_MAP = {
|
|
31
|
+
"darwin-x64": "dws-darwin-amd64.tar.gz",
|
|
32
|
+
"darwin-arm64": "dws-darwin-arm64.tar.gz",
|
|
33
|
+
"linux-x64": "dws-linux-amd64.tar.gz",
|
|
34
|
+
"linux-arm64": "dws-linux-arm64.tar.gz",
|
|
35
|
+
"win32-x64": "dws-windows-amd64.zip",
|
|
36
|
+
"win32-arm64": "dws-windows-arm64.zip",
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
function run(command, args) {
|
|
40
|
+
childProcess.execFileSync(command, args, { stdio: "inherit" });
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function ensureCleanDir(dir) {
|
|
44
|
+
fs.rmSync(dir, { recursive: true, force: true });
|
|
45
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function findBinary(root) {
|
|
49
|
+
const entries = fs.readdirSync(root, { withFileTypes: true });
|
|
50
|
+
for (const entry of entries) {
|
|
51
|
+
const entryPath = path.join(root, entry.name);
|
|
52
|
+
if (entry.isDirectory()) {
|
|
53
|
+
const nested = findBinary(entryPath);
|
|
54
|
+
if (nested) {
|
|
55
|
+
return nested;
|
|
56
|
+
}
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if (entry.name === "dws" || entry.name === "dws.exe") {
|
|
60
|
+
return entryPath;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return "";
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function extractArchive(archivePath, destDir) {
|
|
67
|
+
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "dws-npm-bin-"));
|
|
68
|
+
try {
|
|
69
|
+
if (archivePath.endsWith(".tar.gz")) {
|
|
70
|
+
run("tar", ["-xzf", archivePath, "-C", tmpDir]);
|
|
71
|
+
} else if (process.platform === "win32") {
|
|
72
|
+
run("powershell.exe", [
|
|
73
|
+
"-NoLogo",
|
|
74
|
+
"-NoProfile",
|
|
75
|
+
"-Command",
|
|
76
|
+
`Expand-Archive -Path '${archivePath.replace(/'/g, "''")}' -DestinationPath '${tmpDir.replace(/'/g, "''")}' -Force`,
|
|
77
|
+
]);
|
|
78
|
+
} else {
|
|
79
|
+
run("unzip", ["-q", archivePath, "-d", tmpDir]);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const binaryPath = findBinary(tmpDir);
|
|
83
|
+
if (!binaryPath) {
|
|
84
|
+
throw new Error(`dws binary not found in archive ${archivePath}`);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
ensureCleanDir(destDir);
|
|
88
|
+
const targetName = process.platform === "win32" ? "dws.exe" : "dws";
|
|
89
|
+
const targetPath = path.join(destDir, targetName);
|
|
90
|
+
fs.copyFileSync(binaryPath, targetPath);
|
|
91
|
+
if (process.platform !== "win32") {
|
|
92
|
+
fs.chmodSync(targetPath, 0o755);
|
|
93
|
+
}
|
|
94
|
+
} finally {
|
|
95
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function extractSkills(zipPath, destDir) {
|
|
100
|
+
ensureCleanDir(destDir);
|
|
101
|
+
if (process.platform === "win32") {
|
|
102
|
+
run("powershell.exe", [
|
|
103
|
+
"-NoLogo",
|
|
104
|
+
"-NoProfile",
|
|
105
|
+
"-Command",
|
|
106
|
+
`Expand-Archive -Path '${zipPath.replace(/'/g, "''")}' -DestinationPath '${destDir.replace(/'/g, "''")}' -Force`,
|
|
107
|
+
]);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
run("unzip", ["-q", zipPath, "-d", destDir]);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function copyChildren(srcDir, destDir) {
|
|
114
|
+
fs.mkdirSync(destDir, { recursive: true });
|
|
115
|
+
for (const entry of fs.readdirSync(srcDir)) {
|
|
116
|
+
fs.cpSync(path.join(srcDir, entry), path.join(destDir, entry), { recursive: true, force: true });
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function installSkillsToHomes(skillRoot) {
|
|
121
|
+
const homeDir = os.homedir();
|
|
122
|
+
let installed = 0;
|
|
123
|
+
|
|
124
|
+
AGENT_DIRS.forEach((agentDir, index) => {
|
|
125
|
+
const baseDir = path.join(homeDir, agentDir);
|
|
126
|
+
const parentGate = path.dirname(baseDir);
|
|
127
|
+
if (index > 0 && !fs.existsSync(parentGate)) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
const destDir = path.join(baseDir, "dws");
|
|
131
|
+
fs.rmSync(destDir, { recursive: true, force: true });
|
|
132
|
+
copyChildren(skillRoot, destDir);
|
|
133
|
+
installed += 1;
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
if (installed === 0) {
|
|
137
|
+
copyChildren(skillRoot, path.join(homeDir, ".agents", "skills", "dws"));
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// cacheUserSkills copies the mono and multi trees out of the freshly extracted
|
|
142
|
+
// dws-skills.zip into ~/.dws/skills/{mono,multi}/ so that `dws skill setup`
|
|
143
|
+
// can fall back to a user-local cache when --source is not provided. mono is
|
|
144
|
+
// already installed into agent homes by installSkillsToHomes; the cache is
|
|
145
|
+
// purely a source-of-truth for the setup command.
|
|
146
|
+
function cacheUserSkills(extractedSkillsRoot) {
|
|
147
|
+
const cacheBase = path.join(os.homedir(), ".dws", "skills");
|
|
148
|
+
|
|
149
|
+
const monoSource = fs.existsSync(path.join(extractedSkillsRoot, "mono", "SKILL.md"))
|
|
150
|
+
? path.join(extractedSkillsRoot, "mono")
|
|
151
|
+
: extractedSkillsRoot;
|
|
152
|
+
const monoCache = path.join(cacheBase, "mono");
|
|
153
|
+
fs.rmSync(monoCache, { recursive: true, force: true });
|
|
154
|
+
copyChildren(monoSource, monoCache);
|
|
155
|
+
|
|
156
|
+
const multiSource = path.join(extractedSkillsRoot, "multi");
|
|
157
|
+
if (fs.existsSync(multiSource) && fs.statSync(multiSource).isDirectory()) {
|
|
158
|
+
const multiCache = path.join(cacheBase, "multi");
|
|
159
|
+
fs.rmSync(multiCache, { recursive: true, force: true });
|
|
160
|
+
copyChildren(multiSource, multiCache);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function main() {
|
|
165
|
+
const packageRoot = __dirname;
|
|
166
|
+
const assetsDir = path.join(packageRoot, "assets");
|
|
167
|
+
const vendorDir = path.join(packageRoot, "vendor");
|
|
168
|
+
// Extract dws-skills.zip into a staging directory so we can split mono/
|
|
169
|
+
// (installed to agent homes) from multi/ (cached for later setup use).
|
|
170
|
+
const skillsStaging = path.join(packageRoot, "share", "skills");
|
|
171
|
+
const assetName = PLATFORM_MAP[`${process.platform}-${process.arch}`];
|
|
172
|
+
if (!assetName) {
|
|
173
|
+
throw new Error(`unsupported platform: ${process.platform}/${process.arch}`);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const archivePath = path.join(assetsDir, assetName);
|
|
177
|
+
const skillsPath = path.join(assetsDir, "dws-skills.zip");
|
|
178
|
+
if (!fs.existsSync(archivePath)) {
|
|
179
|
+
throw new Error(`missing platform archive: ${archivePath}`);
|
|
180
|
+
}
|
|
181
|
+
if (!fs.existsSync(skillsPath)) {
|
|
182
|
+
throw new Error(`missing skills archive: ${skillsPath}`);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
extractArchive(archivePath, vendorDir);
|
|
186
|
+
extractSkills(skillsPath, skillsStaging);
|
|
187
|
+
|
|
188
|
+
// For backward compatibility, the zip root carries a copy of mono content
|
|
189
|
+
// (SKILL.md + references/ + scripts/). Prefer the explicit mono/ subdir
|
|
190
|
+
// when present; fall back to the staging root otherwise.
|
|
191
|
+
const monoRoot = fs.existsSync(path.join(skillsStaging, "mono", "SKILL.md"))
|
|
192
|
+
? path.join(skillsStaging, "mono")
|
|
193
|
+
: skillsStaging;
|
|
194
|
+
installSkillsToHomes(monoRoot);
|
|
195
|
+
cacheUserSkills(skillsStaging);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
main();
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "dingtalk-workspace-cli",
|
|
3
|
+
"version": "0.0.48-beta.1",
|
|
4
|
+
"description": "DingTalk Workspace CLI - AI-powered productivity tools",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/open-dingtalk/dingtalk-workspace-cli.git"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/open-dingtalk/dingtalk-workspace-cli",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/open-dingtalk/dingtalk-workspace-cli/issues"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"dingtalk",
|
|
16
|
+
"dws",
|
|
17
|
+
"cli",
|
|
18
|
+
"workspace",
|
|
19
|
+
"ai",
|
|
20
|
+
"productivity"
|
|
21
|
+
],
|
|
22
|
+
"bin": {
|
|
23
|
+
"dws": "./bin/dws.js"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"postinstall": "node install.js"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"assets",
|
|
30
|
+
"bin",
|
|
31
|
+
"install.js",
|
|
32
|
+
"README.md"
|
|
33
|
+
],
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">=16"
|
|
36
|
+
}
|
|
37
|
+
}
|