@chopin-ai/core 0.0.0-stage → 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/LICENSE +202 -0
- package/dist/cli.d.ts +16 -0
- package/dist/cli.js +43 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/layer/gates.d.ts +20 -0
- package/dist/layer/gates.js +37 -0
- package/dist/layer/gates.js.map +1 -0
- package/dist/layer/layer.d.ts +28 -0
- package/dist/layer/layer.js +37 -0
- package/dist/layer/layer.js.map +1 -0
- package/dist/layer/mcp.d.ts +19 -0
- package/dist/layer/mcp.js +93 -0
- package/dist/layer/mcp.js.map +1 -0
- package/dist/layer/skills.d.ts +10 -0
- package/dist/layer/skills.js +60 -0
- package/dist/layer/skills.js.map +1 -0
- package/dist/meta.d.ts +18 -0
- package/dist/meta.js +10 -0
- package/dist/meta.js.map +1 -0
- package/dist/transcript.d.ts +21 -0
- package/dist/transcript.js +13 -0
- package/dist/transcript.js.map +1 -0
- package/package.json +26 -3
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
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/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface CliIo {
|
|
2
|
+
out(text: string): void;
|
|
3
|
+
err(text: string): void;
|
|
4
|
+
}
|
|
5
|
+
/** A `chopin` subcommand; `name` may span several words, such as `layer check`. */
|
|
6
|
+
export interface Command {
|
|
7
|
+
name: string;
|
|
8
|
+
/** Its arguments, as shown in the usage. */
|
|
9
|
+
args: string;
|
|
10
|
+
summary: string;
|
|
11
|
+
/** @returns The process exit code. */
|
|
12
|
+
run(args: readonly string[], io: CliIo): Promise<number>;
|
|
13
|
+
}
|
|
14
|
+
export declare const coreCommands: readonly Command[];
|
|
15
|
+
/** @returns The process exit code. */
|
|
16
|
+
export declare function runCli(argv: readonly string[], io: CliIo, commands?: readonly Command[]): Promise<number>;
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import { loadLayer } from "./layer/layer.js";
|
|
3
|
+
export const coreCommands = [{
|
|
4
|
+
name: "layer check",
|
|
5
|
+
args: "<dir>",
|
|
6
|
+
summary: "validate a mutable layer directory",
|
|
7
|
+
run: async (args, io) => {
|
|
8
|
+
if (args.length !== 1)
|
|
9
|
+
return usageError(io, "layer check <dir>");
|
|
10
|
+
return layerCheck(resolve(args[0] ?? ""), io);
|
|
11
|
+
},
|
|
12
|
+
}];
|
|
13
|
+
/** @returns The process exit code. */
|
|
14
|
+
export async function runCli(argv, io, commands = coreCommands) {
|
|
15
|
+
const command = commands.find((c) => c.name.split(" ").every((word, i) => argv[i] === word));
|
|
16
|
+
if (command !== undefined)
|
|
17
|
+
return command.run(argv.slice(command.name.split(" ").length), io);
|
|
18
|
+
const asked = argv.length === 0 || ["help", "--help", "-h"].includes(argv[0] ?? "");
|
|
19
|
+
const usage = ["usage: chopin <command>", "", "commands:", ...commands.flatMap((c) => [` ${c.name} ${c.args}`.trimEnd(), ` ${c.summary}`])];
|
|
20
|
+
(asked ? io.out : io.err)(usage.join("\n"));
|
|
21
|
+
return asked ? 0 : 2;
|
|
22
|
+
}
|
|
23
|
+
function usageError(io, usage) {
|
|
24
|
+
io.err(`usage: chopin ${usage}`);
|
|
25
|
+
return 2;
|
|
26
|
+
}
|
|
27
|
+
async function layerCheck(directory, io) {
|
|
28
|
+
const result = await loadLayer(directory);
|
|
29
|
+
if (!result.ok) {
|
|
30
|
+
for (const problem of result.problems)
|
|
31
|
+
io.err(problem);
|
|
32
|
+
return 1;
|
|
33
|
+
}
|
|
34
|
+
const { instructions, skills, mcpServers, gates } = result.layer;
|
|
35
|
+
io.out([
|
|
36
|
+
`instructions: ${instructions === undefined ? "none" : "AGENTS.md"}`,
|
|
37
|
+
`skills: ${skills.map((s) => s.name).join(", ") || "none"}`,
|
|
38
|
+
`mcp servers: ${Object.keys(mcpServers).join(", ") || "none"}`,
|
|
39
|
+
`gate rules: ${gates.length}`,
|
|
40
|
+
].join("\n"));
|
|
41
|
+
return 0;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAiB7C,MAAM,CAAC,MAAM,YAAY,GAAuB,CAAC;QAC/C,IAAI,EAAE,aAAa;QACnB,IAAI,EAAE,OAAO;QACb,OAAO,EAAE,oCAAoC;QAC7C,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE;YACtB,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;gBAAE,OAAO,UAAU,CAAC,EAAE,EAAE,mBAAmB,CAAC,CAAC;YAClE,OAAO,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QAChD,CAAC;KACF,CAAC,CAAC;AAEH,sCAAsC;AACtC,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,IAAuB,EAAE,EAAS,EAAE,QAAQ,GAAuB,YAAY;IAC1G,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI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B,EAAE,EAAS;IACpD,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,SAAS,CAAC,CAAC;IAC1C,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;QACf,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,QAAQ;YAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACvD,OAAO,CAAC,CAAC;IACX,CAAC;IACD,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC;IACjE,EAAE,CAAC,GAAG,CAAC;QACL,iBAAiB,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,EAAE;QACpE,WAAW,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,MAAM,EAAE;QAC3D,gBAAgB,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,MAAM,EAAE;QAC9D,eAAe,KAAK,CAAC,MAAM,EAAE;KAC9B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACd,OAAO,CAAC,CAAC;AACX,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { coreCommands, runCli } from "./cli.js";
|
|
2
|
+
export type { CliIo, Command } from "./cli.js";
|
|
3
|
+
export { checkGates, gateRefusal, unmetGates } from "./layer/gates.js";
|
|
4
|
+
export type { GateRule } from "./layer/gates.js";
|
|
5
|
+
export { loadLayer } from "./layer/layer.js";
|
|
6
|
+
export type { Layer, LayerResult } from "./layer/layer.js";
|
|
7
|
+
export { isMcpToolOf, mcpToolName } from "./layer/mcp.js";
|
|
8
|
+
export type { McpServer } from "./layer/mcp.js";
|
|
9
|
+
export { skillBody } from "./layer/skills.js";
|
|
10
|
+
export type { Skill } from "./layer/skills.js";
|
|
11
|
+
export { chopinMeta, META_KEY, withChopinMeta } from "./meta.js";
|
|
12
|
+
export type { ChopinMeta } from "./meta.js";
|
|
13
|
+
export { appendTranscript, parseTranscript, readTranscript } from "./transcript.js";
|
|
14
|
+
export type { TaskRun, TranscriptEntry } from "./transcript.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { coreCommands, runCli } from "./cli.js";
|
|
2
|
+
export { checkGates, gateRefusal, unmetGates } from "./layer/gates.js";
|
|
3
|
+
export { loadLayer } from "./layer/layer.js";
|
|
4
|
+
export { isMcpToolOf, mcpToolName } from "./layer/mcp.js";
|
|
5
|
+
export { skillBody } from "./layer/skills.js";
|
|
6
|
+
export { chopinMeta, META_KEY, withChopinMeta } from "./meta.js";
|
|
7
|
+
export { appendTranscript, parseTranscript, readTranscript } from "./transcript.js";
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEhD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEvE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE1D,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEjE,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A call to `tool` is refused until every tool in `requires` has completed successfully earlier in the same
|
|
3
|
+
* session. What counts is the tool-call record, never the model's account of what it did.
|
|
4
|
+
*/
|
|
5
|
+
export interface GateRule {
|
|
6
|
+
tool: string;
|
|
7
|
+
requires: string[];
|
|
8
|
+
/** Shown to the model when the call is refused. */
|
|
9
|
+
reason: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function parseGates(value: unknown, source: string, problems: string[]): GateRule[];
|
|
12
|
+
/** The rules that refuse a call to `tool`, given the tools that have succeeded so far. */
|
|
13
|
+
export declare function unmetGates(rules: readonly GateRule[], tool: string, succeeded: ReadonlySet<string>): GateRule[];
|
|
14
|
+
/** Why a call is refused: any required tool that is not registered, then each unmet rule's reason. */
|
|
15
|
+
export declare function gateRefusal(unmet: readonly GateRule[], registered: ReadonlySet<string>): string;
|
|
16
|
+
/**
|
|
17
|
+
* Configuration errors against the tools actually registered. A gate on a tool nobody can satisfy would refuse
|
|
18
|
+
* forever, so it is an error rather than an ordinary refusal.
|
|
19
|
+
*/
|
|
20
|
+
export declare function checkGates(rules: readonly GateRule[], registered: ReadonlySet<string>): string[];
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export function parseGates(value, source, problems) {
|
|
2
|
+
if (value === undefined || value === null)
|
|
3
|
+
return [];
|
|
4
|
+
if (!Array.isArray(value)) {
|
|
5
|
+
problems.push(`${source}: expected a list of gate rules`);
|
|
6
|
+
return [];
|
|
7
|
+
}
|
|
8
|
+
return value.flatMap((rule, index) => {
|
|
9
|
+
const { tool, requires, reason } = (typeof rule === "object" && rule !== null ? rule : {});
|
|
10
|
+
const valid = typeof tool === "string" && tool !== "" && typeof reason === "string" && reason !== ""
|
|
11
|
+
&& Array.isArray(requires) && requires.length > 0 && requires.every((r) => typeof r === "string" && r !== "");
|
|
12
|
+
if (!valid) {
|
|
13
|
+
problems.push(`${source}[${index}]: a gate rule needs a tool, a non-empty requires list and a reason`);
|
|
14
|
+
return [];
|
|
15
|
+
}
|
|
16
|
+
return [{ tool, requires: requires, reason }];
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
/** The rules that refuse a call to `tool`, given the tools that have succeeded so far. */
|
|
20
|
+
export function unmetGates(rules, tool, succeeded) {
|
|
21
|
+
return rules.filter((rule) => rule.tool === tool && rule.requires.some((required) => !succeeded.has(required)));
|
|
22
|
+
}
|
|
23
|
+
/** Why a call is refused: any required tool that is not registered, then each unmet rule's reason. */
|
|
24
|
+
export function gateRefusal(unmet, registered) {
|
|
25
|
+
return [...checkGates(unmet, registered), ...unmet.map((rule) => rule.reason)].join("\n");
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Configuration errors against the tools actually registered. A gate on a tool nobody can satisfy would refuse
|
|
29
|
+
* forever, so it is an error rather than an ordinary refusal.
|
|
30
|
+
*/
|
|
31
|
+
export function checkGates(rules, registered) {
|
|
32
|
+
return rules.flatMap((rule) => [
|
|
33
|
+
...(registered.has(rule.tool) ? [] : [`gate on ${rule.tool}: no such tool`]),
|
|
34
|
+
...rule.requires.filter((r) => !registered.has(r)).map((r) => `gate on ${rule.tool}: requires ${r}, which no tool provides`),
|
|
35
|
+
]);
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=gates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gates.js","sourceRoot":"","sources":["../../src/layer/gates.ts"],"names":[],"mappings":"AAWA,MAAM,UAAU,UAAU,CAAC,KAAc,EAAE,MAAc,EAAE,QAAkB;IAC3E,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,EAAE,CAAC;IACrD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,QAAQ,CAAC,IAAI,CAAC,GAAG,MAAM,iCAAiC,CAAC,CAAC;QAC1D,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,IAAa,EAAE,KAAK,EAAE,EAAE;QAC5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,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC5F,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,KAA0B,EAAE,UAA+B;IACpF,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;QAC7B,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,WAAW,IAAI,CAAC,IAAI,gBAAgB,CAAC,CAAC;QAC5E,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,IAAI,CAAC,IAAI,cAAc,CAAC,0BAA0B,CAAC;KAC7H,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type GateRule } from "./gates.js";
|
|
2
|
+
import { type McpServer } from "./mcp.js";
|
|
3
|
+
import { type Skill } from "./skills.js";
|
|
4
|
+
/**
|
|
5
|
+
* The portable tier of the mutable layer: everything in it is an open format that both harnesses load the
|
|
6
|
+
* same way. A layer is a directory:
|
|
7
|
+
*
|
|
8
|
+
* AGENTS.md instructions
|
|
9
|
+
* skills/<name>/ Agent Skills
|
|
10
|
+
* mcp.json MCP servers
|
|
11
|
+
* gates.yaml gate rules
|
|
12
|
+
*
|
|
13
|
+
* Every file is optional; an empty directory is an empty layer.
|
|
14
|
+
*/
|
|
15
|
+
export interface Layer {
|
|
16
|
+
instructions: string | undefined;
|
|
17
|
+
skills: Skill[];
|
|
18
|
+
mcpServers: Record<string, McpServer>;
|
|
19
|
+
gates: GateRule[];
|
|
20
|
+
}
|
|
21
|
+
export type LayerResult = {
|
|
22
|
+
ok: true;
|
|
23
|
+
layer: Layer;
|
|
24
|
+
} | {
|
|
25
|
+
ok: false;
|
|
26
|
+
problems: string[];
|
|
27
|
+
};
|
|
28
|
+
export declare function loadLayer(directory: string): Promise<LayerResult>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { parse } from "yaml";
|
|
4
|
+
import { parseGates } from "./gates.js";
|
|
5
|
+
import { parseMcpServers } from "./mcp.js";
|
|
6
|
+
import { loadSkills } from "./skills.js";
|
|
7
|
+
export async function loadLayer(directory) {
|
|
8
|
+
const problems = [];
|
|
9
|
+
const instructions = await optional(join(directory, "AGENTS.md"));
|
|
10
|
+
const skills = await loadSkills(join(directory, "skills"), problems);
|
|
11
|
+
const mcpServers = parseMcpServers(await structured(join(directory, "mcp.json"), JSON.parse, problems), "mcp.json", problems);
|
|
12
|
+
const gates = parseGates(await structured(join(directory, "gates.yaml"), parse, problems), "gates.yaml", problems);
|
|
13
|
+
return problems.length === 0 ? { ok: true, layer: { instructions, skills, mcpServers, gates } } : { ok: false, problems };
|
|
14
|
+
}
|
|
15
|
+
async function optional(path) {
|
|
16
|
+
try {
|
|
17
|
+
return await readFile(path, "utf8");
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
if (error.code === "ENOENT")
|
|
21
|
+
return undefined;
|
|
22
|
+
throw error;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
async function structured(path, decode, problems) {
|
|
26
|
+
const text = await optional(path);
|
|
27
|
+
if (text === undefined)
|
|
28
|
+
return undefined;
|
|
29
|
+
try {
|
|
30
|
+
return decode(text);
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
problems.push(`${path}: ${error.message}`);
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=layer.js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QAAQ,EAAE,CAAC;AAC5H,CAAC;AAED,KAAK,UAAU,QAAQ,CAAC,IAAY;IAClC,IAAI,CAAC;QACH,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACtC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ;YAAE,OAAO,SAAS,CAAC;QACzE,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED,KAAK,UAAU,UAAU,CAAC,IAAY,EAAE,MAAiC,EAAE,QAAkB;IAC3F,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAC;IAClC,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACzC,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC;IACtB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI,KAAM,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;QACtD,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** An MCP server entry, in the `mcpServers` shape most agents already read; both harnesses speak these two transports. */
|
|
2
|
+
export type McpServer = {
|
|
3
|
+
command: string;
|
|
4
|
+
args?: string[];
|
|
5
|
+
env?: Record<string, string>;
|
|
6
|
+
} | {
|
|
7
|
+
type: "http";
|
|
8
|
+
url: string;
|
|
9
|
+
headers?: Record<string, string>;
|
|
10
|
+
};
|
|
11
|
+
export declare function parseMcpServers(value: unknown, source: string, problems: string[]): Record<string, McpServer>;
|
|
12
|
+
/**
|
|
13
|
+
* The model-facing name of an MCP tool, `mcp__<server>__<tool>`, as both harnesses spell it: provider function names
|
|
14
|
+
* allow only `[A-Za-z0-9_-]` and 64 characters, and a name that had to change gains a hash of its identity so two
|
|
15
|
+
* tools never collapse into one. Gate rules name MCP tools this way.
|
|
16
|
+
*/
|
|
17
|
+
export declare function mcpToolName(server: string, tool: string): string;
|
|
18
|
+
/** Whether `tool` names a tool of `server`, a server name the layer accepts. */
|
|
19
|
+
export declare function isMcpToolOf(server: string, tool: string): boolean;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { isVariableName } from "@chopin-ai/workspace";
|
|
3
|
+
export function parseMcpServers(value, source, problems) {
|
|
4
|
+
if (value === undefined)
|
|
5
|
+
return {};
|
|
6
|
+
const servers = value?.mcpServers;
|
|
7
|
+
if (typeof servers !== "object" || servers === null || Array.isArray(servers)) {
|
|
8
|
+
problems.push(`${source}: expected an object with mcpServers`);
|
|
9
|
+
return {};
|
|
10
|
+
}
|
|
11
|
+
const parsed = {};
|
|
12
|
+
for (const [name, server] of Object.entries(servers)) {
|
|
13
|
+
const problem = serverProblem(name, server);
|
|
14
|
+
if (problem === undefined)
|
|
15
|
+
parsed[name] = server;
|
|
16
|
+
else
|
|
17
|
+
problems.push(`${source}: server ${name} ${problem}`);
|
|
18
|
+
}
|
|
19
|
+
return parsed;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Server names every harness accepts. Without `__` or a trailing `_`, `mcp__<server>__` also names exactly one
|
|
23
|
+
* server in any tool name.
|
|
24
|
+
*/
|
|
25
|
+
const SERVER_NAME = /^(?!.*__)[A-Za-z0-9_-]{0,31}[A-Za-z0-9-]$/;
|
|
26
|
+
/** An HTTP field name: a token. */
|
|
27
|
+
const HEADER_NAME = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
|
|
28
|
+
function serverProblem(name, server) {
|
|
29
|
+
if (!SERVER_NAME.test(name))
|
|
30
|
+
return 'needs a name of 1 to 32 letters, digits, "_" or "-", without "__" or a trailing "_"';
|
|
31
|
+
const entry = (typeof server === "object" && server !== null ? server : {});
|
|
32
|
+
if (entry.type === "sse")
|
|
33
|
+
return "uses SSE, which not every harness speaks; use type http (Streamable HTTP)";
|
|
34
|
+
if (typeof entry.command === "string") {
|
|
35
|
+
if (entry.command === "")
|
|
36
|
+
return "needs a command";
|
|
37
|
+
if (entry.args !== undefined && !strings(entry.args))
|
|
38
|
+
return "needs args as a list of strings";
|
|
39
|
+
if (entry.env !== undefined && !textRecord(entry.env))
|
|
40
|
+
return "needs env as an object of string values";
|
|
41
|
+
const env = (entry.env ?? {});
|
|
42
|
+
const name = Object.keys(env).find((key) => !isVariableName(key));
|
|
43
|
+
if (name !== undefined) {
|
|
44
|
+
return `needs env names of letters, digits and "_", not starting with a digit, other than "_" and those starting with CHOPIN_ENV_, which ${JSON.stringify(name)} is not`;
|
|
45
|
+
}
|
|
46
|
+
if ([entry.command, ...(entry.args ?? []), ...Object.values(env)].some(hasNul))
|
|
47
|
+
return "holds a NUL character, which no program can be given";
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
if (entry.type === "http" && typeof entry.url === "string") {
|
|
51
|
+
if (!/^https?:$/.test(URL.parse(entry.url)?.protocol ?? ""))
|
|
52
|
+
return `needs an http or https url, not ${entry.url}`;
|
|
53
|
+
if (entry.headers !== undefined && !textRecord(entry.headers))
|
|
54
|
+
return "needs headers as an object of string values";
|
|
55
|
+
const header = Object.keys((entry.headers ?? {})).find((key) => !HEADER_NAME.test(key));
|
|
56
|
+
if (header !== undefined)
|
|
57
|
+
return `needs header names an HTTP request can carry, which ${JSON.stringify(header)} is not`;
|
|
58
|
+
const value = Object.entries((entry.headers ?? {})).find(([, text]) => /[^\t\x20-\x7e]/.test(text));
|
|
59
|
+
if (value !== undefined)
|
|
60
|
+
return `needs header values an HTTP request can carry, which that of ${JSON.stringify(value[0])} is not`;
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
return "needs a command, or type http with a url";
|
|
64
|
+
}
|
|
65
|
+
function strings(value) {
|
|
66
|
+
return Array.isArray(value) && value.every((item) => typeof item === "string");
|
|
67
|
+
}
|
|
68
|
+
function textRecord(value) {
|
|
69
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && Object.values(value).every((item) => typeof item === "string");
|
|
70
|
+
}
|
|
71
|
+
function hasNul(text) {
|
|
72
|
+
return text.includes("\0");
|
|
73
|
+
}
|
|
74
|
+
const NAME_LIMIT = 64;
|
|
75
|
+
const INVALID = /[^A-Za-z0-9_-]/g;
|
|
76
|
+
/**
|
|
77
|
+
* The model-facing name of an MCP tool, `mcp__<server>__<tool>`, as both harnesses spell it: provider function names
|
|
78
|
+
* allow only `[A-Za-z0-9_-]` and 64 characters, and a name that had to change gains a hash of its identity so two
|
|
79
|
+
* tools never collapse into one. Gate rules name MCP tools this way.
|
|
80
|
+
*/
|
|
81
|
+
export function mcpToolName(server, tool) {
|
|
82
|
+
const joined = `mcp__${server}__${tool}`;
|
|
83
|
+
const normalized = joined.replace(INVALID, "_");
|
|
84
|
+
if (normalized === joined && normalized.length <= NAME_LIMIT)
|
|
85
|
+
return normalized;
|
|
86
|
+
const hash = createHash("sha256").update(`${server}\0${tool}`).digest("hex").slice(0, 12);
|
|
87
|
+
return `${normalized.slice(0, NAME_LIMIT - 12 - 1)}_${hash}`;
|
|
88
|
+
}
|
|
89
|
+
/** Whether `tool` names a tool of `server`, a server name the layer accepts. */
|
|
90
|
+
export function isMcpToolOf(server, tool) {
|
|
91
|
+
return tool.startsWith(`mcp__${server}__`);
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=mcp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.js","sourceRoot":"","sources":["../../src/layer/mcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAOtD,MAAM,UAAU,eAAe,CAAC,KAAc,EAAE,MAAc,EAAE,QAAkB;IAChF,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,EAAE,CAAC;IACnC,MAAM,OAAO,GAAI,K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7B,CAAC;AACD,MAAM,UAAU,GAAG,EAAE,CAAC;AACtB,MAAM,OAAO,GAAG,iBAAiB,CAAC;AAElC;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,MAAc,EAAE,IAAY;IACtD,MAAM,MAAM,GAAG,QAAQ,MAAM,KAAK,IAAI,EAAE,CAAC;IACzC,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IAChD,IAAI,UAAU,KAAK,MAAM,IAAI,UAAU,CAAC,MAAM,IAAI,UAAU;QAAE,OAAO,UAAU,CAAC;IAChF,MAAM,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,GAAG,MAAM,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC1F,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,GAAG,EAAE,GAAG,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC;AAC/D,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,WAAW,CAAC,MAAc,EAAE,IAAY;IACtD,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,MAAM,IAAI,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** A skill in the Agent Skills format. Agents get the index; they read the body themselves when it applies. */
|
|
2
|
+
export interface Skill {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
/** The skill's directory, holding `SKILL.md` and whatever it bundles. */
|
|
6
|
+
directory: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function loadSkills(root: string, problems: string[]): Promise<Skill[]>;
|
|
9
|
+
/** A skill's instructions as the model reads them, the same on every harness: its SKILL.md without the frontmatter. */
|
|
10
|
+
export declare function skillBody(text: string): string;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { readdir, readFile } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { parse } from "yaml";
|
|
4
|
+
const NAME = /^[a-z0-9]+(-[a-z0-9]+)*$/;
|
|
5
|
+
export async function loadSkills(root, problems) {
|
|
6
|
+
const entries = await readdir(root, { withFileTypes: true }).catch(missing);
|
|
7
|
+
const skills = [];
|
|
8
|
+
for (const entry of entries.filter((e) => e.isDirectory()).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
9
|
+
const directory = join(root, entry.name);
|
|
10
|
+
const file = join(directory, "SKILL.md");
|
|
11
|
+
const text = await readFile(file, "utf8").catch((error) => {
|
|
12
|
+
problems.push(error.code === "ENOENT" ? `${file}: missing` : `${file}: ${error.message}`);
|
|
13
|
+
return undefined;
|
|
14
|
+
});
|
|
15
|
+
if (text === undefined)
|
|
16
|
+
continue;
|
|
17
|
+
const skill = parseSkill(text, entry.name, file, problems);
|
|
18
|
+
if (skill !== undefined)
|
|
19
|
+
skills.push({ ...skill, directory });
|
|
20
|
+
}
|
|
21
|
+
return skills;
|
|
22
|
+
}
|
|
23
|
+
function parseSkill(text, directoryName, file, problems) {
|
|
24
|
+
const match = FRONTMATTER.exec(text);
|
|
25
|
+
if (match === null) {
|
|
26
|
+
problems.push(`${file}: no YAML frontmatter`);
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
let front;
|
|
30
|
+
try {
|
|
31
|
+
front = parse(match[1] ?? "");
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
problems.push(`${file}: frontmatter is not valid YAML: ${error.message}`);
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
const { name, description } = (typeof front === "object" && front !== null ? front : {});
|
|
38
|
+
const before = problems.length;
|
|
39
|
+
if (typeof name !== "string" || name.length > 64 || !NAME.test(name)) {
|
|
40
|
+
problems.push(`${file}: name must be 1-64 lowercase letters, digits and single hyphens`);
|
|
41
|
+
}
|
|
42
|
+
else if (name !== directoryName) {
|
|
43
|
+
problems.push(`${file}: name "${name}" must match its directory "${directoryName}"`);
|
|
44
|
+
}
|
|
45
|
+
if (typeof description !== "string" || description.trim() === "" || description.length > 1024) {
|
|
46
|
+
problems.push(`${file}: description must be 1-1024 characters`);
|
|
47
|
+
}
|
|
48
|
+
return problems.length === before ? { name: name, description: description } : undefined;
|
|
49
|
+
}
|
|
50
|
+
function missing(error) {
|
|
51
|
+
if (error.code === "ENOENT")
|
|
52
|
+
return [];
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
const FRONTMATTER = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/;
|
|
56
|
+
/** A skill's instructions as the model reads them, the same on every harness: its SKILL.md without the frontmatter. */
|
|
57
|
+
export function skillBody(text) {
|
|
58
|
+
return text.replace(FRONTMATTER, "");
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=skills.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skills.js","sourceRoot":"","sources":["../../src/layer/skills.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAU7B,MAAM,IAAI,GAAG,0BAA0B,CAAC;AAExC,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,IAAY,EAAE,QAAkB;IAC/D,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,IAAI,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC5E,MAAM,MAAM,GAAY,EAAE,CAAC;IAC3B,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,IAAI,CAAC,CAA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AAO,EAAE,CAAC;IACvC,MAAM,KAAK,CAAC;AACd,CAAC;AAED,MAAM,WAAW,GAAG,wCAAwC,CAAC;AAE7D,uHAAuH;AACvH,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;AACvC,CAAC"}
|
package/dist/meta.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Namespaced key under ACP's `_meta` for the facts evaluation needs and ACP does not carry. */
|
|
2
|
+
export declare const META_KEY = "chopin-ai";
|
|
3
|
+
export interface ChopinMeta {
|
|
4
|
+
/** The model that produced a turn, so results can be compared per model. */
|
|
5
|
+
model?: {
|
|
6
|
+
provider: string;
|
|
7
|
+
id: string;
|
|
8
|
+
};
|
|
9
|
+
/** What the turn cost, in ACP's own cost shape. */
|
|
10
|
+
cost?: {
|
|
11
|
+
amount: number;
|
|
12
|
+
currency: string;
|
|
13
|
+
};
|
|
14
|
+
/** Why the turn ended without an answer. */
|
|
15
|
+
error?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function withChopinMeta<T extends object>(value: T, meta: ChopinMeta): T;
|
|
18
|
+
export declare function chopinMeta(value: object): ChopinMeta | undefined;
|
package/dist/meta.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Namespaced key under ACP's `_meta` for the facts evaluation needs and ACP does not carry. */
|
|
2
|
+
export const META_KEY = "chopin-ai";
|
|
3
|
+
export function withChopinMeta(value, meta) {
|
|
4
|
+
const existing = value._meta;
|
|
5
|
+
return { ...value, _meta: { ...existing, [META_KEY]: meta } };
|
|
6
|
+
}
|
|
7
|
+
export function chopinMeta(value) {
|
|
8
|
+
return value._meta?.[META_KEY];
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=meta.js.map
|
package/dist/meta.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meta.js","sourceRoot":"","sources":["../src/meta.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,MAAM,CAAC,MAAM,QAAQ,GAAG,WAAW,CAAC;AAapC,MAAM,UAAU,cAAc,CAAmB,KAAQ,EAAE,IAAgB;IACzE,MAAM,QAAQ,GAAI,KAA0B,CAAC,KAAK,CAAC;IACnD,OAAO,EAAE,GAAG,KAAK,EAAE,KAAK,EAAE,EAAE,GAAG,QAAQ,EAAE,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC;AAChE,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,KAAa;IACtC,OAAQ,KAA0B,CAAC,KAAK,EAAE,CAAC,QAAQ,CAA2B,CAAC;AACjF,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { PromptResponse, SessionNotification } from "@agentclientprotocol/sdk";
|
|
2
|
+
/** One line of a transcript: something the agent reported, or how a turn ended. Both are plain ACP. */
|
|
3
|
+
export type TranscriptEntry = {
|
|
4
|
+
at: string;
|
|
5
|
+
notification: SessionNotification;
|
|
6
|
+
} | {
|
|
7
|
+
at: string;
|
|
8
|
+
sessionId: string;
|
|
9
|
+
turnEnd: PromptResponse;
|
|
10
|
+
};
|
|
11
|
+
/** Transcripts are JSON Lines, appended as the run goes so a crash loses at most the line being written. */
|
|
12
|
+
export declare function appendTranscript(path: string, entry: TranscriptEntry): Promise<void>;
|
|
13
|
+
export declare function readTranscript(path: string): Promise<TranscriptEntry[]>;
|
|
14
|
+
/** The entries of a transcript's text; a last line without its newline is one a crash cut short. */
|
|
15
|
+
export declare function parseTranscript(text: string): TranscriptEntry[];
|
|
16
|
+
/** What one task run leaves behind: its transcript, and the patch it made to the workspace's git work tree. */
|
|
17
|
+
export interface TaskRun {
|
|
18
|
+
transcript: TranscriptEntry[];
|
|
19
|
+
/** The patch as git wrote it, bytes and all; `undefined` when the workspace is not a git work tree. */
|
|
20
|
+
diff: Uint8Array | undefined;
|
|
21
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { appendFile, readFile } from "node:fs/promises";
|
|
2
|
+
/** Transcripts are JSON Lines, appended as the run goes so a crash loses at most the line being written. */
|
|
3
|
+
export async function appendTranscript(path, entry) {
|
|
4
|
+
await appendFile(path, `${JSON.stringify(entry)}\n`);
|
|
5
|
+
}
|
|
6
|
+
export async function readTranscript(path) {
|
|
7
|
+
return parseTranscript(await readFile(path, "utf8"));
|
|
8
|
+
}
|
|
9
|
+
/** The entries of a transcript's text; a last line without its newline is one a crash cut short. */
|
|
10
|
+
export function parseTranscript(text) {
|
|
11
|
+
return text.split("\n").slice(0, -1).filter((line) => line !== "").map((line) => JSON.parse(line));
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=transcript.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transcript.js","sourceRoot":"","sources":["../src/transcript.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAQxD,4GAA4G;AAC5G,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,IAAY,EAAE,KAAsB;IACzE,MAAM,UAAU,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AACvD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,IAAY;IAC/C,OAAO,eAAe,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;AACvD,CAAC;AAED,oGAAoG;AACpG,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAoB,CAAC,CAAC;AACxH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chopin-ai/core",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Harness-agnostic core: mutable-layer formats, ACP transcripts and the chopin command registry",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/CodePrometheus/chopin-ai.git",
|
|
9
|
+
"directory": "packages/core"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=24.8.0"
|
|
14
|
+
},
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"default": "./dist/index.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@agentclientprotocol/sdk": "^1.9.0",
|
|
26
|
+
"@chopin-ai/workspace": "^0.2.0",
|
|
27
|
+
"yaml": "^2.9.1"
|
|
28
|
+
}
|
|
6
29
|
}
|
package/README.md
DELETED