@dztabel/docxkit 0.1.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 +17 -0
- package/docs/public-boundary.md +86 -0
- package/npm/docx-kit.cjs +102 -0
- package/package.json +24 -0
package/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# DocxKit
|
|
2
|
+
|
|
3
|
+
Agent-facing CLI for exporting prepared Markdown or `report.json` into polished, editable Word `.docx` reports.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install @dztabel/docxkit
|
|
7
|
+
npx --no-install docx-kit --version
|
|
8
|
+
npx --no-install docx-kit build content.md --out ./report
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Outputs:
|
|
12
|
+
|
|
13
|
+
- `report/report.docx`
|
|
14
|
+
- `report/report.json`
|
|
15
|
+
- `report/build-result.json`
|
|
16
|
+
|
|
17
|
+
The MVP ships the `executive-cn-docx` template for formal Chinese reports.
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# DocxKit Public Boundary
|
|
2
|
+
|
|
3
|
+
`docxkit-cli` 是对外 npm 入口仓库,不承载核心渲染能力。
|
|
4
|
+
|
|
5
|
+
## 仓库职责
|
|
6
|
+
|
|
7
|
+
本仓库包含:
|
|
8
|
+
|
|
9
|
+
- `package.json`
|
|
10
|
+
- npm wrapper:`npm/docx-kit.cjs`
|
|
11
|
+
- 平台包 metadata:`npm/platform-packages/*/package.json`
|
|
12
|
+
- 用户 README
|
|
13
|
+
- Codex skill
|
|
14
|
+
- 公开示例和截图
|
|
15
|
+
|
|
16
|
+
本仓库不包含:
|
|
17
|
+
|
|
18
|
+
- `.NET` / OpenXML renderer 源码;
|
|
19
|
+
- Word 模板源码;
|
|
20
|
+
- schemas;
|
|
21
|
+
- 测试;
|
|
22
|
+
- release preflight;
|
|
23
|
+
- 私有产品说明;
|
|
24
|
+
- npm token。
|
|
25
|
+
|
|
26
|
+
主包不包含二进制。平台包目录在发布前会放入当前平台 self-contained binary。
|
|
27
|
+
public 仓库必须通过 `.gitignore` 忽略平台二进制:
|
|
28
|
+
|
|
29
|
+
```gitignore
|
|
30
|
+
npm/platform-packages/*/docx-kit
|
|
31
|
+
npm/platform-packages/*/docx-kit.exe
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## npm 包结构
|
|
35
|
+
|
|
36
|
+
```text
|
|
37
|
+
@dztabel/docxkit
|
|
38
|
+
public npm wrapper
|
|
39
|
+
- bin: docx-kit, docxkit
|
|
40
|
+
- optionalDependencies 指向平台包
|
|
41
|
+
|
|
42
|
+
@dztabel/docxkit-darwin-arm64
|
|
43
|
+
platform packages
|
|
44
|
+
- 只包含当前平台 self-contained binary
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
MVP 只发布 `@dztabel/docxkit-darwin-arm64`。Linux 和 Windows 平台包是跨平台构建阶段的后续项。
|
|
48
|
+
|
|
49
|
+
## 产品验收
|
|
50
|
+
|
|
51
|
+
产品验收以 npm 安装态为准:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npm install @dztabel/docxkit
|
|
55
|
+
npx --no-install docx-kit --version
|
|
56
|
+
npx --no-install docx-kit build content.md --out ./report
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
验收通过条件:
|
|
60
|
+
|
|
61
|
+
- 用户无需安装 Python、.NET SDK、Typst 或 Microsoft Word;
|
|
62
|
+
- stdout 是单个 JSON;
|
|
63
|
+
- `build-result.json` 与 stdout 完全一致;
|
|
64
|
+
- 输出包含 `report.docx`、`report.json`、`build-result.json`;
|
|
65
|
+
- `report.docx` 完整复刻 ReportKit 默认 `executive-cn` 格式;
|
|
66
|
+
- 主包 tarball 不包含 core 源码、模板源码、schemas、tests 或二进制;
|
|
67
|
+
- 平台包 tarball 只包含当前平台二进制和 package metadata。
|
|
68
|
+
|
|
69
|
+
## 发布凭证和发布方式
|
|
70
|
+
|
|
71
|
+
npm 已在本机用户级配置中登录。后续 LLM / Agent 发布前只需要验证当前登录态:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
npm whoami
|
|
75
|
+
npm ping
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
禁止读取、打印或提交任何 npm / GitHub token;禁止把 token 写入仓库、README、脚本、日志样例或构建产物。
|
|
79
|
+
|
|
80
|
+
本机 GitHub 已验证可用:`gh auth status` 通过,账号 `dztabel-happy`,具备 `repo`、`workflow` 权限,可推送 GitHub。
|
|
81
|
+
|
|
82
|
+
完整发布步骤见:
|
|
83
|
+
|
|
84
|
+
```text
|
|
85
|
+
/Users/dztmacmini/project/zhiyun/docxkit-cli-core/docs/release-runbook.md
|
|
86
|
+
```
|
package/npm/docx-kit.cjs
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { spawnSync } = require("node:child_process");
|
|
3
|
+
const fs = require("node:fs");
|
|
4
|
+
const path = require("node:path");
|
|
5
|
+
|
|
6
|
+
const packageRoot = findPackageRoot();
|
|
7
|
+
const binary = findPlatformPackageBinary();
|
|
8
|
+
|
|
9
|
+
if (!binary) {
|
|
10
|
+
const packageName = platformPackageName();
|
|
11
|
+
const version = packageVersion();
|
|
12
|
+
console.error("docx-kit: platform package is missing.");
|
|
13
|
+
console.error(
|
|
14
|
+
packageName
|
|
15
|
+
? `docx-kit: expected optional dependency ${packageName} to provide the binary.`
|
|
16
|
+
: `docx-kit: unsupported platform ${process.platform}/${process.arch}.`,
|
|
17
|
+
);
|
|
18
|
+
if (packageName) {
|
|
19
|
+
console.error(`docx-kit: run "npm install -g @dztabel/docxkit@${version} ${packageName}@${version}".`);
|
|
20
|
+
}
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const result = spawnSync(binary, process.argv.slice(2), {
|
|
25
|
+
cwd: process.cwd(),
|
|
26
|
+
env: process.env,
|
|
27
|
+
stdio: "inherit",
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
if (result.error) {
|
|
31
|
+
console.error(`docx-kit: failed to start: ${result.error.message}`);
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
process.exit(result.status ?? 1);
|
|
36
|
+
|
|
37
|
+
function findPackageRoot() {
|
|
38
|
+
const candidates = [
|
|
39
|
+
path.resolve(__dirname, ".."),
|
|
40
|
+
path.resolve(__dirname, "node_modules", "@dztabel", "docxkit"),
|
|
41
|
+
path.resolve(__dirname, "..", "node_modules", "@dztabel", "docxkit"),
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
for (const candidate of candidates) {
|
|
45
|
+
if (isDocxKitPackageRoot(candidate)) {
|
|
46
|
+
return candidate;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
const packageJson = require.resolve("@dztabel/docxkit/package.json", {
|
|
52
|
+
paths: [__dirname, process.cwd()],
|
|
53
|
+
});
|
|
54
|
+
return path.dirname(packageJson);
|
|
55
|
+
} catch (_) {
|
|
56
|
+
return path.resolve(__dirname, "..");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function isDocxKitPackageRoot(candidate) {
|
|
61
|
+
try {
|
|
62
|
+
const packageJson = JSON.parse(fs.readFileSync(path.join(candidate, "package.json"), "utf8"));
|
|
63
|
+
return packageJson.name === "@dztabel/docxkit" && fs.existsSync(path.join(candidate, "npm", "docx-kit.cjs"));
|
|
64
|
+
} catch (_) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function findPlatformPackageBinary() {
|
|
70
|
+
const packageName = platformPackageName();
|
|
71
|
+
if (!packageName) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
const packageJson = require.resolve(`${packageName}/package.json`, { paths: [packageRoot] });
|
|
76
|
+
const platformRoot = path.dirname(packageJson);
|
|
77
|
+
const candidate = path.join(platformRoot, process.platform === "win32" ? "docx-kit.exe" : "docx-kit");
|
|
78
|
+
return fs.existsSync(candidate) ? candidate : null;
|
|
79
|
+
} catch (_) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function platformPackageName() {
|
|
85
|
+
const arch = process.arch === "arm64" ? "arm64" : process.arch === "x64" ? "x64" : null;
|
|
86
|
+
if (!arch) {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
if (process.platform === "darwin") {
|
|
90
|
+
return `@dztabel/docxkit-darwin-${arch}`;
|
|
91
|
+
}
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function packageVersion() {
|
|
96
|
+
try {
|
|
97
|
+
const packageJson = JSON.parse(fs.readFileSync(path.join(packageRoot, "package.json"), "utf8"));
|
|
98
|
+
return packageJson.version || "latest";
|
|
99
|
+
} catch (_) {
|
|
100
|
+
return "latest";
|
|
101
|
+
}
|
|
102
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dztabel/docxkit",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Agent-facing CLI for exporting prepared content into polished Word docx reports.",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"bin": {
|
|
10
|
+
"docx-kit": "npm/docx-kit.cjs",
|
|
11
|
+
"docxkit": "npm/docx-kit.cjs"
|
|
12
|
+
},
|
|
13
|
+
"optionalDependencies": {
|
|
14
|
+
"@dztabel/docxkit-darwin-arm64": "0.1.0"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"npm/docx-kit.cjs",
|
|
18
|
+
"README.md",
|
|
19
|
+
"docs/public-boundary.md"
|
|
20
|
+
],
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=18"
|
|
23
|
+
}
|
|
24
|
+
}
|