aicommunicator-plugin-check 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -35
- package/dist/bundle.d.ts +7 -4
- package/dist/bundle.js +50 -35
- package/dist/icon.d.ts +10 -0
- package/dist/icon.js +61 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/manifest.d.ts +2 -0
- package/dist/manifest.js +41 -37
- package/dist/messages.js +33 -33
- package/dist/sample.d.ts +5 -2
- package/dist/sample.js +73 -64
- package/dist/state.js +7 -7
- package/package.json +2 -2
package/dist/sample.js
CHANGED
|
@@ -7,8 +7,11 @@ export const SAMPLE_FORMAT = 'aic-sample/1';
|
|
|
7
7
|
export const MANUAL_MAX_CHARS = 50_000;
|
|
8
8
|
/** 예제 파일 하나의 한도(글자, 037 7절 4번). */
|
|
9
9
|
export const SAMPLE_MAX_CHARS = 200_000;
|
|
10
|
-
/**
|
|
11
|
-
|
|
10
|
+
/**
|
|
11
|
+
* 예제를 쓴 참여자. 실제 이름 대신 "Person", "AI" 이고, 같은 종류가 여럿이면 "Person 2" 처럼 번호를 붙인다. 참여자가 없는 revision 은 "Core" 다.
|
|
12
|
+
* 새로 내보내는 파일은 영어로 쓰고, 옛 파일의 "사람", "코어" 도 읽는다(999 4.2절, rawdev 2026-11-30).
|
|
13
|
+
*/
|
|
14
|
+
export const SAMPLE_WHO = /^(Person|AI|Core|사람|코어)( [2-9]| [1-9]\d)?$/;
|
|
12
15
|
/** 글자 수(코드 포인트). manifest 의 길이 한도와 같은 방법으로 잰다. */
|
|
13
16
|
export function charCount(s) {
|
|
14
17
|
let n = 0;
|
|
@@ -24,19 +27,19 @@ const REVISION_KEYS = ['revision', 'who', 'kind', 'cause', 'summary', 'operation
|
|
|
24
27
|
const TOP_KEYS = ['format', 'title', 'plugins', 'instances', 'revisions', 'generations', 'transmissions'];
|
|
25
28
|
function wordsProblem(where, w) {
|
|
26
29
|
if (!isObject(w) || !isText(w.text) || (w.source !== 'screen' && w.source !== 'relayed_by_ai'))
|
|
27
|
-
return `${where}
|
|
30
|
+
return `${where} must be { text, source: "screen" | "relayed_by_ai" }`;
|
|
28
31
|
const extra = extraKeys(w, ['text', 'source']);
|
|
29
|
-
return extra.length ? `${where}
|
|
32
|
+
return extra.length ? `${where} has unknown fields: ${extra.join(', ')}` : null;
|
|
30
33
|
}
|
|
31
34
|
function causeProblem(where, c) {
|
|
32
35
|
if (!isObject(c))
|
|
33
|
-
return `${where}
|
|
36
|
+
return `${where} must be an object`;
|
|
34
37
|
const extra = extraKeys(c, CAUSE_KEYS);
|
|
35
38
|
if (extra.length)
|
|
36
|
-
return `${where}
|
|
39
|
+
return `${where} has unknown fields: ${extra.join(', ')}. A sample must be a file exported with aic export-sample`;
|
|
37
40
|
if (c.humanWords !== undefined) {
|
|
38
41
|
if (!Array.isArray(c.humanWords))
|
|
39
|
-
return `${where}.humanWords
|
|
42
|
+
return `${where}.humanWords must be a list`;
|
|
40
43
|
for (const [i, w] of c.humanWords.entries()) {
|
|
41
44
|
const p = wordsProblem(`${where}.humanWords[${i}]`, w);
|
|
42
45
|
if (p)
|
|
@@ -49,95 +52,95 @@ function causeProblem(where, c) {
|
|
|
49
52
|
return p;
|
|
50
53
|
}
|
|
51
54
|
if (c.selection !== undefined && (!isObject(c.selection) || (c.selection.kind !== 'artifact' && c.selection.kind !== 'concept'))) {
|
|
52
|
-
return `${where}.selection
|
|
55
|
+
return `${where}.selection must be an object whose kind is artifact or concept`;
|
|
53
56
|
}
|
|
54
57
|
if (c.switch !== undefined && (!isObject(c.switch) || !isText(c.switch.from) || !isText(c.switch.to)))
|
|
55
|
-
return `${where}.switch
|
|
58
|
+
return `${where}.switch must be { from, to, mode }`;
|
|
56
59
|
return null;
|
|
57
60
|
}
|
|
58
61
|
/**
|
|
59
62
|
* 예제 파일(aic-sample/1)의 검사. 문제의 설명이고 없으면 null 이다. 맨 위 층과 revision 과 원인에 모르는 칸이 있으면 거절한다.
|
|
60
63
|
* 예제는 실제 작업을 내보낸 것이어야 하고(037 7절 2번), 내보낼 때 지운 것(참여자 이름, 도구, 시각, 연결 정의)이 다시 들어가지
|
|
61
|
-
* 않게 하려는 것이다. 참여자는 "
|
|
64
|
+
* 않게 하려는 것이다. 참여자는 "Person", "AI", "Core" 로만 적는다(옛 파일의 "사람", "코어" 도 받는다).
|
|
62
65
|
*/
|
|
63
66
|
export function checkSample(value) {
|
|
64
67
|
if (!isObject(value))
|
|
65
|
-
return '
|
|
68
|
+
return 'The sample file must be a JSON object';
|
|
66
69
|
if (value.format !== SAMPLE_FORMAT)
|
|
67
|
-
return
|
|
70
|
+
return `The format of the sample file must be "${SAMPLE_FORMAT}". Use a file exported with aic export-sample`;
|
|
68
71
|
const extra = extraKeys(value, TOP_KEYS);
|
|
69
72
|
if (extra.length)
|
|
70
|
-
return
|
|
73
|
+
return `The sample file has unknown fields: ${extra.join(', ')}`;
|
|
71
74
|
if (!isText(value.title) || value.title.trim() === '' || charCount(value.title) > 200)
|
|
72
|
-
return '
|
|
75
|
+
return 'The title of the sample file must be non-empty text of up to 200 characters';
|
|
73
76
|
if (!Array.isArray(value.plugins) || value.plugins.length === 0 || value.plugins.length > 20)
|
|
74
|
-
return '
|
|
77
|
+
return 'The plugins of the sample file must be a list of 1 to 20 plugins';
|
|
75
78
|
const seen = new Set();
|
|
76
79
|
for (const [i, p] of value.plugins.entries()) {
|
|
77
80
|
if (!isObject(p) || !isPluginId(p.package) || !isVersion(p.version) || (p.title !== undefined && !isText(p.title)))
|
|
78
|
-
return
|
|
81
|
+
return `plugins[${i}] of the sample file must be { package, version, title? }, where package is a plugin id and version is semver`;
|
|
79
82
|
if (seen.has(p.package))
|
|
80
|
-
return
|
|
83
|
+
return `${p.package} appears twice in the plugins of the sample file`;
|
|
81
84
|
seen.add(p.package);
|
|
82
85
|
}
|
|
83
86
|
if (!Array.isArray(value.instances))
|
|
84
|
-
return '
|
|
87
|
+
return 'The instances of the sample file must be a list';
|
|
85
88
|
for (const [i, s] of value.instances.entries()) {
|
|
86
89
|
if (!isObject(s) || !isText(s.id) || !isText(s.package))
|
|
87
|
-
return
|
|
90
|
+
return `instances[${i}] of the sample file must be { id, package, title?, connection? }`;
|
|
88
91
|
const more = extraKeys(s, ['id', 'package', 'title', 'connection']);
|
|
89
92
|
if (more.length)
|
|
90
|
-
return
|
|
93
|
+
return `instances[${i}] of the sample file has unknown fields: ${more.join(', ')}`;
|
|
91
94
|
}
|
|
92
95
|
if (!Array.isArray(value.revisions) || value.revisions.length === 0)
|
|
93
|
-
return '
|
|
96
|
+
return 'The revisions of the sample file must be a list of one or more revisions';
|
|
94
97
|
for (const [i, r] of value.revisions.entries()) {
|
|
95
98
|
const where = `revisions[${i}]`;
|
|
96
99
|
if (!isObject(r))
|
|
97
|
-
return
|
|
100
|
+
return `${where} of the sample file must be an object`;
|
|
98
101
|
const more = extraKeys(r, REVISION_KEYS);
|
|
99
102
|
if (more.length)
|
|
100
|
-
return
|
|
103
|
+
return `${where} of the sample file has unknown fields: ${more.join(', ')}`;
|
|
101
104
|
if (!isText(r.revision) || !isText(r.kind) || !isText(r.summary))
|
|
102
|
-
return
|
|
105
|
+
return `${where} of the sample file must have revision, kind, and summary text`;
|
|
103
106
|
if (!isText(r.who) || !SAMPLE_WHO.test(r.who))
|
|
104
|
-
return
|
|
107
|
+
return `${where}.who of the sample file must be one of "Person", "AI", "Core", with a number such as "Person 2" when there are several of the same kind. Do not put real participant names`;
|
|
105
108
|
if (r.cause !== undefined) {
|
|
106
|
-
const p = causeProblem(
|
|
109
|
+
const p = causeProblem(`${where}.cause of the sample file`, r.cause);
|
|
107
110
|
if (p)
|
|
108
111
|
return p;
|
|
109
112
|
}
|
|
110
113
|
if (r.operations !== undefined && (!Array.isArray(r.operations) || r.operations.some((o) => !isObject(o) || !isText(o.op))))
|
|
111
|
-
return
|
|
114
|
+
return `${where}.operations of the sample file must be a list of { op, as?, input? }`;
|
|
112
115
|
if (!Array.isArray(r.changes) || r.changes.some((c) => !isObject(c) || !isText(c.record) || !isText(c.type)))
|
|
113
|
-
return
|
|
116
|
+
return `${where}.changes of the sample file must be a list of { record, type, owner, before, after }`;
|
|
114
117
|
}
|
|
115
118
|
if (value.generations !== undefined) {
|
|
116
119
|
if (!Array.isArray(value.generations))
|
|
117
|
-
return '
|
|
120
|
+
return 'The generations of the sample file must be a list';
|
|
118
121
|
const texts = (v) => Array.isArray(v) && v.every(isText);
|
|
119
122
|
for (const [i, g] of value.generations.entries()) {
|
|
120
|
-
const where =
|
|
123
|
+
const where = `generations[${i}] of the sample file`;
|
|
121
124
|
if (!isObject(g) || !isText(g.artifact) || !isText(g.who) || !isText(g.medium) || !isText(g.after) || !texts(g.sections))
|
|
122
|
-
return `${where}
|
|
125
|
+
return `${where} must be { artifact, who, medium, instance?, scope?, sections, missing?, after }`;
|
|
123
126
|
if (!SAMPLE_WHO.test(g.who))
|
|
124
|
-
return `${where}.who
|
|
127
|
+
return `${where}.who must be one of "Person", "AI", "Core", with a number when there are several of the same kind`;
|
|
125
128
|
if ((g.instance !== undefined && !isText(g.instance)) || (g.scope !== undefined && !texts(g.scope)) || (g.missing !== undefined && !texts(g.missing)))
|
|
126
|
-
return
|
|
129
|
+
return `instance, scope, or missing of ${where} has the wrong shape`;
|
|
127
130
|
const more = extraKeys(g, ['artifact', 'who', 'medium', 'instance', 'scope', 'sections', 'missing', 'after']);
|
|
128
131
|
if (more.length)
|
|
129
|
-
return `${where}
|
|
132
|
+
return `${where} has unknown fields: ${more.join(', ')}. Do not include artifact bodies or source text`;
|
|
130
133
|
}
|
|
131
134
|
}
|
|
132
135
|
if (value.transmissions !== undefined) {
|
|
133
136
|
if (!Array.isArray(value.transmissions))
|
|
134
|
-
return '
|
|
137
|
+
return 'The transmissions of the sample file must be a list';
|
|
135
138
|
for (const [i, t] of value.transmissions.entries()) {
|
|
136
139
|
if (!isObject(t) || !isText(t.instance) || (t.kind !== 'send' && t.kind !== 'update') || !isText(t.status))
|
|
137
|
-
return
|
|
140
|
+
return `transmissions[${i}] of the sample file must be { instance, kind, status, label? }`;
|
|
138
141
|
const more = extraKeys(t, ['instance', 'kind', 'status', 'label']);
|
|
139
142
|
if (more.length)
|
|
140
|
-
return
|
|
143
|
+
return `transmissions[${i}] of the sample file has unknown fields: ${more.join(', ')}. Run records hold only a summary`;
|
|
141
144
|
}
|
|
142
145
|
}
|
|
143
146
|
return null;
|
|
@@ -149,17 +152,17 @@ export function parseSample(data) {
|
|
|
149
152
|
text = typeof data === 'string' ? data : new TextDecoder('utf-8', { fatal: true }).decode(data);
|
|
150
153
|
}
|
|
151
154
|
catch {
|
|
152
|
-
return { ok: false, problem: '
|
|
155
|
+
return { ok: false, problem: 'The sample file is not UTF-8 text' };
|
|
153
156
|
}
|
|
154
157
|
const n = charCount(text);
|
|
155
158
|
if (n > SAMPLE_MAX_CHARS)
|
|
156
|
-
return { ok: false, problem:
|
|
159
|
+
return { ok: false, problem: `The sample file is over ${SAMPLE_MAX_CHARS.toLocaleString('en-US')} characters (${n.toLocaleString('en-US')} characters)` };
|
|
157
160
|
let value;
|
|
158
161
|
try {
|
|
159
162
|
value = JSON.parse(text.replace(/^/, ''));
|
|
160
163
|
}
|
|
161
164
|
catch (e) {
|
|
162
|
-
return { ok: false, problem:
|
|
165
|
+
return { ok: false, problem: `The sample file is not JSON (${e.message})` };
|
|
163
166
|
}
|
|
164
167
|
const problem = checkSample(value);
|
|
165
168
|
return problem ? { ok: false, problem } : { ok: true, sample: value };
|
|
@@ -171,12 +174,12 @@ export function parseManual(data) {
|
|
|
171
174
|
text = typeof data === 'string' ? data : new TextDecoder('utf-8', { fatal: true }).decode(data);
|
|
172
175
|
}
|
|
173
176
|
catch {
|
|
174
|
-
return { ok: false, problem: '
|
|
177
|
+
return { ok: false, problem: 'The manual is not UTF-8 text' };
|
|
175
178
|
}
|
|
176
179
|
text = text.replace(/^/, '');
|
|
177
180
|
const n = charCount(text);
|
|
178
181
|
if (n > MANUAL_MAX_CHARS)
|
|
179
|
-
return { ok: false, problem:
|
|
182
|
+
return { ok: false, problem: `The manual is over ${MANUAL_MAX_CHARS.toLocaleString('en-US')} characters (${n.toLocaleString('en-US')} characters)` };
|
|
180
183
|
return { ok: true, text };
|
|
181
184
|
}
|
|
182
185
|
/** 쓴 플러그인 하나의 글. 설치되지 않았거나 낮은 버전이면 괄호로 붙인다. */
|
|
@@ -186,8 +189,8 @@ function pluginWord(p, installed) {
|
|
|
186
189
|
return base;
|
|
187
190
|
const have = installed(p.package);
|
|
188
191
|
if (have === null)
|
|
189
|
-
return `${base}(
|
|
190
|
-
return have === p.version ? base : `${base}(
|
|
192
|
+
return `${base} (not installed)`;
|
|
193
|
+
return have === p.version ? base : `${base} (${have} on this computer)`;
|
|
191
194
|
}
|
|
192
195
|
/** 예제가 쓴 플러그인 가운데 이 컴퓨터에 설치되지 않은 것(037 5.2절). */
|
|
193
196
|
export function missingPlugins(sample, installed) {
|
|
@@ -195,11 +198,11 @@ export function missingPlugins(sample, installed) {
|
|
|
195
198
|
}
|
|
196
199
|
/** "쓰는 플러그인" 한 줄과, 설치되지 않은 것이 있으면 "이 예제는 X 도 씁니다(설치되지 않음)." 한 줄. */
|
|
197
200
|
export function samplePluginLines(sample, installed, self) {
|
|
198
|
-
const lines = [
|
|
201
|
+
const lines = [`Plugins used: ${sample.plugins.map((p) => pluginWord(p, installed)).join(', ')}`];
|
|
199
202
|
if (installed) {
|
|
200
203
|
const missing = missingPlugins(sample, installed).filter((p) => p !== self);
|
|
201
204
|
if (missing.length)
|
|
202
|
-
lines.push(
|
|
205
|
+
lines.push(`This sample also uses ${missing.join(', ')} (not installed).`);
|
|
203
206
|
}
|
|
204
207
|
return lines;
|
|
205
208
|
}
|
|
@@ -212,46 +215,52 @@ function clip(s, max) {
|
|
|
212
215
|
return all.length <= max ? s : `${all.slice(0, max).join('')} ...`;
|
|
213
216
|
}
|
|
214
217
|
const indentLines = (s, pad) => s.replace(/\r?\n/g, `\n${pad}`);
|
|
218
|
+
/** 파일의 참여자 표기("Person", "AI", "Core" 와 번호)를 읽기 글의 이름으로. 옛 파일의 "사람", "코어" 는 영어 이름으로 옮긴다. */
|
|
219
|
+
function whoWord(who) {
|
|
220
|
+
return who.replace(/^사람/, 'Person').replace(/^코어/, 'Core');
|
|
221
|
+
}
|
|
222
|
+
/** 그 표기가 사람인가. 옛 파일의 "사람" 도 사람이다. */
|
|
223
|
+
const isPersonWho = (who) => /^(Person|사람)/.test(who);
|
|
215
224
|
function changeWord(c) {
|
|
216
|
-
const action = c.before === null || c.before === undefined ? '
|
|
225
|
+
const action = c.before === null || c.before === undefined ? 'added' : c.after === null || c.after === undefined ? 'removed' : 'changed';
|
|
217
226
|
return `${c.record} ${c.type} ${action}`;
|
|
218
227
|
}
|
|
219
228
|
/** 사람의 말과 선택을 "사람: ..." 줄로. 말한 사람은 revision 을 만든 참여자가 아니라 사람이다. */
|
|
220
229
|
function causeLines(c, who) {
|
|
221
230
|
if (!c)
|
|
222
231
|
return [];
|
|
223
|
-
const person = who
|
|
232
|
+
const person = isPersonWho(who) ? whoWord(who) : 'Person';
|
|
224
233
|
const out = [];
|
|
225
234
|
for (const w of c.humanWords ?? [])
|
|
226
|
-
out.push(`${person}${w.source === 'relayed_by_ai' ? '(
|
|
235
|
+
out.push(`${person}${w.source === 'relayed_by_ai' ? ' (relayed by the AI)' : ''}: "${w.text}"`);
|
|
227
236
|
const s = c.selection;
|
|
228
237
|
if (s) {
|
|
229
238
|
const said = s.said ? `: "${s.said}"` : '';
|
|
230
239
|
if (s.kind === 'artifact')
|
|
231
|
-
out.push(`${person}:
|
|
240
|
+
out.push(`${person}: picked "${clip(s.text ?? '', 200)}" in artifact${s.artifact ? ` ${s.artifact}` : ''}${said}`);
|
|
232
241
|
else
|
|
233
|
-
out.push(`${person}:
|
|
242
|
+
out.push(`${person}: pointed at ${s.records?.length ? s.records.join(', ') : 'one place'} on screen${s.instance ? ` ${s.instance}` : ''}${s.role === 'reference' ? ' as a reference' : ''}${said}`);
|
|
234
243
|
}
|
|
235
244
|
if (c.choice)
|
|
236
|
-
out.push(`${person}(
|
|
245
|
+
out.push(`${person} (answer): "${c.choice.text}"`);
|
|
237
246
|
return out;
|
|
238
247
|
}
|
|
239
248
|
/** 생성 한 줄. 본문은 예제에 없으므로 범위와 구간 이름만 적는다. */
|
|
240
249
|
function generationLine(g, withBasis) {
|
|
241
|
-
const scope = g.scope?.length ?
|
|
242
|
-
const sections = g.sections.length ?
|
|
243
|
-
const missing = g.missing?.length ? `,
|
|
244
|
-
return `${g.who}: ${
|
|
250
|
+
const scope = g.scope?.length ? `scope ${g.scope.join(', ')}` : 'whole scope';
|
|
251
|
+
const sections = g.sections.length ? `sections ${clip(g.sections.join(', '), 300)}` : 'no sections';
|
|
252
|
+
const missing = g.missing?.length ? `, sections without a body ${g.missing.join(', ')}` : '';
|
|
253
|
+
return `${whoWord(g.who)}: made artifact ${g.artifact} (${g.medium}) ${withBasis ? `from the state up to ${g.after}` : 'from this state'} (${g.instance ? `screen ${g.instance}, ` : ''}${scope}, ${sections}${missing})`;
|
|
245
254
|
}
|
|
246
255
|
/**
|
|
247
256
|
* 예제를 읽기 좋은 글로 옮긴다(037 5.3절). revision 마다 "사람: (말)", "AI: (한 일의 요약)", "화면 변화" 를 차례로 적는다. 조작
|
|
248
257
|
* 원문과 변경의 내용은 넣지 않는다. 그것은 파일 자체(form: json)에 있다. installed 를 주면 설치되지 않은 플러그인을 알린다.
|
|
249
258
|
*/
|
|
250
259
|
export function sampleNarrative(sample, opts = {}) {
|
|
251
|
-
const lines = [
|
|
260
|
+
const lines = [`Sample work: ${sample.title}`, ...samplePluginLines(sample, opts.installed, opts.self)];
|
|
252
261
|
if (sample.instances.length) {
|
|
253
|
-
const screens = sample.instances.map((i) => `${i.id} ${i.title ?? i.package}(${i.connection !== undefined ?
|
|
254
|
-
lines.push(
|
|
262
|
+
const screens = sample.instances.map((i) => `${i.id} ${i.title ?? i.package}(${i.connection !== undefined ? `external connection ${i.connection}` : i.package})`);
|
|
263
|
+
lines.push(`Screens: ${screens.join(', ')}`);
|
|
255
264
|
}
|
|
256
265
|
lines.push('');
|
|
257
266
|
// 생성은 revision 이 아니므로 그 상태(after)의 revision 아래에 적는다. 그 revision 이 예제에 없으면 끝에 모은다.
|
|
@@ -262,10 +271,10 @@ export function sampleNarrative(sample, opts = {}) {
|
|
|
262
271
|
sample.revisions.forEach((r, i) => {
|
|
263
272
|
const head = `${i + 1}. (${r.revision}) `;
|
|
264
273
|
const pad = ' '.repeat(head.length);
|
|
265
|
-
const body = [...causeLines(r.cause, r.who), `${r.who}: ${indentLines(clip(r.summary, SUMMARY_SHOWN), pad)}`];
|
|
274
|
+
const body = [...causeLines(r.cause, r.who), `${whoWord(r.who)}: ${indentLines(clip(r.summary, SUMMARY_SHOWN), pad)}`];
|
|
266
275
|
if (r.changes.length) {
|
|
267
276
|
const shown = r.changes.slice(0, CHANGES_SHOWN).map(changeWord);
|
|
268
|
-
body.push(
|
|
277
|
+
body.push(`Screen changes: ${shown.join(', ')}${r.changes.length > shown.length ? ` and ${r.changes.length - shown.length} more` : ''}`);
|
|
269
278
|
}
|
|
270
279
|
for (const g of made.get(r.revision) ?? [])
|
|
271
280
|
body.push(generationLine(g, false));
|
|
@@ -273,14 +282,14 @@ export function sampleNarrative(sample, opts = {}) {
|
|
|
273
282
|
});
|
|
274
283
|
const loose = made.get('') ?? [];
|
|
275
284
|
if (loose.length) {
|
|
276
|
-
lines.push('', '
|
|
285
|
+
lines.push('', 'Artifacts made');
|
|
277
286
|
for (const g of loose)
|
|
278
287
|
lines.push(`- ${generationLine(g, true)}`);
|
|
279
288
|
}
|
|
280
289
|
if (sample.transmissions?.length) {
|
|
281
|
-
lines.push('', '
|
|
290
|
+
lines.push('', 'External connection runs (summary)');
|
|
282
291
|
for (const t of sample.transmissions)
|
|
283
|
-
lines.push(`- ${t.instance} ${t.kind === 'send' ? '
|
|
292
|
+
lines.push(`- ${t.instance} ${t.kind === 'send' ? 'send' : 'update'} ${t.status}${t.label ? `(${t.label})` : ''}`);
|
|
284
293
|
}
|
|
285
294
|
return lines.join('\n');
|
|
286
295
|
}
|
package/dist/state.js
CHANGED
|
@@ -12,22 +12,22 @@ export function isStateId(s) {
|
|
|
12
12
|
/** 상태 목록의 모양 검사. 문제의 설명이고 없으면 null 이다. 같은 id 가 둘이면 받지 않는다. 한 id 는 한 버전만 설치되기 때문이다. */
|
|
13
13
|
export function checkState(plugins) {
|
|
14
14
|
if (!Array.isArray(plugins))
|
|
15
|
-
return 'plugins
|
|
15
|
+
return 'plugins must be a list of { id, version, sha256 }';
|
|
16
16
|
if (plugins.length > STATE_MAX_PLUGINS)
|
|
17
|
-
return `plugins
|
|
17
|
+
return `plugins can have up to ${STATE_MAX_PLUGINS} entries (${plugins.length} given)`;
|
|
18
18
|
const seen = new Set();
|
|
19
19
|
for (const [i, e] of plugins.entries()) {
|
|
20
20
|
if (typeof e !== 'object' || e === null || Array.isArray(e))
|
|
21
|
-
return `plugins[${i}]
|
|
21
|
+
return `plugins[${i}] must be an object`;
|
|
22
22
|
const { id, version, sha256 } = e;
|
|
23
23
|
if (!isPluginId(id))
|
|
24
|
-
return `plugins[${i}].id
|
|
24
|
+
return `plugins[${i}].id is not shaped like a plugin id`;
|
|
25
25
|
if (!isVersion(version))
|
|
26
|
-
return `plugins[${i}].version
|
|
26
|
+
return `plugins[${i}].version is not semver`;
|
|
27
27
|
if (typeof sha256 !== 'string' || !SHA256.test(sha256))
|
|
28
|
-
return `plugins[${i}].sha256
|
|
28
|
+
return `plugins[${i}].sha256 must be 64 lowercase hexadecimal characters`;
|
|
29
29
|
if (seen.has(id))
|
|
30
|
-
return `plugins
|
|
30
|
+
return `plugins has the id ${id} twice`;
|
|
31
31
|
seen.add(id);
|
|
32
32
|
}
|
|
33
33
|
return null;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aicommunicator-plugin-check",
|
|
3
|
-
"version": "0.1
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "Checks the rules for the manifest and package file (.tgz) of AIC (aicommunicator) plugins. Shared by the AIC core, the aic command, and the plugin registry site",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"engines": { "node": ">=22.13" },
|