@meltemi/diagrams-assist 0.0.0-stage → 1.9.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 +21 -0
- package/README.md +35 -2
- package/dist/adapters.d.ts +66 -0
- package/dist/adapters.d.ts.map +1 -0
- package/dist/adapters.js +167 -0
- package/dist/adapters.js.map +1 -0
- package/dist/assist.d.ts +79 -0
- package/dist/assist.d.ts.map +1 -0
- package/dist/assist.js +212 -0
- package/dist/assist.js.map +1 -0
- package/dist/guide.d.ts +3 -0
- package/dist/guide.d.ts.map +1 -0
- package/dist/guide.js +10 -0
- package/dist/guide.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/messages/en.d.ts +69 -0
- package/dist/messages/en.d.ts.map +1 -0
- package/dist/messages/en.js +69 -0
- package/dist/messages/en.js.map +1 -0
- package/dist/messages/es.d.ts +4 -0
- package/dist/messages/es.d.ts.map +1 -0
- package/dist/messages/es.js +43 -0
- package/dist/messages/es.js.map +1 -0
- package/dist/messages/index.d.ts +46 -0
- package/dist/messages/index.d.ts.map +1 -0
- package/dist/messages/index.js +10 -0
- package/dist/messages/index.js.map +1 -0
- package/dist/proposal.d.ts +96 -0
- package/dist/proposal.d.ts.map +1 -0
- package/dist/proposal.js +298 -0
- package/dist/proposal.js.map +1 -0
- package/package.json +37 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Architecture Studio contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,36 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @meltemi/diagrams-assist
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Optional AI assistance for `.meltemi` sources: adapters for Anthropic and OpenAI-compatible
|
|
4
|
+
endpoints (local ones included), proposals of whole blocks checked against the project and
|
|
5
|
+
reconciled with later edits, accepted in part, and redaction of secrets. Nothing is sent unless a
|
|
6
|
+
person asks.
|
|
7
|
+
|
|
8
|
+
It is part of [Meltemi Diagrams](https://github.com/askenaz-dev/meltemi-diagrams#readme), diagrams as code with a canvas, motion and
|
|
9
|
+
exports. Every package of the product has the same version.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @meltemi/diagrams-assist
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Node 22.12.0 or later. The package is an ES module with type declarations.
|
|
18
|
+
|
|
19
|
+
## Use
|
|
20
|
+
|
|
21
|
+
Assistance is used through the command line and the editor:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
meltemi-diagrams assist generate diagrams/new.meltemi --prompt "The checkout of a web shop"
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
The adapters, the prompt guide and the proposal format are this package's exports.
|
|
28
|
+
|
|
29
|
+
## Documentation
|
|
30
|
+
|
|
31
|
+
- [AI assistance](https://github.com/askenaz-dev/meltemi-diagrams/blob/main/docs/assist.md)
|
|
32
|
+
- [All documentation](https://github.com/askenaz-dev/meltemi-diagrams/blob/main/docs/README.md)
|
|
33
|
+
|
|
34
|
+
## Licence
|
|
35
|
+
|
|
36
|
+
MIT. Third-party components and their licences are listed in [THIRD_PARTY_LICENSES.md](https://github.com/askenaz-dev/meltemi-diagrams/blob/main/THIRD_PARTY_LICENSES.md).
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/** One turn of a conversation. */
|
|
2
|
+
export interface AssistMessage {
|
|
3
|
+
readonly role: "user" | "assistant";
|
|
4
|
+
readonly content: string;
|
|
5
|
+
}
|
|
6
|
+
export interface CompletionRequest {
|
|
7
|
+
readonly system: string;
|
|
8
|
+
readonly messages: readonly AssistMessage[];
|
|
9
|
+
readonly maxTokens?: number;
|
|
10
|
+
readonly signal?: AbortSignal;
|
|
11
|
+
}
|
|
12
|
+
export interface ModelAdapter {
|
|
13
|
+
/** `anthropic` or `openai-compatible`. */
|
|
14
|
+
readonly provider: string;
|
|
15
|
+
readonly model: string;
|
|
16
|
+
/** Where requests go, without credentials. */
|
|
17
|
+
readonly endpoint: string;
|
|
18
|
+
/** False when the endpoint is on this machine: nothing leaves it. */
|
|
19
|
+
readonly remote: boolean;
|
|
20
|
+
complete(request: CompletionRequest): Promise<string>;
|
|
21
|
+
}
|
|
22
|
+
export type Fetch = typeof fetch;
|
|
23
|
+
/** The most capable Claude model, the default for Anthropic (decision 0029). */
|
|
24
|
+
export declare const DEFAULT_ANTHROPIC_MODEL = "claude-opus-5-5";
|
|
25
|
+
export declare const ANTHROPIC_URL = "https://api.anthropic.com";
|
|
26
|
+
/** An error of a provider, its message in the interface language and free of credentials. */
|
|
27
|
+
export declare class AssistError extends Error {
|
|
28
|
+
readonly status: number | null;
|
|
29
|
+
constructor(message: string, status?: number | null);
|
|
30
|
+
}
|
|
31
|
+
/** Whether a URL points at this machine. */
|
|
32
|
+
export declare function isLocalUrl(url: string): boolean;
|
|
33
|
+
/** Text with every secret replaced, so that no error or log can show one. */
|
|
34
|
+
export declare function redact(text: string, secrets: readonly (string | undefined)[]): string;
|
|
35
|
+
export interface AnthropicOptions {
|
|
36
|
+
readonly apiKey: string;
|
|
37
|
+
readonly model?: string;
|
|
38
|
+
readonly baseUrl?: string;
|
|
39
|
+
readonly fetch?: Fetch;
|
|
40
|
+
}
|
|
41
|
+
/** Claude through Anthropic's Messages API. */
|
|
42
|
+
export declare function anthropicAdapter(options: AnthropicOptions): ModelAdapter;
|
|
43
|
+
export interface OpenAiCompatibleOptions {
|
|
44
|
+
/** Such as `http://127.0.0.1:11434/v1`. */
|
|
45
|
+
readonly baseUrl: string;
|
|
46
|
+
readonly model: string;
|
|
47
|
+
readonly apiKey?: string;
|
|
48
|
+
readonly fetch?: Fetch;
|
|
49
|
+
}
|
|
50
|
+
/** A chat-completions endpoint: local model servers, or remote services that speak the protocol. */
|
|
51
|
+
export declare function openAiCompatibleAdapter(options: OpenAiCompatibleOptions): ModelAdapter;
|
|
52
|
+
/** Where assistance is configured: provider, model, endpoint and the key, never from projects. */
|
|
53
|
+
export interface AssistConfig {
|
|
54
|
+
readonly provider?: string;
|
|
55
|
+
readonly model?: string;
|
|
56
|
+
readonly baseUrl?: string;
|
|
57
|
+
readonly apiKey?: string;
|
|
58
|
+
}
|
|
59
|
+
export declare const PROVIDERS: readonly ["anthropic", "openai-compatible"];
|
|
60
|
+
/**
|
|
61
|
+
* The adapter of a configuration: explicit settings first, then the environment
|
|
62
|
+
* (`MELTEMI_AI_PROVIDER`, `MELTEMI_AI_MODEL`, `MELTEMI_AI_BASE_URL`, `MELTEMI_AI_API_KEY`,
|
|
63
|
+
* `ANTHROPIC_API_KEY`). A message in the interface language says what is missing.
|
|
64
|
+
*/
|
|
65
|
+
export declare function adapterFor(config: AssistConfig, env?: Readonly<Record<string, string | undefined>>, fetcher?: Fetch): ModelAdapter | string;
|
|
66
|
+
//# sourceMappingURL=adapters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapters.d.ts","sourceRoot":"","sources":["../src/adapters.ts"],"names":[],"mappings":"AAKA,kCAAkC;AAClC,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,CAAC;IAC5C,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B;AAED,MAAM,WAAW,YAAY;IAC3B,0CAA0C;IAC1C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,8CAA8C;IAC9C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,qEAAqE;IACrE,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACvD;AAED,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC;AAEjC,gFAAgF;AAChF,eAAO,MAAM,uBAAuB,oBAAoB,CAAC;AACzD,eAAO,MAAM,aAAa,8BAA8B,CAAC;AAKzD,6FAA6F;AAC7F,qBAAa,WAAY,SAAQ,KAAK;IAGlC,QAAQ,CAAC,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;;;GAIG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,YAAY,EACpB,GAAG,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAM,EACtD,OAAO,CAAC,EAAE,KAAK,GACd,YAAY,GAAG,MAAM,CAyBvB"}
|
package/dist/adapters.js
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
// Model adapters: Anthropic's Messages API and OpenAI-compatible chat endpoints (local servers
|
|
2
|
+
// such as Ollama, llama.cpp or LM Studio, or remote ones). Keys come from the environment or the
|
|
3
|
+
// editor's secret storage, never from project files, and never appear in errors (decision 0029).
|
|
4
|
+
import { messages } from "./messages/index.js";
|
|
5
|
+
/** The most capable Claude model, the default for Anthropic (decision 0029). */
|
|
6
|
+
export const DEFAULT_ANTHROPIC_MODEL = "claude-opus-5-5";
|
|
7
|
+
export const ANTHROPIC_URL = "https://api.anthropic.com";
|
|
8
|
+
const ANTHROPIC_VERSION = "2023-06-01";
|
|
9
|
+
const DEFAULT_MAX_TOKENS = 16000;
|
|
10
|
+
const TIMEOUT_MS = 300_000;
|
|
11
|
+
/** An error of a provider, its message in the interface language and free of credentials. */
|
|
12
|
+
export class AssistError extends Error {
|
|
13
|
+
status;
|
|
14
|
+
constructor(message, status = null) {
|
|
15
|
+
super(message);
|
|
16
|
+
this.status = status;
|
|
17
|
+
this.name = "AssistError";
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/** Whether a URL points at this machine. */
|
|
21
|
+
export function isLocalUrl(url) {
|
|
22
|
+
try {
|
|
23
|
+
const host = new URL(url).hostname;
|
|
24
|
+
return host === "localhost" || host === "127.0.0.1" || host === "[::1]" || host === "::1";
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/** Text with every secret replaced, so that no error or log can show one. */
|
|
31
|
+
export function redact(text, secrets) {
|
|
32
|
+
let result = text;
|
|
33
|
+
for (const secret of secrets) {
|
|
34
|
+
if (secret && secret.length >= 4)
|
|
35
|
+
result = result.split(secret).join("[redacted]");
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
const trimSlash = (url) => url.replace(/\/+$/, "");
|
|
40
|
+
async function post(fetcher, url, headers, body, secrets, signal) {
|
|
41
|
+
let response;
|
|
42
|
+
try {
|
|
43
|
+
response = await fetcher(url, {
|
|
44
|
+
method: "POST",
|
|
45
|
+
headers: { "content-type": "application/json", ...headers },
|
|
46
|
+
body: JSON.stringify(body),
|
|
47
|
+
signal: signal ?? AbortSignal.timeout(TIMEOUT_MS),
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
throw new AssistError(redact(messages().provider.cannotReach(new URL(url).origin, error.message), secrets));
|
|
52
|
+
}
|
|
53
|
+
const text = await response.text();
|
|
54
|
+
if (!response.ok) {
|
|
55
|
+
let detail = text.slice(0, 500);
|
|
56
|
+
try {
|
|
57
|
+
const parsed = JSON.parse(text);
|
|
58
|
+
const message = typeof parsed.error === "string" ? parsed.error : parsed.error?.message;
|
|
59
|
+
if (message)
|
|
60
|
+
detail = message;
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
// Not JSON: keep the start of the text.
|
|
64
|
+
}
|
|
65
|
+
throw new AssistError(redact(messages().provider.answered(response.status, detail), secrets), response.status);
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
return JSON.parse(text);
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
throw new AssistError(messages().provider.notJson);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/** Claude through Anthropic's Messages API. */
|
|
75
|
+
export function anthropicAdapter(options) {
|
|
76
|
+
const baseUrl = trimSlash(options.baseUrl ?? ANTHROPIC_URL);
|
|
77
|
+
const model = options.model ?? DEFAULT_ANTHROPIC_MODEL;
|
|
78
|
+
const fetcher = options.fetch ?? fetch;
|
|
79
|
+
return {
|
|
80
|
+
provider: "anthropic",
|
|
81
|
+
model,
|
|
82
|
+
endpoint: baseUrl,
|
|
83
|
+
remote: !isLocalUrl(baseUrl),
|
|
84
|
+
async complete(request) {
|
|
85
|
+
const answer = (await post(fetcher, `${baseUrl}/v1/messages`, { "x-api-key": options.apiKey, "anthropic-version": ANTHROPIC_VERSION }, {
|
|
86
|
+
model,
|
|
87
|
+
max_tokens: request.maxTokens ?? DEFAULT_MAX_TOKENS,
|
|
88
|
+
system: request.system,
|
|
89
|
+
messages: request.messages.map((m) => ({ role: m.role, content: m.content })),
|
|
90
|
+
}, [options.apiKey], request.signal));
|
|
91
|
+
if (answer.stop_reason === "max_tokens")
|
|
92
|
+
throw new AssistError(messages().provider.cutOff);
|
|
93
|
+
const text = (answer.content ?? [])
|
|
94
|
+
.filter((c) => c.type === "text")
|
|
95
|
+
.map((c) => c.text ?? "")
|
|
96
|
+
.join("");
|
|
97
|
+
if (text === "")
|
|
98
|
+
throw new AssistError(messages().provider.noText);
|
|
99
|
+
return text;
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
/** A chat-completions endpoint: local model servers, or remote services that speak the protocol. */
|
|
104
|
+
export function openAiCompatibleAdapter(options) {
|
|
105
|
+
const baseUrl = trimSlash(options.baseUrl);
|
|
106
|
+
const fetcher = options.fetch ?? fetch;
|
|
107
|
+
return {
|
|
108
|
+
provider: "openai-compatible",
|
|
109
|
+
model: options.model,
|
|
110
|
+
endpoint: baseUrl,
|
|
111
|
+
remote: !isLocalUrl(baseUrl),
|
|
112
|
+
async complete(request) {
|
|
113
|
+
const answer = (await post(fetcher, `${baseUrl}/chat/completions`, options.apiKey ? { authorization: `Bearer ${options.apiKey}` } : {}, {
|
|
114
|
+
model: options.model,
|
|
115
|
+
max_tokens: request.maxTokens ?? DEFAULT_MAX_TOKENS,
|
|
116
|
+
temperature: 0.2,
|
|
117
|
+
messages: [
|
|
118
|
+
{ role: "system", content: request.system },
|
|
119
|
+
...request.messages.map((m) => ({ role: m.role, content: m.content })),
|
|
120
|
+
],
|
|
121
|
+
}, [options.apiKey], request.signal));
|
|
122
|
+
const choice = answer.choices?.[0];
|
|
123
|
+
if (choice?.finish_reason === "length")
|
|
124
|
+
throw new AssistError(messages().provider.cutOff);
|
|
125
|
+
const text = choice?.message?.content ?? "";
|
|
126
|
+
if (text === "")
|
|
127
|
+
throw new AssistError(messages().provider.noText);
|
|
128
|
+
return text;
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
export const PROVIDERS = ["anthropic", "openai-compatible"];
|
|
133
|
+
/**
|
|
134
|
+
* The adapter of a configuration: explicit settings first, then the environment
|
|
135
|
+
* (`MELTEMI_AI_PROVIDER`, `MELTEMI_AI_MODEL`, `MELTEMI_AI_BASE_URL`, `MELTEMI_AI_API_KEY`,
|
|
136
|
+
* `ANTHROPIC_API_KEY`). A message in the interface language says what is missing.
|
|
137
|
+
*/
|
|
138
|
+
export function adapterFor(config, env = {}, fetcher) {
|
|
139
|
+
const provider = config.provider ?? env.MELTEMI_AI_PROVIDER ?? (env.ANTHROPIC_API_KEY ? "anthropic" : undefined);
|
|
140
|
+
const model = config.model ?? env.MELTEMI_AI_MODEL;
|
|
141
|
+
const baseUrl = config.baseUrl ?? env.MELTEMI_AI_BASE_URL;
|
|
142
|
+
const extra = fetcher ? { fetch: fetcher } : {};
|
|
143
|
+
const t = messages().config;
|
|
144
|
+
if (provider === undefined)
|
|
145
|
+
return t.noProvider;
|
|
146
|
+
if (provider === "anthropic") {
|
|
147
|
+
const apiKey = config.apiKey ?? env.ANTHROPIC_API_KEY ?? env.MELTEMI_AI_API_KEY;
|
|
148
|
+
if (!apiKey)
|
|
149
|
+
return t.anthropicKey;
|
|
150
|
+
return anthropicAdapter({
|
|
151
|
+
apiKey,
|
|
152
|
+
...(model ? { model } : {}),
|
|
153
|
+
...(baseUrl ? { baseUrl } : {}),
|
|
154
|
+
...extra,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
if (provider === "openai-compatible") {
|
|
158
|
+
if (!baseUrl)
|
|
159
|
+
return t.baseUrl;
|
|
160
|
+
if (!model)
|
|
161
|
+
return t.model;
|
|
162
|
+
const apiKey = config.apiKey ?? env.MELTEMI_AI_API_KEY;
|
|
163
|
+
return openAiCompatibleAdapter({ baseUrl, model, ...(apiKey ? { apiKey } : {}), ...extra });
|
|
164
|
+
}
|
|
165
|
+
return t.unknownProvider(provider, PROVIDERS);
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=adapters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapters.js","sourceRoot":"","sources":["../src/adapters.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,iGAAiG;AACjG,iGAAiG;AACjG,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AA4B/C,gFAAgF;AAChF,MAAM,CAAC,MAAM,uBAAuB,GAAG,iBAAiB,CAAC;AACzD,MAAM,CAAC,MAAM,aAAa,GAAG,2BAA2B,CAAC;AACzD,MAAM,iBAAiB,GAAG,YAAY,CAAC;AACvC,MAAM,kBAAkB,GAAG,KAAK,CAAC;AACjC,MAAM,UAAU,GAAG,OAAO,CAAC;AAE3B,6FAA6F;AAC7F,MAAM,OAAO,WAAY,SAAQ,KAAK;IAGzB;IAFX,YACE,OAAe,EACN,SAAwB,IAAI;QAErC,KAAK,CAAC,OAAO,CAAC,CAAC;QAFN,WAAM,GAAN,MAAM,CAAsB;QAGrC,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;IAC5B,CAAC;CACF;AAED,4CAA4C;AAC5C,MAAM,UAAU,UAAU,CAAC,GAAW;IACpC,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC;QACnC,OAAO,IAAI,KAAK,WAAW,IAAI,IAAI,KAAK,WAAW,IAAI,IAAI,KAAK,OA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CAAC,CAAC,CAAC,EAAE,CAAC;YAC3B,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC/B,GAAG,KAAK;SACT,CAAC,CAAC;IACL,CAAC;IACD,IAAI,QAAQ,KAAK,mBAAmB,EAAE,CAAC;QACrC,IAAI,CAAC,OAAO;YAAE,OAAO,CAAC,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,KAAK;YAAE,OAAO,CAAC,CAAC,KAAK,CAAC;QAC3B,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,kBAAkB,CAAC;QACvD,OAAO,uBAAuB,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC;IAC9F,CAAC;IACD,OAAO,CAAC,CAAC,eAAe,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;AAChD,CAAC"}
|
package/dist/assist.d.ts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { type Locale } from "@meltemi/diagrams-i18n";
|
|
2
|
+
import type { Diagnostic } from "@meltemi/diagrams-language";
|
|
3
|
+
import { type Document } from "@meltemi/diagrams-model";
|
|
4
|
+
import type { ModelAdapter } from "./adapters.js";
|
|
5
|
+
import { type AssistOperation, type Proposal } from "./proposal.js";
|
|
6
|
+
/** A file sent with a request, and why. */
|
|
7
|
+
export interface SharedFile {
|
|
8
|
+
/** Relative to the project. */
|
|
9
|
+
readonly path: string;
|
|
10
|
+
readonly text: string;
|
|
11
|
+
/** Shown to the person in the interface language; never sent. */
|
|
12
|
+
readonly reason: string;
|
|
13
|
+
}
|
|
14
|
+
export interface AssistRequest {
|
|
15
|
+
readonly operation: AssistOperation;
|
|
16
|
+
/** The file to change or create, relative to the project. */
|
|
17
|
+
readonly path: string;
|
|
18
|
+
/** Its current text; empty for a new file. */
|
|
19
|
+
readonly text: string;
|
|
20
|
+
/** What the person asks; for `relations`, an optional focus. */
|
|
21
|
+
readonly instruction: string;
|
|
22
|
+
/** `relations`: the block to look at, such as `diagram checkout`; every block when absent. */
|
|
23
|
+
readonly block?: string;
|
|
24
|
+
/** `generate`: the profile to start with. */
|
|
25
|
+
readonly profile?: "flow" | "c4" | "sequence" | "free";
|
|
26
|
+
/** Other files sent for context: the files the file imports, or may import. */
|
|
27
|
+
readonly shared: readonly SharedFile[];
|
|
28
|
+
}
|
|
29
|
+
export interface AssistRun {
|
|
30
|
+
readonly adapter: ModelAdapter;
|
|
31
|
+
/** The diagnostics of a text of the file in its project, to validate proposals. */
|
|
32
|
+
readonly check: (text: string) => readonly Diagnostic[];
|
|
33
|
+
/** The document of a text of the file in its project, to describe what items change. */
|
|
34
|
+
readonly documentOf?: (text: string) => Document;
|
|
35
|
+
/** Answers sent back with their errors, at most; 1 by default. */
|
|
36
|
+
readonly maxRepairs?: number;
|
|
37
|
+
readonly signal?: AbortSignal;
|
|
38
|
+
/** The language of the words a proposal writes into the file; English when absent. */
|
|
39
|
+
readonly locale?: Locale;
|
|
40
|
+
}
|
|
41
|
+
/** What a request sends, for the person to see before it goes. */
|
|
42
|
+
export interface Disclosure {
|
|
43
|
+
readonly provider: string;
|
|
44
|
+
readonly model: string;
|
|
45
|
+
readonly endpoint: string;
|
|
46
|
+
readonly remote: boolean;
|
|
47
|
+
readonly files: readonly {
|
|
48
|
+
readonly path: string;
|
|
49
|
+
readonly bytes: number;
|
|
50
|
+
readonly reason: string;
|
|
51
|
+
}[];
|
|
52
|
+
/** Characters of the person's own words sent. */
|
|
53
|
+
readonly instruction: number;
|
|
54
|
+
}
|
|
55
|
+
/** The system prompt: the rules and the guide pages the request needs. */
|
|
56
|
+
export declare function systemPrompt(pages: readonly string[]): string;
|
|
57
|
+
/** The first message of a request. */
|
|
58
|
+
export declare function requestMessage(request: AssistRequest): string;
|
|
59
|
+
/** What a request will send. */
|
|
60
|
+
export declare function disclosure(request: AssistRequest, adapter: ModelAdapter): Disclosure;
|
|
61
|
+
/**
|
|
62
|
+
* Asks the model and turns its answer into a proposal. When the items together add errors, the
|
|
63
|
+
* errors go back to the model for a corrected answer, up to `maxRepairs` times; a proposal that
|
|
64
|
+
* still adds errors lists them in `problems`.
|
|
65
|
+
*/
|
|
66
|
+
export declare function propose(request: AssistRequest, run: AssistRun): Promise<Proposal & {
|
|
67
|
+
readonly problems: readonly string[];
|
|
68
|
+
}>;
|
|
69
|
+
/**
|
|
70
|
+
* Explains changes between two versions (as `describeChange` lines, by file) with the files
|
|
71
|
+
* after them, in Markdown.
|
|
72
|
+
*/
|
|
73
|
+
export declare function explainChanges(changes: string, shared: readonly SharedFile[], adapter: ModelAdapter, signal?: AbortSignal): Promise<{
|
|
74
|
+
summary: string;
|
|
75
|
+
explanation: string;
|
|
76
|
+
}>;
|
|
77
|
+
/** The disclosure as lines for a terminal or a dialog, in the interface language. */
|
|
78
|
+
export declare function describeDisclosure(d: Disclosure): string[];
|
|
79
|
+
//# sourceMappingURL=assist.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assist.d.ts","sourceRoot":"","sources":["../src/assist.ts"],"names":[],"mappings":"AAIA,OAAO,EAAwB,KAAK,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAW,KAAK,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,eAAe,CAAC;AAGjE,OAAO,EAIL,KAAK,eAAe,EACpB,KAAK,QAAQ,EACd,MAAM,eAAe,CAAC;AAEvB,2CAA2C;AAC3C,MAAM,WAAW,UAAU;IACzB,+BAA+B;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI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C;IACzB,QAAQ,CAAC,KAAK,EAAE,SAAS;QACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;KACzB,EAAE,CAAC;IACJ,iDAAiD;IACjD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAkCD,0EAA0E;AAC1E,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAM7D;AAID,sCAAsC;AACtC,wBAAgB,cAAc,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,CAoC7D;AAED,gCAAgC;AAChC,wBAAgB,UAAU,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,YAAY,GAAG,UAAU,CAepF;AAaD;;;;GAIG;AACH,wBAAsB,OAAO,CAC3B,OAAO,EAAE,aAAa,EACtB,GAAG,EAAE,SAAS,GACb,OAAO,CAAC,QAAQ,GAAG;IAAE,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC,CA8D9D;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,SAAS,UAAU,EAAE,EAC7B,OAAO,EAAE,YAAY,EACrB,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC,CA0BnD;AAED,qFAAqF;AACrF,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,UAAU,GAAG,MAAM,EAAE,CAQ1D"}
|
package/dist/assist.js
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
// What an assistance request sends and how its answer becomes a proposal. Requests carry the
|
|
2
|
+
// language guide, the file and the files it imports, nothing else; the person sees that list
|
|
3
|
+
// before anything is sent (decision 0029). Prompts and repair messages are English whatever the
|
|
4
|
+
// interface language: they are written for the model, not for people.
|
|
5
|
+
import { getLocale, setLocale } from "@meltemi/diagrams-i18n";
|
|
6
|
+
import { compile } from "@meltemi/diagrams-model";
|
|
7
|
+
import { GUIDE_PAGES } from "./guide.js";
|
|
8
|
+
import { messages as words } from "./messages/index.js";
|
|
9
|
+
import { applyProposal, buildProposal, parseAnswer, } from "./proposal.js";
|
|
10
|
+
const RULES = `You assist people who write Meltemi Diagrams sources (.meltemi files): diagrams as code that
|
|
11
|
+
people review in Git. Answer with exactly one JSON object and nothing before or after it.
|
|
12
|
+
|
|
13
|
+
Rules for the sources you write:
|
|
14
|
+
- Follow the language guide below exactly; the language version is 0.2. Use only the statements
|
|
15
|
+
and properties it shows.
|
|
16
|
+
- Keep every id that exists unless the request asks to rename it: ids are the identity of
|
|
17
|
+
elements, relations, entities and scenes.
|
|
18
|
+
- Keep the comments and the order of statements of what you do not change.
|
|
19
|
+
- Never refer to files, imports, images or icons that are not in the shared files, except
|
|
20
|
+
built-in tabler:<name> icons you are sure of.
|
|
21
|
+
- Mark every relation you infer, rather than were asked for, with assumption "<why>" in its
|
|
22
|
+
block; people confirm an assumption by removing that line.
|
|
23
|
+
- Give relations an id (as <id>) when stories, routes or styles may need to name them.
|
|
24
|
+
- Never write secrets, credentials or personal data.`;
|
|
25
|
+
function pagesFor(request) {
|
|
26
|
+
const pages = new Set(["language"]);
|
|
27
|
+
const types = new Set();
|
|
28
|
+
if (request.profile)
|
|
29
|
+
types.add(request.profile);
|
|
30
|
+
for (const text of [request.text, ...request.shared.map((s) => s.text)]) {
|
|
31
|
+
const document = compile(text).document;
|
|
32
|
+
for (const d of document.diagrams)
|
|
33
|
+
types.add(d.type);
|
|
34
|
+
if (document.models.length > 0)
|
|
35
|
+
types.add("c4");
|
|
36
|
+
if (document.stories.length > 0)
|
|
37
|
+
pages.add("stories");
|
|
38
|
+
}
|
|
39
|
+
for (const type of ["sequence", "c4", "free"])
|
|
40
|
+
if (types.has(type))
|
|
41
|
+
pages.add(type);
|
|
42
|
+
if (/\b(story|stories|walkthrough|recorrido|animat)/i.test(request.instruction))
|
|
43
|
+
pages.add("stories");
|
|
44
|
+
return [...pages];
|
|
45
|
+
}
|
|
46
|
+
/** The system prompt: the rules and the guide pages the request needs. */
|
|
47
|
+
export function systemPrompt(pages) {
|
|
48
|
+
const guide = pages
|
|
49
|
+
.filter((p) => GUIDE_PAGES[p] !== undefined)
|
|
50
|
+
.map((p) => `<guide page="${p}">\n${GUIDE_PAGES[p]}\n</guide>`)
|
|
51
|
+
.join("\n\n");
|
|
52
|
+
return `${RULES}\n\n${guide}`;
|
|
53
|
+
}
|
|
54
|
+
const fileBlock = (path, text) => `<file path="${path}">\n${text}\n</file>`;
|
|
55
|
+
/** The first message of a request. */
|
|
56
|
+
export function requestMessage(request) {
|
|
57
|
+
const shared = request.shared.map((s) => fileBlock(s.path, s.text)).join("\n\n");
|
|
58
|
+
const context = shared ? `\n\nOther files of the project, for context:\n\n${shared}` : "";
|
|
59
|
+
switch (request.operation) {
|
|
60
|
+
case "generate":
|
|
61
|
+
return `Write a new file ${request.path} for this request:
|
|
62
|
+
|
|
63
|
+
<request>
|
|
64
|
+
${request.instruction}
|
|
65
|
+
</request>
|
|
66
|
+
${request.profile ? `\nStart from a ${request.profile} diagram.\n` : ""}${context}
|
|
67
|
+
|
|
68
|
+
Answer with: {"summary": "<one sentence>", "file": "<the complete text of the new file, starting with language \\"0.2\\">"}`;
|
|
69
|
+
case "modify":
|
|
70
|
+
return `Change ${request.path} as this request asks:
|
|
71
|
+
|
|
72
|
+
<request>
|
|
73
|
+
${request.instruction}
|
|
74
|
+
</request>
|
|
75
|
+
|
|
76
|
+
${fileBlock(request.path, request.text)}${context}
|
|
77
|
+
|
|
78
|
+
Answer with the blocks you change, add or remove, each complete from its keyword to its closing
|
|
79
|
+
brace, and nothing the request does not need:
|
|
80
|
+
{"summary": "<one sentence>", "imports": ["<import statements the new blocks need, if any>"], "changes": [{"action": "replace" | "add" | "remove", "block": "<kind and id, such as diagram checkout>", "text": "<the complete new block; empty to remove>", "reason": "<why, in one sentence>"}]}`;
|
|
81
|
+
case "relations":
|
|
82
|
+
return `Find relations that are probably missing in ${request.path}${request.block ? `, in ${request.block}` : ""}:
|
|
83
|
+
connections that the names and descriptions of the elements and the other relations suggest but
|
|
84
|
+
the file does not have. Do not repeat relations that exist. For C4 views, add them to the model
|
|
85
|
+
block they come from. Leave sequence diagrams out.${request.instruction ? `\n\n<request>\n${request.instruction}\n</request>` : ""}
|
|
86
|
+
|
|
87
|
+
${fileBlock(request.path, request.text)}${context}
|
|
88
|
+
|
|
89
|
+
Answer with at most 10, the most likely first; an empty list is a fine answer:
|
|
90
|
+
{"summary": "<one sentence>", "relations": [{"block": "<kind and id of the block to add it to>", "from": "<id>", "to": "<id>", "label": "<short label>", "reason": "<why it is probably there>"}]}`;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/** What a request will send. */
|
|
94
|
+
export function disclosure(request, adapter) {
|
|
95
|
+
const bytes = (text) => new TextEncoder().encode(text).length;
|
|
96
|
+
return {
|
|
97
|
+
provider: adapter.provider,
|
|
98
|
+
model: adapter.model,
|
|
99
|
+
endpoint: adapter.endpoint,
|
|
100
|
+
remote: adapter.remote,
|
|
101
|
+
files: [
|
|
102
|
+
...(request.text !== ""
|
|
103
|
+
? [{ path: request.path, bytes: bytes(request.text), reason: words().reasons.file }]
|
|
104
|
+
: []),
|
|
105
|
+
...request.shared.map((s) => ({ path: s.path, bytes: bytes(s.text), reason: s.reason })),
|
|
106
|
+
],
|
|
107
|
+
instruction: request.instruction.length,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
/** Runs synchronous work with English as the interface language, for text sent to a model. */
|
|
111
|
+
function inEnglish(work) {
|
|
112
|
+
const previous = getLocale();
|
|
113
|
+
setLocale("en");
|
|
114
|
+
try {
|
|
115
|
+
return work();
|
|
116
|
+
}
|
|
117
|
+
finally {
|
|
118
|
+
setLocale(previous);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Asks the model and turns its answer into a proposal. When the items together add errors, the
|
|
123
|
+
* errors go back to the model for a corrected answer, up to `maxRepairs` times; a proposal that
|
|
124
|
+
* still adds errors lists them in `problems`.
|
|
125
|
+
*/
|
|
126
|
+
export async function propose(request, run) {
|
|
127
|
+
const system = systemPrompt(pagesFor(request));
|
|
128
|
+
const messages = [{ role: "user", content: requestMessage(request) }];
|
|
129
|
+
const repairs = run.maxRepairs ?? 1;
|
|
130
|
+
let last;
|
|
131
|
+
for (let attempt = 0; attempt <= repairs; attempt++) {
|
|
132
|
+
const answerText = await run.adapter.complete({
|
|
133
|
+
system,
|
|
134
|
+
messages,
|
|
135
|
+
...(run.signal ? { signal: run.signal } : {}),
|
|
136
|
+
});
|
|
137
|
+
let answer;
|
|
138
|
+
try {
|
|
139
|
+
answer = parseAnswer(answerText);
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
if (attempt === repairs)
|
|
143
|
+
throw new Error(words().proposal.notAsAsked(error.message), {
|
|
144
|
+
cause: error,
|
|
145
|
+
});
|
|
146
|
+
messages.push({ role: "assistant", content: answerText }, { role: "user", content: "Answer again with only the JSON object asked for." });
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
const proposal = buildProposal({
|
|
150
|
+
operation: request.operation,
|
|
151
|
+
path: request.path,
|
|
152
|
+
baseText: request.text,
|
|
153
|
+
answer,
|
|
154
|
+
provider: run.adapter.provider,
|
|
155
|
+
model: run.adapter.model,
|
|
156
|
+
...(run.documentOf ? { documentOf: run.documentOf } : {}),
|
|
157
|
+
...(run.locale ? { locale: run.locale } : {}),
|
|
158
|
+
});
|
|
159
|
+
const all = applyProposal(proposal, request.text, proposal.items.map((i) => i.id), run.check);
|
|
160
|
+
last = { ...proposal, problems: all.ok || proposal.items.length === 0 ? [] : all.problems };
|
|
161
|
+
if (last.problems.length === 0 || attempt === repairs)
|
|
162
|
+
break;
|
|
163
|
+
// The person reads the problems in the interface language; the model reads them in English.
|
|
164
|
+
const forModel = inEnglish(() => applyProposal(proposal, request.text, proposal.items.map((i) => i.id), run.check));
|
|
165
|
+
const errors = forModel.ok ? last.problems : forModel.problems;
|
|
166
|
+
messages.push({ role: "assistant", content: answerText }, {
|
|
167
|
+
role: "user",
|
|
168
|
+
content: `Applying every change gives these errors:\n${errors.map((p) => `- ${p}`).join("\n")}\n\nAnswer again with the whole JSON object, corrected.`,
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
return last;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Explains changes between two versions (as `describeChange` lines, by file) with the files
|
|
175
|
+
* after them, in Markdown.
|
|
176
|
+
*/
|
|
177
|
+
export async function explainChanges(changes, shared, adapter, signal) {
|
|
178
|
+
const files = shared.map((s) => fileBlock(s.path, s.text)).join("\n\n");
|
|
179
|
+
const answer = parseAnswer(await adapter.complete({
|
|
180
|
+
system: systemPrompt(["language"]),
|
|
181
|
+
messages: [
|
|
182
|
+
{
|
|
183
|
+
role: "user",
|
|
184
|
+
content: `Explain these changes between two versions of an architecture project to someone who
|
|
185
|
+
reviews them: what changed, why it may matter, and what to check. Use the ids and names as written,
|
|
186
|
+
and be brief.
|
|
187
|
+
|
|
188
|
+
<changes>
|
|
189
|
+
${changes}
|
|
190
|
+
</changes>
|
|
191
|
+
${files ? `\nThe changed files as they are now:\n\n${files}\n` : ""}
|
|
192
|
+
Answer with: {"summary": "<one sentence>", "explanation": "<Markdown, at most 300 words>"}`,
|
|
193
|
+
},
|
|
194
|
+
],
|
|
195
|
+
...(signal ? { signal } : {}),
|
|
196
|
+
}));
|
|
197
|
+
return {
|
|
198
|
+
summary: typeof answer.summary === "string" ? answer.summary : "",
|
|
199
|
+
explanation: typeof answer.explanation === "string" ? answer.explanation : "",
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
/** The disclosure as lines for a terminal or a dialog, in the interface language. */
|
|
203
|
+
export function describeDisclosure(d) {
|
|
204
|
+
const t = words().disclosure;
|
|
205
|
+
return [
|
|
206
|
+
t.goesTo(d.provider, d.model, d.endpoint, d.remote),
|
|
207
|
+
...d.files.map((f) => ` ${f.path} (${t.size(f.bytes)}, ${f.reason})`),
|
|
208
|
+
...(d.instruction > 0 ? [` ${t.instruction(d.instruction)}`] : []),
|
|
209
|
+
` ${t.guide}`,
|
|
210
|
+
];
|
|
211
|
+
}
|
|
212
|
+
//# sourceMappingURL=assist.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assist.js","sourceRoot":"","sources":["../src/assist.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,6FAA6F;AAC7F,gGAAgG;AAChG,sEAAsE;AACtE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAe,MAAM,wBAAwB,CAAC;AAE3E,OAAO,EAAE,OAAO,EAAiB,MAAM,yBAAyB,CAAC;AAEjE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,QAAQ,IAAI,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EACL,aAAa,EACb,aAAa,EACb,WAAW,GAGZ,MAAM,eAAe,CAAC;AAuDvB,MAAM,KAAK,GAAG;;;;;;;;;;;;;;qDAcuC,CAAC;AAEtD,SAAS,QAAQ,CAAC,OAAsB;IACtC,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;IACpC,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;IAChC,IAAI,OAAO,CAAC,OAAO;QAAE,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAChD,KAAK,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;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