skill-family-harness-node 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/CODE_OF_CONDUCT.md +131 -0
- package/CONTRIBUTING.md +69 -0
- package/LICENSE +202 -0
- package/README.md +64 -0
- package/SECURITY.md +34 -0
- package/package.json +35 -0
- package/src/atomic.mjs +114 -0
- package/src/closure.mjs +153 -0
- package/src/errors.mjs +75 -0
- package/src/index.mjs +52 -0
- package/src/paths.mjs +285 -0
- package/src/request.mjs +274 -0
- package/src/validation.mjs +116 -0
- package/src/workspace.mjs +119 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# 贡献者公约(Contributor Covenant Code of Conduct)
|
|
2
|
+
|
|
3
|
+
本行为准则采用 Contributor Covenant 2.1 标准文本,来源明确:
|
|
4
|
+
`https://www.contributor-covenant.org/version/2/1/code_of_conduct/`。
|
|
5
|
+
译文与解读以英文原文为准;执行联系方式见文末。
|
|
6
|
+
|
|
7
|
+
## Our Pledge
|
|
8
|
+
|
|
9
|
+
We as members, contributors, and leaders pledge to make participation in our
|
|
10
|
+
community a harassment-free experience for everyone, regardless of age, body
|
|
11
|
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
|
12
|
+
identity and expression, level of experience, education, socio-economic status,
|
|
13
|
+
nationality, personal appearance, race, religion, or sexual identity
|
|
14
|
+
and orientation.
|
|
15
|
+
|
|
16
|
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
|
17
|
+
diverse, inclusive, and healthy community.
|
|
18
|
+
|
|
19
|
+
## Our Standards
|
|
20
|
+
|
|
21
|
+
Examples of behavior that contributes to a positive environment for our
|
|
22
|
+
community include:
|
|
23
|
+
|
|
24
|
+
* Demonstrating empathy and kindness toward other people
|
|
25
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
|
26
|
+
* Giving and gracefully accepting constructive feedback
|
|
27
|
+
* Accepting responsibility and apologizing to those affected by our mistakes,
|
|
28
|
+
and learning from the experience
|
|
29
|
+
* Focusing on what is best not just for us as individuals, but for the
|
|
30
|
+
overall community
|
|
31
|
+
|
|
32
|
+
Examples of unacceptable behavior include:
|
|
33
|
+
|
|
34
|
+
* The use of sexualized language or imagery, and sexual attention or
|
|
35
|
+
advances of any kind
|
|
36
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
|
37
|
+
* Public or private harassment
|
|
38
|
+
* Publishing others' private information, such as a physical or email
|
|
39
|
+
address, without their explicit permission
|
|
40
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
41
|
+
professional setting
|
|
42
|
+
|
|
43
|
+
## Enforcement Responsibilities
|
|
44
|
+
|
|
45
|
+
Community leaders are responsible for clarifying and enforcing our standards of
|
|
46
|
+
acceptable behavior and will take appropriate and fair corrective action in
|
|
47
|
+
response to any behavior that they deem inappropriate, threatening, offensive,
|
|
48
|
+
or harmful.
|
|
49
|
+
|
|
50
|
+
Community leaders have the right and responsibility to remove, edit, or reject
|
|
51
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
|
52
|
+
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
|
53
|
+
decisions when appropriate.
|
|
54
|
+
|
|
55
|
+
## Scope
|
|
56
|
+
|
|
57
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
|
58
|
+
an individual is officially representing the community in public spaces.
|
|
59
|
+
Examples of representing our community include using an official e-mail address,
|
|
60
|
+
posting via an official social media account, or acting as an appointed
|
|
61
|
+
representative at an online or offline event.
|
|
62
|
+
|
|
63
|
+
## Enforcement
|
|
64
|
+
|
|
65
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
66
|
+
reported to the community leaders responsible for enforcement through the
|
|
67
|
+
source repository's private channels (see SECURITY.md for private reporting).
|
|
68
|
+
All complaints will be reviewed and investigated promptly and fairly.
|
|
69
|
+
|
|
70
|
+
All community leaders are obligated to respect the privacy and security of the
|
|
71
|
+
reporter of any incident.
|
|
72
|
+
|
|
73
|
+
## Enforcement Guidelines
|
|
74
|
+
|
|
75
|
+
Community leaders will follow these Community Impact Guidelines in determining
|
|
76
|
+
the consequences for any action they deem in violation of this Code of Conduct:
|
|
77
|
+
|
|
78
|
+
### 1. Correction
|
|
79
|
+
|
|
80
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed
|
|
81
|
+
unprofessional or unwelcome in the community.
|
|
82
|
+
|
|
83
|
+
**Consequence**: A private, written warning from community leaders, providing
|
|
84
|
+
clarity around the nature of the violation and an explanation of why the
|
|
85
|
+
behavior was inappropriate. A public apology may be requested.
|
|
86
|
+
|
|
87
|
+
### 2. Warning
|
|
88
|
+
|
|
89
|
+
**Community Impact**: A violation through a single incident or series
|
|
90
|
+
of actions.
|
|
91
|
+
|
|
92
|
+
**Consequence**: A warning with consequences for continued behavior. No
|
|
93
|
+
interaction with the people involved, including unsolicited interaction with
|
|
94
|
+
those enforcing the Code of Conduct, for a specified period of time. This
|
|
95
|
+
includes avoiding interactions in community spaces as well as external channels
|
|
96
|
+
like social media. Violating these terms may lead to a temporary or
|
|
97
|
+
permanent ban.
|
|
98
|
+
|
|
99
|
+
### 3. Temporary Ban
|
|
100
|
+
|
|
101
|
+
**Community Impact**: A serious violation of community standards, including
|
|
102
|
+
sustained inappropriate behavior.
|
|
103
|
+
|
|
104
|
+
**Consequence**: A temporary ban from any sort of interaction or public
|
|
105
|
+
communication with the community for a specified period of time. No public or
|
|
106
|
+
private interaction with the people involved, including unsolicited interaction
|
|
107
|
+
with those enforcing the Code of Conduct, is allowed during this period.
|
|
108
|
+
Violating these terms may lead to a permanent ban.
|
|
109
|
+
|
|
110
|
+
### 4. Permanent Ban
|
|
111
|
+
|
|
112
|
+
**Community Impact**: Demonstrating a pattern of violation of community
|
|
113
|
+
standards, including sustained inappropriate behavior, harassment of an
|
|
114
|
+
individual, or aggression toward or disparagement of classes of individuals.
|
|
115
|
+
|
|
116
|
+
**Consequence**: A permanent ban from any sort of public interaction within
|
|
117
|
+
the community.
|
|
118
|
+
|
|
119
|
+
## Attribution
|
|
120
|
+
|
|
121
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
122
|
+
version 2.1, available at
|
|
123
|
+
`https://www.contributor-covenant.org/version/2/1/code_of_conduct/`.
|
|
124
|
+
|
|
125
|
+
Community Impact Guidelines were inspired by Mozilla's code of conduct
|
|
126
|
+
enforcement ladder.
|
|
127
|
+
|
|
128
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
|
129
|
+
`https://www.contributor-covenant.org/faq`.
|
|
130
|
+
|
|
131
|
+
[homepage]: https://www.contributor-covenant.org
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# 贡献指南(Contributing)
|
|
2
|
+
|
|
3
|
+
感谢关注 `skill-family-foundation-workspace`。本文件说明本地开发环境、
|
|
4
|
+
验证流程与 PR 规则。行为准则见 [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md),
|
|
5
|
+
Git 写操作的授权边界见仓库内文档站的生命周期指南(`docs/git-lifecycle.md`)。
|
|
6
|
+
|
|
7
|
+
拓扑说明:本工作区仓永久 private,是唯一开发真源;三个 public 仓
|
|
8
|
+
(`skill-family-contracts`、`skill-family-harness-node`、
|
|
9
|
+
`skill-family-engineering-kit`)是版本化发布镜像,不承载完整开发历史与
|
|
10
|
+
测试,也不接受直接 PR 或 issue。本指南描述的是私有工作区内经授权的开发
|
|
11
|
+
流程;消费坐标与发布状态唯一见 `docs/status/current.md`。
|
|
12
|
+
|
|
13
|
+
## 本地安装
|
|
14
|
+
|
|
15
|
+
必需工具(精确版本见仓库内 `docs/setup.md` 的安装合同):
|
|
16
|
+
|
|
17
|
+
- Node.js:`>=22.22.2 <23`(版本取自 `.node-version`)
|
|
18
|
+
- pnpm:10.30.0(`packageManager` 精确锁定)
|
|
19
|
+
- Python:3.10 或更高(仅文档站构建需要)
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pnpm install
|
|
23
|
+
pnpm synth
|
|
24
|
+
pnpm check
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
- `pnpm synth` 再生成 projen 受管文件。受管文件只能通过修改
|
|
28
|
+
`.projenrc.js` 间接变更;手写源码、文档和 fixture 不会被 synth 覆盖。
|
|
29
|
+
- `pnpm check` 是统一根门禁:10 个稳定门禁 ID 按固定顺序串联执行,
|
|
30
|
+
任一步骤非 0 即整体失败。
|
|
31
|
+
|
|
32
|
+
## 提交 PR 前必须做到
|
|
33
|
+
|
|
34
|
+
1. 只修改当前任务授权的文件,不顺手改动无关文件;
|
|
35
|
+
2. 修改 `.projenrc.js` 后运行 `pnpm synth`,并保证连续两次 synth 零漂移;
|
|
36
|
+
3. 本地完整通过根门禁:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pnpm check
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
4. 涉及文档时额外运行文档事实与链接检查:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
node scripts/docs/fact-check.mjs
|
|
46
|
+
node scripts/docs/link-check.mjs
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
5. 涉及三个叶子包时,确认发布字节合同仍然成立:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
pnpm run release-artifacts:build -- --output .artifacts/publish-candidates
|
|
53
|
+
pnpm run release-artifacts:verify -- --root .artifacts/publish-candidates --manifest .artifacts/publish-candidates/release-artifacts.manifest.json
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## PR 规则
|
|
57
|
+
|
|
58
|
+
- PR 描述须包含:动机、变更面、本地门禁结果(退出码)与剩余风险;
|
|
59
|
+
- 不得为转绿而弱化任何产品门禁、Action pin、权限、泄漏策略或 tarball 合同;
|
|
60
|
+
- 不新增运行时依赖,除非先经评审并显式修订泄漏策略中的公开依赖清单;
|
|
61
|
+
- 不提交生成物与本地状态:`node_modules`、`site/`、`.artifacts/`、缓存、
|
|
62
|
+
日志、凭据或本机绝对路径一律不进入提交;
|
|
63
|
+
- 受管投影必须与产生它的源变更在同一 PR 内提交,禁止手改受管文件;
|
|
64
|
+
- 动态状态(实时发布状态、远端对象状态)不写入版本化文档,唯一产品状态
|
|
65
|
+
口径见 `docs/status/current.md`。
|
|
66
|
+
|
|
67
|
+
## 安全报告
|
|
68
|
+
|
|
69
|
+
漏洞报告渠道与支持版本见 [SECURITY.md](SECURITY.md)。
|
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright (c) 2026 skill-family-foundation-workspace contributors
|
|
190
|
+
Copyright (c) 2026 广州市风荷科技有限公司
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
<!-- release-skill:safe-first-command -->
|
|
2
|
+
<!-- release-skill:external-write-boundary -->
|
|
3
|
+
|
|
4
|
+
# skill-family-harness-node
|
|
5
|
+
|
|
6
|
+
Contracts 机制协议的**唯一默认 Node 实现**。这是一个薄运行时(thin runtime):只实现机制协议,不引入业务语义,不做第二语言实现。
|
|
7
|
+
|
|
8
|
+
## 边界
|
|
9
|
+
|
|
10
|
+
- 消费 `skill-family-contracts`(工作区依赖),复用其方言路由的 Ajv validator、Kernel Protocol、冻结错误码与 fixture;不复制协议定义,不重新解释 Schema。
|
|
11
|
+
- 只实现机制:Schema 校验、原子写、路径收容、临时工作区、资源闭包、operation-request → operation-result 管道。
|
|
12
|
+
- 明确排除:业务语义、任务编排、Git 写入、模型调用、远程网络、发布状态。见 `HARNESS_EXCLUSIONS`。
|
|
13
|
+
|
|
14
|
+
## 公共 API
|
|
15
|
+
|
|
16
|
+
| 导出 | 职责 |
|
|
17
|
+
| --- | --- |
|
|
18
|
+
| `HARNESS_CAPABILITIES` / `HARNESS_EXCLUSIONS` | 能力与排除清单(冻结常量)。 |
|
|
19
|
+
| `HarnessError` / `HARNESS_ERROR_KINDS` / `mechanismError` | 机制失败统一携带注册错误码 `SFC2004`,`details.kind` 给出稳定细分。 |
|
|
20
|
+
| `validateContractDocument` / `getValidator` / `resolveSchemaContext` / `validatorCacheSize` | 按 Schema 方言路由并缓存 validator;复用 Contracts 的 Ajv 实例与 dialect/policy 语义。 |
|
|
21
|
+
| `classifyPathInput` / `resolveContained` / `readFileContained` | 路径收容:拦截路径越界、符号链接逃逸、真实路径逃逸。 |
|
|
22
|
+
| `writeFileAtomic` | 原子写:失败不留半成品(临时文件 + fsync + rename)。 |
|
|
23
|
+
| `TemporaryWorkspace` / `createTemporaryWorkspace` / `withTemporaryWorkspace` | 自动清理的临时工作区,异常路径也清理。 |
|
|
24
|
+
| `digestBytes` / `computeResourceClosure` / `closureContains` | 资源闭包与确定性 sha256 摘要。 |
|
|
25
|
+
| `parseRequest` / `processRequest` | 解析 `operation-request`,输出终态 `operation-result`。 |
|
|
26
|
+
|
|
27
|
+
## 稳定错误码
|
|
28
|
+
|
|
29
|
+
全部复用 Contracts 冻结登记表,不新增未登记码。机制失败统一为 `SFC2004`(EXECUTION_FAILED),`details.kind` 取 `HARNESS_ERROR_KINDS` 中的稳定值,例如 `path-traversal`、`symlink-escape`、`realpath-escape`、`atomic-write-failed`、`missing-resource`、`workspace-disposed`。
|
|
30
|
+
|
|
31
|
+
新增一个全新的 SFC 码属于 Contracts 变更(登记表在 contracts 包内),超出本包写集;因此用「`SFC2004` + 稳定 `details.kind`」组合保持对外语义稳定。
|
|
32
|
+
|
|
33
|
+
## 路径收容模型
|
|
34
|
+
|
|
35
|
+
`resolveContained(root, rel)` 是所有文件系统访问的唯一入口,按序拒绝:
|
|
36
|
+
|
|
37
|
+
1. 输入分级(`classifyPathInput`,纯函数可测):拒绝绝对路径、Windows 盘符/UNC 路径、POSIX 上的反斜杠路径、空输入、NUL 字节。
|
|
38
|
+
2. 词法收容:`path.resolve` 后离开根 → `path-traversal`。
|
|
39
|
+
3. 符号链接逃逸:末位组件是指向根外的符号链接(或断链)→ `symlink-escape`。
|
|
40
|
+
4. 真实路径逃逸:任一中间符号链接链的规范化结果离开根 → `realpath-escape`。
|
|
41
|
+
|
|
42
|
+
比较基于 `realpath` 之后的规范根,避免 macOS `/var → /private/var` 一类系统级符号链接造成误判。
|
|
43
|
+
|
|
44
|
+
## 测试
|
|
45
|
+
|
|
46
|
+
`node --test` 覆盖:Contracts fixture 全量回放、安全反例(三类逃逸均被拦截且零越界写)、原子性失败路径无残留、临时工作区异常清理、闭包确定性、Windows 路径/整数/正则/`format` 边界。
|
|
47
|
+
|
|
48
|
+
## 安装
|
|
49
|
+
|
|
50
|
+
```sh
|
|
51
|
+
npm install skill-family-harness-node
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## 最小示例
|
|
55
|
+
|
|
56
|
+
```js
|
|
57
|
+
// release-skill: harness runtime validation
|
|
58
|
+
import { validateContractDocument } from "skill-family-harness-node";
|
|
59
|
+
const result = validateContractDocument(doc, { schemaId: "project-manifest" });
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## 故障诊断
|
|
63
|
+
|
|
64
|
+
机制失败统一抛出 `SFC2004`(EXECUTION_FAILED),`details.kind` 给出稳定细分(如 `path-traversal`、`atomic-write-failed`)。如失败,检查 root 路径是否正确且目标文件未被锁定。
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# 安全策略(Security Policy)
|
|
2
|
+
|
|
3
|
+
## 支持的版本
|
|
4
|
+
|
|
5
|
+
| 版本 | 安全支持状态 |
|
|
6
|
+
| --- | --- |
|
|
7
|
+
| 0.1.x | 当前维护线:接受安全报告 |
|
|
8
|
+
| 0.0.0 | 未发布的内部骨架版本,不在公开支持范围 |
|
|
9
|
+
|
|
10
|
+
安全修复只承诺在最新的 0.1.x 线上提供;更早版本不回移修复。
|
|
11
|
+
|
|
12
|
+
## 报告漏洞
|
|
13
|
+
|
|
14
|
+
请勿通过公开 issue 直接披露未修复的安全漏洞。private workspace 仓永久
|
|
15
|
+
private,不是公开报告渠道;请通过任一 public 发布镜像仓(例如
|
|
16
|
+
`https://github.com/ifoohoo/skill-family-engineering-kit`)在 GitHub 上使用
|
|
17
|
+
**Private vulnerability reporting**(仓库 Security 页签的
|
|
18
|
+
"Report a vulnerability")私下报告;如该通道不可用,再通过仓库维护者
|
|
19
|
+
提供的私下联系方式报告。
|
|
20
|
+
|
|
21
|
+
报告时请尽量提供:
|
|
22
|
+
|
|
23
|
+
- 受影响的包与版本(`skill-family-contracts`、`skill-family-harness-node`、
|
|
24
|
+
`skill-family-engineering-kit`);
|
|
25
|
+
- 可复现的最小步骤或概念验证;
|
|
26
|
+
- 影响范围与利用前提。
|
|
27
|
+
|
|
28
|
+
## 处置承诺
|
|
29
|
+
|
|
30
|
+
- 收到报告后先确认受理,再按影响面排期修复;
|
|
31
|
+
- 修复发布前不公开披露细节;
|
|
32
|
+
- 修复随下一个补丁版本发布,并在该版本的变更记录中说明。
|
|
33
|
+
|
|
34
|
+
本文件只描述漏洞报告渠道与支持版本;实时发布状态不属于本文件范围。
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "skill-family-harness-node",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "Thin Node.js mechanism runtime for Skill Family engineering contracts.",
|
|
6
|
+
"author": "广州市风荷科技有限公司",
|
|
7
|
+
"license": "Apache-2.0",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/ifoohoo/skill-family-harness-node.git"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/ifoohoo/skill-family-harness-node",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/ifoohoo/skill-family-harness-node/issues"
|
|
15
|
+
},
|
|
16
|
+
"type": "module",
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=22.22.2 <23"
|
|
19
|
+
},
|
|
20
|
+
"exports": "./src/index.mjs",
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"skill-family-contracts": "0.1.0"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"src",
|
|
26
|
+
"SECURITY.md",
|
|
27
|
+
"CONTRIBUTING.md",
|
|
28
|
+
"CODE_OF_CONDUCT.md"
|
|
29
|
+
],
|
|
30
|
+
"//": "~~ Generated by projen. To modify, edit .projenrc.js and run \"npx projen\".",
|
|
31
|
+
"scripts": {
|
|
32
|
+
"check": "node --test",
|
|
33
|
+
"test": "node --test"
|
|
34
|
+
}
|
|
35
|
+
}
|
package/src/atomic.mjs
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { lstat, mkdir, open, realpath, rename, rm } from "node:fs/promises";
|
|
2
|
+
import { randomBytes } from "node:crypto";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import process from "node:process";
|
|
5
|
+
import { HARNESS_ERROR_KINDS, mechanismError } from "./errors.mjs";
|
|
6
|
+
import { resolveContained } from "./paths.mjs";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Atomic contained writes.
|
|
10
|
+
*
|
|
11
|
+
* Guarantees:
|
|
12
|
+
* - The target path is containment-checked first (path traversal, symlink
|
|
13
|
+
* escape, realpath escape all reject before any write happens).
|
|
14
|
+
* - Content is written to a fresh temporary file in the target's own
|
|
15
|
+
* directory (same filesystem), fsynced, then renamed over the target.
|
|
16
|
+
* rename is atomic on POSIX, so readers observe either the complete old
|
|
17
|
+
* content or the complete new content, never a partial file.
|
|
18
|
+
* - On any failure the temporary file is removed and the target keeps its
|
|
19
|
+
* previous content (or stays absent). A failed write never leaves a
|
|
20
|
+
* half-written target behind.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
function assertWritableData(data) {
|
|
24
|
+
const ok =
|
|
25
|
+
typeof data === "string" ||
|
|
26
|
+
Buffer.isBuffer(data) ||
|
|
27
|
+
ArrayBuffer.isView(data) ||
|
|
28
|
+
data instanceof ArrayBuffer;
|
|
29
|
+
if (!ok) {
|
|
30
|
+
throw new TypeError(
|
|
31
|
+
"writeFileAtomic: data must be a string, Buffer, TypedArray, DataView, or ArrayBuffer",
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async function removeQuiet(candidate) {
|
|
37
|
+
try {
|
|
38
|
+
await rm(candidate, { force: true });
|
|
39
|
+
} catch {
|
|
40
|
+
// Cleanup is best-effort; the original failure is the one that counts.
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Atomically writes `data` to `relPath` inside `root`.
|
|
46
|
+
* Options: { mode } (file mode for a newly created target, default 0o644).
|
|
47
|
+
* Returns the absolute contained target path that was written.
|
|
48
|
+
* Throws HarnessError (SFC2004) with a stable details.kind on failure.
|
|
49
|
+
*/
|
|
50
|
+
export async function writeFileAtomic(root, relPath, data, { mode = 0o644 } = {}) {
|
|
51
|
+
assertWritableData(data);
|
|
52
|
+
let target = await resolveContained(root, relPath);
|
|
53
|
+
// When the final component is a symlink to a contained target, write to the
|
|
54
|
+
// real target: rename would otherwise replace the link itself instead of
|
|
55
|
+
// updating the resource it points at. resolveContained already proved the
|
|
56
|
+
// real target stays inside the root.
|
|
57
|
+
try {
|
|
58
|
+
const finalStat = await lstat(target);
|
|
59
|
+
if (finalStat.isSymbolicLink()) {
|
|
60
|
+
target = await realpath(target);
|
|
61
|
+
}
|
|
62
|
+
} catch {
|
|
63
|
+
// Not yet existing: the lexical target is the write destination.
|
|
64
|
+
}
|
|
65
|
+
const dir = path.dirname(target);
|
|
66
|
+
try {
|
|
67
|
+
await mkdir(dir, { recursive: true });
|
|
68
|
+
} catch (cause) {
|
|
69
|
+
throw mechanismError(
|
|
70
|
+
HARNESS_ERROR_KINDS.ATOMIC_WRITE_FAILED,
|
|
71
|
+
`cannot prepare contained directory: ${cause && cause.code ? cause.code : "unknown"}`,
|
|
72
|
+
{ input: relPath },
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
const tmpName = `.${path.basename(target)}.${process.pid}.${randomBytes(8).toString("hex")}.tmp`;
|
|
76
|
+
const tmpPath = path.join(dir, tmpName);
|
|
77
|
+
let handle = null;
|
|
78
|
+
try {
|
|
79
|
+
// wx => O_CREAT|O_EXCL: the temporary name is fresh and never clobbers.
|
|
80
|
+
handle = await open(tmpPath, "wx", mode);
|
|
81
|
+
await handle.writeFile(data);
|
|
82
|
+
await handle.sync();
|
|
83
|
+
await handle.close();
|
|
84
|
+
handle = null;
|
|
85
|
+
await rename(tmpPath, target);
|
|
86
|
+
} catch (cause) {
|
|
87
|
+
if (handle) {
|
|
88
|
+
try {
|
|
89
|
+
await handle.close();
|
|
90
|
+
} catch {
|
|
91
|
+
// Closing on the error path is best-effort.
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
await removeQuiet(tmpPath);
|
|
95
|
+
throw mechanismError(
|
|
96
|
+
HARNESS_ERROR_KINDS.ATOMIC_WRITE_FAILED,
|
|
97
|
+
`atomic write failed: ${cause && cause.code ? cause.code : "unknown"}`,
|
|
98
|
+
{ input: relPath },
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
// Best-effort directory fsync so the rename itself is durable; platforms
|
|
102
|
+
// without directory fsync simply skip it.
|
|
103
|
+
try {
|
|
104
|
+
const dirHandle = await open(dir, "r");
|
|
105
|
+
try {
|
|
106
|
+
await dirHandle.sync();
|
|
107
|
+
} finally {
|
|
108
|
+
await dirHandle.close();
|
|
109
|
+
}
|
|
110
|
+
} catch {
|
|
111
|
+
// Durability hardening only; the atomicity guarantee already holds.
|
|
112
|
+
}
|
|
113
|
+
return target;
|
|
114
|
+
}
|