@celljs/ta-creator 4.31.0 → 4.32.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.en.md +9 -5
- package/README.md +9 -5
- package/bin/render.mjs +861 -38
- package/host/index.mjs +263 -21
- package/package.json +8 -8
- package/skills/creator-make/SKILL.md +38 -17
- package/skills/creator-publish/SKILL.md +15 -14
- package/web/index.js +1342 -357
package/host/index.mjs
CHANGED
|
@@ -7,11 +7,13 @@ var Keys;
|
|
|
7
7
|
Keys.ITEMS = "items";
|
|
8
8
|
Keys.WEEKS = "weeks";
|
|
9
9
|
Keys.TASKS = "tasks";
|
|
10
|
+
Keys.INSIGHTS = "insights";
|
|
10
11
|
})(Keys ||= {});
|
|
11
12
|
var STAGES = ["topic", "making", "review", "published"];
|
|
12
13
|
var FORMS = ["video", "post"];
|
|
13
14
|
var KINDS = ["hot", "howto", "explain"];
|
|
14
15
|
var STEPS = ["script", "visuals", "voice", "captions", "versions", "checks"];
|
|
16
|
+
var SERIES_COLORS = ["#22c55e", "#f97316", "#3b82f6", "#a855f7", "#ec4899", "#14b8a6", "#eab308", "#64748b"];
|
|
15
17
|
var ASPECTS = ["16:9", "9:16", "3:4", "1:1"];
|
|
16
18
|
var PLATFORMS = [
|
|
17
19
|
{
|
|
@@ -96,10 +98,37 @@ var CreatorUtil;
|
|
|
96
98
|
sources: Array.isArray(kept.sources) ? kept.sources.map(source).filter((one) => !!one) : [...SOURCES],
|
|
97
99
|
...goal && time(goal.from) ? { goal: { from: time(goal.from), days: count(goal.days, 30), videos: count(goal.videos, 0), posts: count(goal.posts, 0) } } : {},
|
|
98
100
|
minutesCap: count(kept.minutesCap, 120),
|
|
99
|
-
voice: text(kept.voice, 60) || "zh-CN-XiaoxiaoNeural"
|
|
101
|
+
voice: text(kept.voice, 60) || "zh-CN-XiaoxiaoNeural",
|
|
102
|
+
series: Array.isArray(kept.series) ? seriesOf(kept.series) : []
|
|
100
103
|
};
|
|
101
104
|
}
|
|
102
105
|
CreatorUtil.settings = settings;
|
|
106
|
+
function seriesOf(values) {
|
|
107
|
+
const all = [];
|
|
108
|
+
for (const value of values) {
|
|
109
|
+
const kept = object(value);
|
|
110
|
+
const name = text(kept?.name, 40);
|
|
111
|
+
if (!kept || !name) {
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
const id = text(kept.id, 60) || `s${hash(name)}`;
|
|
115
|
+
if (all.some((one) => one.id === id)) {
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
const about = text(kept.about, 200);
|
|
119
|
+
const perWeek = count(kept.perWeek, 0);
|
|
120
|
+
all.push({
|
|
121
|
+
id,
|
|
122
|
+
name,
|
|
123
|
+
...about ? { about } : {},
|
|
124
|
+
color: text(kept.color, 40) || SERIES_COLORS[all.length % SERIES_COLORS.length],
|
|
125
|
+
...kept.ordered === true ? { ordered: true } : {},
|
|
126
|
+
...perWeek ? { perWeek: Math.min(perWeek, 14) } : {}
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
return all.slice(0, 12);
|
|
130
|
+
}
|
|
131
|
+
CreatorUtil.seriesOf = seriesOf;
|
|
103
132
|
function platform(value) {
|
|
104
133
|
const kept = object(value);
|
|
105
134
|
const id = text(kept?.id, 60);
|
|
@@ -149,6 +178,8 @@ var CreatorUtil;
|
|
|
149
178
|
form: oneOf(FORMS, kept.form, "video"),
|
|
150
179
|
kind: oneOf(KINDS, kept.kind, "howto"),
|
|
151
180
|
stage: oneOf(STAGES, kept.stage, "topic"),
|
|
181
|
+
...text(kept.series, 60) ? { series: text(kept.series, 60) } : {},
|
|
182
|
+
...count(kept.number, 0) ? { number: count(kept.number, 0) } : {},
|
|
152
183
|
...text(kept.why, 300) ? { why: text(kept.why, 300) } : {},
|
|
153
184
|
...typeof kept.heat === "number" ? { heat: Math.max(0, Math.min(100, Math.round(kept.heat))) } : {},
|
|
154
185
|
...time(kept.until) ? { until: time(kept.until) } : {},
|
|
@@ -168,6 +199,7 @@ var CreatorUtil;
|
|
|
168
199
|
...text(kept.session, 1000) ? { session: text(kept.session, 1000) } : {},
|
|
169
200
|
...time(kept.approved) ? { approved: time(kept.approved) } : {},
|
|
170
201
|
...Array.isArray(kept.links) ? { links: kept.links.map(link).filter((one) => !!one) } : {},
|
|
202
|
+
...Array.isArray(kept.stats) ? { stats: kept.stats.map(stat).filter((one) => !!one) } : {},
|
|
171
203
|
...kept.dropped === true ? { dropped: true } : {},
|
|
172
204
|
at,
|
|
173
205
|
changedAt: time(kept.changedAt) ?? at
|
|
@@ -214,13 +246,15 @@ var CreatorUtil;
|
|
|
214
246
|
return Math.min(...(item2.links ?? []).map((one) => one.at), item2.changedAt);
|
|
215
247
|
}
|
|
216
248
|
CreatorUtil.publishedAt = publishedAt;
|
|
217
|
-
function addTopics(items2, topics, now, id) {
|
|
249
|
+
function addTopics(items2, topics, now, id, series = []) {
|
|
218
250
|
const key = (title) => title.toLowerCase().replace(/[\s\p{P}]+/gu, "");
|
|
219
251
|
const titles = new Set(items2.map((one) => key(one.title)));
|
|
220
252
|
const origins = new Set(items2.map((one) => one.origin?.url).filter(Boolean));
|
|
221
253
|
const added = [];
|
|
222
254
|
for (const topic of topics) {
|
|
223
|
-
const
|
|
255
|
+
const of = seriesNamed(series, topic.series);
|
|
256
|
+
const number = of?.ordered ? count(topic.number, 0) || nextNumber([...items2, ...added], of.id) : undefined;
|
|
257
|
+
const made = item({ ...topic, series: of?.id, number, id: id(), stage: "topic", at: now, changedAt: now });
|
|
224
258
|
if (!made || titles.has(key(made.title)) || made.origin && origins.has(made.origin.url)) {
|
|
225
259
|
continue;
|
|
226
260
|
}
|
|
@@ -249,6 +283,101 @@ var CreatorUtil;
|
|
|
249
283
|
return items2.map((one, index) => index === at ? changed : one);
|
|
250
284
|
}
|
|
251
285
|
CreatorUtil.change = change;
|
|
286
|
+
function seriesNamed(series, value) {
|
|
287
|
+
const key = text(value, 60).toLowerCase();
|
|
288
|
+
return key ? series.find((one) => one.id.toLowerCase() === key || one.name.toLowerCase() === key) : undefined;
|
|
289
|
+
}
|
|
290
|
+
CreatorUtil.seriesNamed = seriesNamed;
|
|
291
|
+
function nextNumber(items2, series) {
|
|
292
|
+
return items2.filter((one) => one.series === series).reduce((most, one) => Math.max(most, one.number ?? 0), 0) + 1;
|
|
293
|
+
}
|
|
294
|
+
CreatorUtil.nextNumber = nextNumber;
|
|
295
|
+
function removed(items2, stage) {
|
|
296
|
+
return items2.filter((one) => one.dropped && one.stage === stage && stage !== "published").sort((a, b) => b.changedAt - a.changedAt);
|
|
297
|
+
}
|
|
298
|
+
CreatorUtil.removed = removed;
|
|
299
|
+
function bySeries(items2, series) {
|
|
300
|
+
const known = new Set(series.map((one) => one.id));
|
|
301
|
+
const groups = series.map((one) => {
|
|
302
|
+
const of = items2.filter((item2) => item2.series === one.id);
|
|
303
|
+
return { series: one, items: one.ordered ? [...of].sort((a, b) => (a.number ?? 1e9) - (b.number ?? 1e9)) : of };
|
|
304
|
+
});
|
|
305
|
+
const rest = items2.filter((item2) => !item2.series || !known.has(item2.series));
|
|
306
|
+
return [...groups, ...rest.length ? [{ items: rest }] : []];
|
|
307
|
+
}
|
|
308
|
+
CreatorUtil.bySeries = bySeries;
|
|
309
|
+
function views(item2) {
|
|
310
|
+
return item2.stats?.length ? item2.stats.reduce((all, one) => all + one.views, 0) : undefined;
|
|
311
|
+
}
|
|
312
|
+
CreatorUtil.views = views;
|
|
313
|
+
function analysis(items2, settings2) {
|
|
314
|
+
const published = items2.filter((one) => one.stage === "published" && !one.dropped);
|
|
315
|
+
const measured = published.filter((one) => one.stats?.length);
|
|
316
|
+
const group = (key, of) => {
|
|
317
|
+
const read = of.filter((one) => one.stats?.length);
|
|
318
|
+
const total = read.reduce((all, one) => all + (views(one) ?? 0), 0);
|
|
319
|
+
const watched = read.flatMap((one) => (one.stats ?? []).filter((stat2) => stat2.completion !== undefined));
|
|
320
|
+
const weight = watched.reduce((all, one) => all + Math.max(1, one.views), 0);
|
|
321
|
+
return {
|
|
322
|
+
key,
|
|
323
|
+
count: of.length,
|
|
324
|
+
measured: read.length,
|
|
325
|
+
views: total,
|
|
326
|
+
average: read.length ? Math.round(total / read.length) : 0,
|
|
327
|
+
...watched.length ? { completion: watched.reduce((all, one) => all + (one.completion ?? 0) * Math.max(1, one.views), 0) / weight } : {}
|
|
328
|
+
};
|
|
329
|
+
};
|
|
330
|
+
const known = new Set(settings2.series.map((one) => one.id));
|
|
331
|
+
const none = published.filter((one) => !one.series || !known.has(one.series));
|
|
332
|
+
const platforms = [...new Set(measured.flatMap((one) => (one.stats ?? []).map((stat2) => stat2.platform)))].map((platform2) => {
|
|
333
|
+
const stats = measured.flatMap((one) => (one.stats ?? []).filter((stat2) => stat2.platform === platform2));
|
|
334
|
+
const total = stats.reduce((all, one) => all + one.views, 0);
|
|
335
|
+
return { key: platform2, count: stats.length, measured: stats.length, views: total, average: stats.length ? Math.round(total / stats.length) : 0 };
|
|
336
|
+
});
|
|
337
|
+
return {
|
|
338
|
+
published: published.length,
|
|
339
|
+
measured: measured.length,
|
|
340
|
+
views: measured.reduce((all, one) => all + (views(one) ?? 0), 0),
|
|
341
|
+
series: [
|
|
342
|
+
...settings2.series.map((one) => group(one.id, published.filter((item2) => item2.series === one.id))),
|
|
343
|
+
...none.length ? [group("", none)] : []
|
|
344
|
+
],
|
|
345
|
+
kinds: KINDS.map((kind) => group(kind, published.filter((one) => one.kind === kind))).filter((one) => one.count),
|
|
346
|
+
forms: FORMS.map((form) => group(form, published.filter((one) => one.form === form))).filter((one) => one.count),
|
|
347
|
+
platforms: platforms.sort((a, b) => b.views - a.views),
|
|
348
|
+
top: measured.map((item2) => ({ item: item2, views: views(item2) ?? 0 })).sort((a, b) => b.views - a.views).slice(0, 5)
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
CreatorUtil.analysis = analysis;
|
|
352
|
+
function setStats(items2, id, stats, now) {
|
|
353
|
+
const read = stats.map((one) => stat({ at: now, ...object(one) ?? {} })).filter((one) => !!one);
|
|
354
|
+
const before = items2.find((one) => one.id === id);
|
|
355
|
+
if (!before) {
|
|
356
|
+
throw new Error(`No such piece: ${id}.`);
|
|
357
|
+
}
|
|
358
|
+
const kept = (before.stats ?? []).filter((one) => !read.some((it) => it.platform === one.platform));
|
|
359
|
+
return change(items2, id, { stats: [...kept, ...read] }, now);
|
|
360
|
+
}
|
|
361
|
+
CreatorUtil.setStats = setStats;
|
|
362
|
+
function insights(value) {
|
|
363
|
+
return (Array.isArray(value) ? value : []).map((one) => object(one)).filter((one) => !!one && !!text(one.text, 300) && !!time(one.at)).map((one) => ({
|
|
364
|
+
text: text(one.text, 300),
|
|
365
|
+
tone: oneOf(["good", "bad", "idea"], one.tone, "idea"),
|
|
366
|
+
...text(one.series, 60) ? { series: text(one.series, 60) } : {},
|
|
367
|
+
at: time(one.at)
|
|
368
|
+
})).sort((a, b) => b.at - a.at).slice(0, 30);
|
|
369
|
+
}
|
|
370
|
+
CreatorUtil.insights = insights;
|
|
371
|
+
function addInsights(kept, added, series, now) {
|
|
372
|
+
const read = added.map((one) => typeof one === "string" ? { text: one } : object(one)).filter((one) => !!one).map((one) => ({ ...one, series: seriesNamed(series, one.series)?.id, at: now }));
|
|
373
|
+
return insights([...read, ...kept]);
|
|
374
|
+
}
|
|
375
|
+
CreatorUtil.addInsights = addInsights;
|
|
376
|
+
function latestInsights(insights2) {
|
|
377
|
+
const newest = insights2[0]?.at ?? 0;
|
|
378
|
+
return insights2.filter((one) => newest - one.at < DAY);
|
|
379
|
+
}
|
|
380
|
+
CreatorUtil.latestInsights = latestInsights;
|
|
252
381
|
function progress(items2, goal, now) {
|
|
253
382
|
if (!goal) {
|
|
254
383
|
return;
|
|
@@ -322,6 +451,30 @@ var CreatorUtil;
|
|
|
322
451
|
const href = url(kept?.url);
|
|
323
452
|
return kept && href && text(kept.platform, 60) ? { platform: text(kept.platform, 60), url: href, at: time(kept.at) ?? Date.now() } : undefined;
|
|
324
453
|
}
|
|
454
|
+
function stat(value) {
|
|
455
|
+
const kept = object(value);
|
|
456
|
+
const platform2 = text(kept?.platform, 60);
|
|
457
|
+
if (!kept || !platform2 || typeof kept.views !== "number") {
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
const optional = (key) => typeof kept[key] === "number" ? { [key]: count(kept[key], 0) } : {};
|
|
461
|
+
return {
|
|
462
|
+
platform: platform2,
|
|
463
|
+
views: count(kept.views, 0),
|
|
464
|
+
...optional("likes"),
|
|
465
|
+
...optional("comments"),
|
|
466
|
+
...optional("follows"),
|
|
467
|
+
...typeof kept.completion === "number" && Number.isFinite(kept.completion) ? { completion: Math.max(0, Math.min(1, kept.completion)) } : {},
|
|
468
|
+
at: time(kept.at) ?? Date.now()
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
function hash(value) {
|
|
472
|
+
let h = 0;
|
|
473
|
+
for (const char of value) {
|
|
474
|
+
h = Math.imul(h, 31) + (char.codePointAt(0) ?? 0) | 0;
|
|
475
|
+
}
|
|
476
|
+
return (h >>> 0).toString(36);
|
|
477
|
+
}
|
|
325
478
|
function source(value) {
|
|
326
479
|
const kept = object(value);
|
|
327
480
|
const href = url(kept?.url);
|
|
@@ -342,6 +495,14 @@ var DAY2 = 86400000;
|
|
|
342
495
|
var CreatorTasks;
|
|
343
496
|
((CreatorTasks) => {
|
|
344
497
|
CreatorTasks.IDS = ["topics", "review"];
|
|
498
|
+
function version(task) {
|
|
499
|
+
let h = 0;
|
|
500
|
+
for (const char of task.prompt) {
|
|
501
|
+
h = Math.imul(h, 31) + (char.codePointAt(0) ?? 0) | 0;
|
|
502
|
+
}
|
|
503
|
+
return (h >>> 0).toString(36);
|
|
504
|
+
}
|
|
505
|
+
CreatorTasks.version = version;
|
|
345
506
|
function of(id) {
|
|
346
507
|
const call = (method) => `ta call ${NAME} ${method}`;
|
|
347
508
|
switch (id) {
|
|
@@ -351,13 +512,15 @@ var CreatorTasks;
|
|
|
351
512
|
when: "cron 0 8,12,18 * * *",
|
|
352
513
|
notify: "error",
|
|
353
514
|
prompt: [
|
|
354
|
-
`Run \`${call("brief topics")}\` and read the JSON: the field of the account (niche), its platforms, the sources to look at, how many topics to offer (offer)
|
|
355
|
-
"Look at the sources and the news of the field of the last hours (search the web too), at home and abroad. Pick at most `offer` topics the audience of the niche would want today, none like the titles already there
|
|
515
|
+
`Run \`${call("brief topics")}\` and read the JSON: the field of the account (niche), its platforms, the sources to look at, how many topics to offer (offer), the titles already there, its series (each with what it is about, how many a week the user wants, the topics waiting and what it published) and what the last review of the numbers concluded (insights).`,
|
|
516
|
+
"Look at the sources and the news of the field of the last hours (search the web too), at home and abroad. Pick at most `offer` topics the audience of the niche would want today, none like the titles already there.",
|
|
517
|
+
"Think in series: give each topic the series it belongs to, first to the series that wait for topics the most (few waiting against its perWeek). A series in order (ordered) is a course from easy to deep: its next topic is the next lesson after the last one it has, never one it already has. News goes to the series about news. Follow the insights: more of what worked, less of what did not.",
|
|
518
|
+
"Each topic is one of:",
|
|
356
519
|
'- kind "hot": news while it is hot (a release, a change, a debate); `until` when it stops being worth making (Date.now() milliseconds), `heat` 0–100 by how fast it spreads and how it fits the niche.',
|
|
357
520
|
'- kind "explain": a good work abroad (a post, a talk, a paper, a tool) explained in Chinese; `origin` with url, title, author and its licence if it says one. It is explained, quoted shortly, linked; never reposted or translated whole unless its licence allows it.',
|
|
358
521
|
'- kind "howto": something to show step by step on screen.',
|
|
359
522
|
"Never a topic that rewrites news unchecked, plays on fear, or touches politics, people in the news, film and TV of others, or anything of the user's employer.",
|
|
360
|
-
`Add them with \`${call("topics")} '<JSON array of { title, form: "video" | "post", kind, why (one line: why now), heat, until?, seen: [source names], origin? }>'\`.`,
|
|
523
|
+
`Add them with \`${call("topics")} '<JSON array of { title, series (its id), form: "video" | "post", kind, why (one line: why now), heat, until?, seen: [source names], origin? }>'\`.`,
|
|
361
524
|
"Then, only when a topic has heat 85 or more and is worth making today, tell the user with notify_user in one line: its title and why now. Otherwise reply in one short line how many topics you added. Reply in Chinese."
|
|
362
525
|
].join(`
|
|
363
526
|
`)
|
|
@@ -368,10 +531,13 @@ var CreatorTasks;
|
|
|
368
531
|
when: "mon 09:00",
|
|
369
532
|
notify: "always",
|
|
370
533
|
prompt: [
|
|
371
|
-
`Run \`${call("brief review")}\` and read the JSON: what was published
|
|
372
|
-
"
|
|
373
|
-
|
|
374
|
-
|
|
534
|
+
`Run \`${call("brief review")}\` and read the JSON: what was published (each piece with its id, series, kind, form, links and the numbers read before), the numbers of the weeks kept, the minutes the user gave it, the goal and the series.`,
|
|
535
|
+
"Read the numbers in the user's browser, from each platform's page of data for creators (only read; change nothing, answer no comment, click no ads):",
|
|
536
|
+
`- for each piece published in the last 4 weeks: \`${call("stats")} <id> '<JSON array of { platform, views, likes?, comments?, follows?, completion? (0–1) }>'\`;`,
|
|
537
|
+
`- for last week, each platform: \`${call("week")} <monday YYYY-MM-DD> '<JSON array of { platform, views, likes?, follows?, completion? }>'\`.`,
|
|
538
|
+
`Then run \`${call("brief analysis")}\`: the numbers by series, kind, form and platform. Compare them: which series, kinds, forms and hooks of titles did better, and why.`,
|
|
539
|
+
`Keep 3 to 5 conclusions for the topics to come: \`${call("insights")} '<JSON array of { text (one line: what to do next, with the number behind it), tone: "good" | "bad" | "idea", series? (its id) }>'\`. The search for topics follows them.`,
|
|
540
|
+
"Then write the review as a ta-glance card: the numbers by platform against the week before, the series side by side, what worked and what did not, the minutes against the cap, how far the goal is, and a topic for each series this week. When the minutes passed the cap, say what to make less of. Reply in Chinese, short, for a phone."
|
|
375
541
|
].join(`
|
|
376
542
|
`)
|
|
377
543
|
};
|
|
@@ -422,15 +588,32 @@ class CreatorHost {
|
|
|
422
588
|
const now = this.now();
|
|
423
589
|
const [settings, items, weeks] = await Promise.all([this.settings(), this.items(), this.weeks()]);
|
|
424
590
|
const platforms = CreatorUtil.picked(settings).map((one) => one.name);
|
|
591
|
+
const columns = CreatorUtil.columns(items, now);
|
|
592
|
+
const series = settings.series.map((one) => ({
|
|
593
|
+
id: one.id,
|
|
594
|
+
name: one.name,
|
|
595
|
+
about: one.about,
|
|
596
|
+
ordered: one.ordered,
|
|
597
|
+
perWeek: one.perWeek,
|
|
598
|
+
waiting: columns.topic.filter((item) => item.series === one.id).length,
|
|
599
|
+
making: columns.making.filter((item) => item.series === one.id).length + columns.review.filter((item) => item.series === one.id).length,
|
|
600
|
+
published: columns.published.filter((item) => item.series === one.id).length,
|
|
601
|
+
...one.ordered ? {
|
|
602
|
+
lessons: items.filter((item) => item.series === one.id && !item.dropped).sort((a, b) => (a.number ?? 0) - (b.number ?? 0)).map((item) => `${item.number ?? "?"}. ${item.title}`)
|
|
603
|
+
} : {}
|
|
604
|
+
}));
|
|
605
|
+
const insights = CreatorUtil.latestInsights(await this.insightsKept()).map((one) => ({ text: one.text, tone: one.tone, series: one.series }));
|
|
425
606
|
switch (task) {
|
|
426
607
|
case "topics":
|
|
427
608
|
return {
|
|
609
|
+
series,
|
|
610
|
+
insights,
|
|
428
611
|
niche: settings.niche,
|
|
429
612
|
platforms,
|
|
430
613
|
sources: settings.sources,
|
|
431
614
|
offer: CreatorUtil.offer(settings, weeks, now),
|
|
432
615
|
titles: items.filter((one) => now - one.at < 30 * DAY2).map((one) => one.title).slice(-80),
|
|
433
|
-
waiting:
|
|
616
|
+
waiting: columns.topic.length
|
|
434
617
|
};
|
|
435
618
|
case "review": {
|
|
436
619
|
const week = CreatorUtil.weekOf(now - 7 * DAY2);
|
|
@@ -441,15 +624,34 @@ class CreatorHost {
|
|
|
441
624
|
published: items.filter((one) => one.stage === "published").filter((one) => {
|
|
442
625
|
const at = CreatorUtil.publishedAt(one);
|
|
443
626
|
return at >= from && at < from + 7 * DAY2;
|
|
444
|
-
}).map((one) => ({ title: one.title, form: one.form, kind: one.kind, links: one.links })),
|
|
627
|
+
}).map((one) => ({ id: one.id, title: one.title, series: one.series, form: one.form, kind: one.kind, links: one.links })),
|
|
628
|
+
recent: items.filter((one) => one.stage === "published" && !one.dropped && now - CreatorUtil.publishedAt(one) < 28 * DAY2).map((one) => ({ id: one.id, title: one.title, series: one.series, links: one.links, stats: one.stats })),
|
|
629
|
+
series,
|
|
445
630
|
numbers: weeks.filter((one) => one.week >= CreatorUtil.weekOf(now - 21 * DAY2)),
|
|
446
631
|
minutes: weeks.find((one) => one.week === week)?.minutes ?? 0,
|
|
447
632
|
minutesCap: settings.minutesCap,
|
|
448
633
|
goal: settings.goal ? { ...settings.goal, progress: CreatorUtil.progress(items, settings.goal, now) } : undefined
|
|
449
634
|
};
|
|
450
635
|
}
|
|
636
|
+
case "analysis": {
|
|
637
|
+
const analysis = CreatorUtil.analysis(items, settings);
|
|
638
|
+
const name = (id) => settings.series.find((one) => one.id === id)?.name ?? id;
|
|
639
|
+
return {
|
|
640
|
+
...analysis,
|
|
641
|
+
series: analysis.series.map((one) => ({ ...one, name: name(one.key) })),
|
|
642
|
+
top: analysis.top.map((one) => ({
|
|
643
|
+
id: one.item.id,
|
|
644
|
+
title: one.item.title,
|
|
645
|
+
series: one.item.series,
|
|
646
|
+
kind: one.item.kind,
|
|
647
|
+
form: one.item.form,
|
|
648
|
+
views: one.views
|
|
649
|
+
})),
|
|
650
|
+
insights
|
|
651
|
+
};
|
|
652
|
+
}
|
|
451
653
|
default:
|
|
452
|
-
throw new Error(`No such brief: ${task}. One of topics, review.`);
|
|
654
|
+
throw new Error(`No such brief: ${task}. One of topics, review, analysis.`);
|
|
453
655
|
}
|
|
454
656
|
}
|
|
455
657
|
topics(topics) {
|
|
@@ -457,31 +659,63 @@ class CreatorHost {
|
|
|
457
659
|
return Promise.reject(new Error("Topics are an array of { title, form, kind, why, heat, until?, seen, origin? }."));
|
|
458
660
|
}
|
|
459
661
|
return this.serial(async () => {
|
|
460
|
-
const
|
|
662
|
+
const [kept, settings] = await Promise.all([this.items(), this.settings()]);
|
|
663
|
+
const { items, added } = CreatorUtil.addTopics(kept, topics, this.now(), () => this.id(), settings.series);
|
|
461
664
|
await this.host.setExtensionData(NAME, Keys.ITEMS, items);
|
|
462
665
|
return added;
|
|
463
666
|
});
|
|
464
667
|
}
|
|
465
668
|
update(id, patch) {
|
|
466
|
-
const kept = ["stage", "approved", "links", "dropped"];
|
|
669
|
+
const kept = ["stage", "approved", "links", "dropped", "stats"];
|
|
467
670
|
return this.change(id, Object.fromEntries(Object.entries(patch ?? {}).filter(([key]) => !kept.includes(key))));
|
|
468
671
|
}
|
|
469
672
|
start(id) {
|
|
470
673
|
return this.change(id, { stage: "making", done: [] });
|
|
471
674
|
}
|
|
472
|
-
|
|
675
|
+
async remove(id) {
|
|
676
|
+
const item = (await this.items()).find((one) => one.id === id);
|
|
677
|
+
if (item?.stage === "published") {
|
|
678
|
+
throw new Error("A piece published stays: remove it on the platforms.");
|
|
679
|
+
}
|
|
473
680
|
return this.change(id, { dropped: true });
|
|
474
681
|
}
|
|
682
|
+
restore(id) {
|
|
683
|
+
return this.change(id, { dropped: false });
|
|
684
|
+
}
|
|
685
|
+
stats(id, stats) {
|
|
686
|
+
if (!Array.isArray(stats)) {
|
|
687
|
+
return Promise.reject(new Error("Stats are an array of { platform, views, likes?, comments?, follows?, completion? }."));
|
|
688
|
+
}
|
|
689
|
+
return this.serial(async () => {
|
|
690
|
+
const items = CreatorUtil.setStats(await this.items(), id, stats, this.now());
|
|
691
|
+
await this.host.setExtensionData(NAME, Keys.ITEMS, items);
|
|
692
|
+
return items.find((one) => one.id === id);
|
|
693
|
+
});
|
|
694
|
+
}
|
|
695
|
+
insights(insights) {
|
|
696
|
+
if (!Array.isArray(insights)) {
|
|
697
|
+
return Promise.reject(new Error('Insights are an array of { text, tone: "good" | "bad" | "idea", series? }.'));
|
|
698
|
+
}
|
|
699
|
+
return this.serial(async () => {
|
|
700
|
+
const [kept, settings] = await Promise.all([this.insightsKept(), this.settings()]);
|
|
701
|
+
const next = CreatorUtil.addInsights(kept, insights, settings.series, this.now());
|
|
702
|
+
await this.host.setExtensionData(NAME, Keys.INSIGHTS, next);
|
|
703
|
+
return CreatorUtil.latestInsights(next);
|
|
704
|
+
});
|
|
705
|
+
}
|
|
475
706
|
async submit(id) {
|
|
476
707
|
const [settings, items] = await Promise.all([this.settings(), this.items()]);
|
|
477
708
|
const item = items.find((one) => one.id === id);
|
|
478
|
-
const missing = CreatorUtil.picked(settings).filter((platform) => !item?.versions?.some((one) => one.platform === platform.id && one.files.length));
|
|
709
|
+
const missing = CreatorUtil.picked(settings).filter((platform) => item?.form === "post" ? !!platform.post : true).filter((platform) => !item?.versions?.some((one) => one.platform === platform.id && one.files.length));
|
|
479
710
|
if (!item) {
|
|
480
711
|
throw new Error(`No such piece: ${id}.`);
|
|
481
712
|
}
|
|
482
713
|
if (missing.length) {
|
|
483
714
|
throw new Error(`No version yet for ${missing.map((one) => one.name).join(", ")}.`);
|
|
484
715
|
}
|
|
716
|
+
if (!item.versions?.some((one) => one.files.length)) {
|
|
717
|
+
throw new Error("No version yet: none of the platforms picked takes this form.");
|
|
718
|
+
}
|
|
485
719
|
if (!item.checks?.length) {
|
|
486
720
|
throw new Error("Check it first (the AI label, private information, the length of each version), and keep the checks.");
|
|
487
721
|
}
|
|
@@ -533,14 +767,19 @@ class CreatorHost {
|
|
|
533
767
|
const next = { ...made };
|
|
534
768
|
for (const id of CreatorTasks.IDS) {
|
|
535
769
|
const record = made[id];
|
|
770
|
+
const task = CreatorTasks.of(id);
|
|
771
|
+
const v = CreatorTasks.version(task);
|
|
536
772
|
if (on && !record) {
|
|
537
|
-
const added = await this.host.callPackageHost(CRON, "add", [
|
|
538
|
-
next[id] = { id: added.id };
|
|
539
|
-
} else if (record && "id" in record && !tasks.some((
|
|
773
|
+
const added = await this.host.callPackageHost(CRON, "add", [task]);
|
|
774
|
+
next[id] = { id: added.id, v };
|
|
775
|
+
} else if (record && "id" in record && !tasks.some((one) => one.id === record.id)) {
|
|
540
776
|
next[id] = { removed: true };
|
|
777
|
+
} else if (on && record && "id" in record && record.v !== v) {
|
|
778
|
+
await this.host.callPackageHost(CRON, "update", [record.id, { prompt: task.prompt }]);
|
|
779
|
+
next[id] = { id: record.id, v };
|
|
541
780
|
}
|
|
542
781
|
if (!on && record) {
|
|
543
|
-
if ("id" in record && tasks.some((
|
|
782
|
+
if ("id" in record && tasks.some((task2) => task2.id === record.id)) {
|
|
544
783
|
await this.host.callPackageHost(CRON, "remove", [record.id]).catch(() => {
|
|
545
784
|
return;
|
|
546
785
|
});
|
|
@@ -558,6 +797,9 @@ class CreatorHost {
|
|
|
558
797
|
items() {
|
|
559
798
|
return this.data(Keys.ITEMS).then(CreatorUtil.items);
|
|
560
799
|
}
|
|
800
|
+
insightsKept() {
|
|
801
|
+
return this.data(Keys.INSIGHTS).then(CreatorUtil.insights);
|
|
802
|
+
}
|
|
561
803
|
weeks() {
|
|
562
804
|
return this.data(Keys.WEEKS).then(CreatorUtil.weeks);
|
|
563
805
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celljs/ta-creator",
|
|
3
|
-
"version": "4.
|
|
4
|
-
"description": "A pi package for Ta: a channel of content without showing your face, hot topics of your field found three times a day, videos and posts made for each platform, reviewed on your phone and
|
|
3
|
+
"version": "4.32.1",
|
|
4
|
+
"description": "A pi package for Ta: a channel of content without showing your face, hot topics of your field found three times a day, videos and posts made for each platform, reviewed on your phone and published for you once passed",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
|
7
7
|
"ta-industry"
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"watch": "tsc -b -w --preserveWatchOutput"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@celljs/ta-protocol": "4.
|
|
33
|
-
"@celljs/ta-web": "4.
|
|
32
|
+
"@celljs/ta-protocol": "4.32.1",
|
|
33
|
+
"@celljs/ta-web": "4.32.1",
|
|
34
34
|
"@types/react": "^19.3.0"
|
|
35
35
|
},
|
|
36
36
|
"publishConfig": {
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
"ja-JP": "クリエイター"
|
|
45
45
|
},
|
|
46
46
|
"summary": {
|
|
47
|
-
"en": "Run a channel without showing your face: hot topics of your field three times a day, videos and posts made for each platform you pick, reviewed on your phone,
|
|
48
|
-
"zh-CN": "
|
|
49
|
-
"zh-TW": "
|
|
50
|
-
"ja-JP": "顔出しなしでチャンネル運営:分野の話題を1日3
|
|
47
|
+
"en": "Run a channel without showing your face: hot topics of your field three times a day, videos and posts made for each platform you pick, reviewed on your phone, published for you once you pass it, and a review of the numbers each Monday.",
|
|
48
|
+
"zh-CN": "不出镜也能做内容号:每天三次找你所在领域的热点选题,按你选的平台各做一版视频或图文,手机上一张卡审稿,审过就替你发布,每周一复盘数据。",
|
|
49
|
+
"zh-TW": "不出鏡也能做內容號:每天三次找你所在領域的熱點選題,按你選的平台各做一版影片或圖文,手機上一張卡審稿,審過就替你發佈,每週一複盤數據。",
|
|
50
|
+
"ja-JP": "顔出しなしでチャンネル運営:分野の話題を1日3回探し、選んだプラットフォームごとに動画や投稿を作り、スマホのカードで確認、OK したら代わりに投稿、毎週月曜にデータを振り返ります。"
|
|
51
51
|
},
|
|
52
52
|
"icon": "Film",
|
|
53
53
|
"web": [
|
|
@@ -10,18 +10,24 @@ its server: `ta call @celljs/ta-creator <method> [args as JSON]`.
|
|
|
10
10
|
|
|
11
11
|
| Method | What it does |
|
|
12
12
|
|---|---|
|
|
13
|
-
| `settings` | What the channel is about (niche), the platforms picked and their shapes, the voice |
|
|
13
|
+
| `settings` | What the channel is about (niche), its series, the platforms picked and their shapes, the voice, what happens once a piece is passed (`publish`) |
|
|
14
14
|
| `list [stage]` | The pieces, of a stage: `topic`, `making`, `review`, `published` |
|
|
15
|
-
| `brief topics` | What finding topics needs: niche, platforms, sources, how many to offer, the titles already there |
|
|
16
|
-
| `topics '<JSON array>'` | Adds topics found: `{ title, form: "video" \| "post", kind: "hot" \| "howto" \| "explain", why, heat, until?, seen, origin? }
|
|
17
|
-
| `update <id> '<JSON>'` | Keeps what you made: `script`, `done` (steps of script, visuals, voice, captions, versions, checks), `versions`, `checks` |
|
|
15
|
+
| `brief topics` | What finding topics needs: niche, platforms, sources, how many to offer, the titles already there, the series (what each is about, how many a week, waiting, published, the lessons of a course) and what the last review concluded |
|
|
16
|
+
| `topics '<JSON array>'` | Adds topics found: `{ title, series (its id or name), form: "video" \| "post", kind: "hot" \| "howto" \| "explain", why, heat, until?, seen, origin? }`; a topic of a course is numbered the next lesson |
|
|
17
|
+
| `update <id> '<JSON>'` | Keeps what you made: `script`, `done` (steps of script, visuals, voice, captions, versions, checks), `versions`, `checks`; `series` and `number` when the user moves it |
|
|
18
|
+
| `remove <id>` / `restore <id>` | Removes a topic or a piece not published (kept, to be put back) / puts it back |
|
|
18
19
|
| `submit <id>` | Sends it to review, once it has a version for each platform picked and its checks |
|
|
19
|
-
| `published <id> '<JSON array of { platform, url }>'` | The links once
|
|
20
|
+
| `published <id> '<JSON array of { platform, url }>'` | The links once it is published |
|
|
21
|
+
| `stats <id> '<JSON array of { platform, views, likes?, comments?, follows?, completion? }>'` | What a piece published did, as read from the platforms |
|
|
22
|
+
| `brief analysis` | The numbers by series, kind, form and platform, the pieces that did best, the last conclusions |
|
|
23
|
+
| `insights '<JSON array of { text, tone: "good" \| "bad" \| "idea", series? }>'` | Keeps what a review of the numbers concluded; the search for topics follows it |
|
|
20
24
|
|
|
21
25
|
## Finding topics now
|
|
22
26
|
|
|
23
27
|
Run `brief topics`, look at the sources and the news of the field of the last hours (search the web, at home and
|
|
24
|
-
abroad), and add at most `offer` topics with `topics`.
|
|
28
|
+
abroad), and add at most `offer` topics with `topics`. Think in series: each topic goes to a series, first to those
|
|
29
|
+
with fewest waiting against their `perWeek`; a course (`ordered`) gets its next lesson after those it has, from easy to
|
|
30
|
+
deep, never one it has; news goes to the series about news. Follow the `insights`: more of what worked. A hot topic says until when it is worth making. A work of
|
|
25
31
|
others explained (kind `explain`) names and links its source, quotes it shortly and says the rest in the user's words;
|
|
26
32
|
translate it whole only when its licence allows it, and say so in `origin.licence`. Never news unchecked, fear, politics,
|
|
27
33
|
people in the news, films and shows of others, or anything of the user's employer. Say in a line how many you added.
|
|
@@ -36,17 +42,30 @@ people in the news, films and shows of others, or anything of the user's employe
|
|
|
36
42
|
`~/workspace/ai-coding-channel/episodes/<number>-<short-name>/` unless the user keeps them elsewhere:
|
|
37
43
|
|
|
38
44
|
```json
|
|
39
|
-
{ "title": "
|
|
45
|
+
{ "title": "Before the colon: after it", "series": "the series' name", "number": 3,
|
|
46
|
+
"cover": { "lines": ["two short", "lines"], "sub": "a line under it", "tags": ["tmux", "ssh"] },
|
|
40
47
|
"scenes": [
|
|
41
|
-
{ "title": "
|
|
42
|
-
{ "code": { "file": "
|
|
43
|
-
{ "
|
|
48
|
+
{ "title": "第一步", "sub": "a line under it", "say": "what the voice says" },
|
|
49
|
+
{ "code": { "file": "mac.sh", "lines": ["$ tmux new -s agent"] }, "note": "the key to remember", "say": "..." },
|
|
50
|
+
{ "phone": { "lines": ["$ ssh me@my-mac"], "notify": { "title": "Agent", "text": "完成了 ✓" } }, "note": "...", "say": "..." },
|
|
51
|
+
{ "title": "Sum up", "points": ["one", "two", "three"], "sub": "下期见~", "say": "..." } ] }
|
|
44
52
|
```
|
|
45
53
|
|
|
46
|
-
|
|
47
|
-
|
|
54
|
+
The channel is known by its look, the same every time: a pixel dinosaur hosts it, the series opens each piece with
|
|
55
|
+
its chime, and each cover is the series' green with the title large. `series` is the name of the piece's series (its
|
|
56
|
+
`series` id in `settings`), after the name of the channel as the last `episode.json` of the channel writes it (the
|
|
57
|
+
user named it, as `小绿龙 · `; never invent another); `number` is the piece's own, else one more than the last
|
|
58
|
+
`episode.json` of that series. A title scene is the
|
|
59
|
+
host speaking it in bubbles (a title as `第一步`, `窍门二` is a badge); `code` is a terminal typed a line at a time
|
|
60
|
+
(at most 14 lines, 22 when tall, 60 columns; a line starting `$ ` is a command); `phone` is a phone showing a
|
|
61
|
+
terminal, its `notify` coming in at the end; `points` are written in a notebook by hand. `note` puts a short line
|
|
62
|
+
beside the terminal or the phone. Mix them: never two scenes alike in a row, a device every other scene or so.
|
|
63
|
+
`look` (`paper`, `ink`, `sketch`) changes the background of one scene or, on the piece, of all. Each scene lasts as
|
|
64
|
+
long as its `say`. The voice is the neural voice Xiaoxiao (`zh-CN-XiaoxiaoNeural`, read online by edge-tts, from a Python that has
|
|
48
65
|
it: `TA_CREATOR_PYTHON`, `~/lemo-opuscar/.venv/bin/python` or `python3`), unless `settings` or `voice` names
|
|
49
|
-
another
|
|
66
|
+
another: `hunyuan` (or `hunyuan:<voice>`) is the voice of Tencent Hunyuan, more like a person, read by the Hy Realtime
|
|
67
|
+
service of Ta's voice settings (falling back to Xiaoxiao without one); another neural voice; or a voice of this
|
|
68
|
+
computer's speech (`say -v '?'`), which it falls back to without edge-tts.
|
|
50
69
|
Write `say` as one speaks: short sentences with commas. Never the user's own voice unless they asked and agreed.
|
|
51
70
|
Then make it, the shapes of the platforms picked:
|
|
52
71
|
|
|
@@ -56,7 +75,9 @@ people in the news, films and shows of others, or anything of the user's employe
|
|
|
56
75
|
```
|
|
57
76
|
|
|
58
77
|
(the script is in this package, relative to this file). It needs ffmpeg (`brew install ffmpeg`): when it is missing,
|
|
59
|
-
ask the user to install it. It
|
|
78
|
+
ask the user to install it. It draws the pictures with the browser of this computer (Chrome, Edge, Brave or
|
|
79
|
+
Chromium, without a window; `TA_CREATOR_CHROME` names another); without one it draws them plainly, without the host,
|
|
80
|
+
and you tell the user so. It writes `<shape>.mp4` (`16x9.mp4`, `9x16.mp4`, `3x4.mp4`), `cover-<shape>.png`,
|
|
60
81
|
`captions.srt` and `voice.m4a`; with `--post`, `post-<shape>-01.png`… Every picture carries the label "AI 合成";
|
|
61
82
|
the captions are burned in. Look at a few frames (`ffmpeg -ss <s> -i 16x9.mp4 -frames:v 1 f.png`) before going on.
|
|
62
83
|
A screen recording may stand for a scene when the user made one; never record their screen yourself.
|
|
@@ -74,7 +95,7 @@ people in the news, films and shows of others, or anything of the user's employe
|
|
|
74
95
|
```
|
|
75
96
|
|
|
76
97
|
When the user asks for a change (a message "<id> 要改:…"), change what they said, make it again, `submit` and show the
|
|
77
|
-
card again. When they pass it ("<id> 审过了…"), follow creator-publish.
|
|
98
|
+
card again. When they pass it ("<id> 审过了…"), follow creator-publish: it publishes it on each platform.
|
|
78
99
|
|
|
79
|
-
Never publish, never like, follow or comment as the user, never post the same piece twice on
|
|
80
|
-
than one piece a day on a platform.
|
|
100
|
+
Never publish before the user passed it, never like, follow or comment as the user, never post the same piece twice on
|
|
101
|
+
a platform, never more than one piece a day on a platform.
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: creator-publish
|
|
3
|
-
description: Once the user passed a piece of Creator in review,
|
|
3
|
+
description: Once the user passed a piece of Creator in review, publishes it on each platform in the user's own browser (the file, title, words, tags, cover, the declaration of AI content) and keeps the links: passing it is the user's say-so to publish, they press nothing more. Use it whenever a piece is passed, or the user says they published it.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
#
|
|
6
|
+
# Publishing a piece passed
|
|
7
7
|
|
|
8
|
-
The user passed the piece; read it with `ta call @celljs/ta-creator list review` (its `versions
|
|
9
|
-
`settings` each platform's `publish` page and `declare`, where its declaration of AI content
|
|
8
|
+
The user passed the piece; read it with `ta call @celljs/ta-creator list review` (its `versions`), and with
|
|
9
|
+
`ta call @celljs/ta-creator settings` each platform's `publish` page and `declare`, where its declaration of AI content
|
|
10
|
+
is. Passing it in review is the user's say-so: you publish it yourself, never leaving Publish for them to press.
|
|
10
11
|
|
|
11
12
|
For each platform of its versions, one at a time, with the tools that operate the user's computer (computer use: the
|
|
12
13
|
user's browser, where they are signed in):
|
|
@@ -17,17 +18,17 @@ user's browser, where they are signed in):
|
|
|
17
18
|
tags as they are in the version, nothing added.
|
|
18
19
|
3. Tick the declaration of content made with AI, as `declare` says (B站: 创作声明 → 该视频使用人工智能合成技术). When
|
|
19
20
|
the page has no such choice, write "内容由 AI 辅助生成" at the end of the words.
|
|
20
|
-
4. Leave every other choice as the platform sets it (no paid promotion, no
|
|
21
|
-
|
|
22
|
-
5.
|
|
23
|
-
|
|
21
|
+
4. Leave every other choice as the platform sets it (no paid promotion, no sync to other apps) unless the user said
|
|
22
|
+
otherwise.
|
|
23
|
+
5. Press Publish (发布, 发表, 投稿). When the account already published a piece on that platform today, use the
|
|
24
|
+
platform's own scheduled publishing for the next free day instead (one piece a day on a platform at most). Then
|
|
25
|
+
read the link of the piece from the page of the account's works.
|
|
24
26
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
change nothing and tell the user.
|
|
27
|
+
When the page shows a warning of the platform (a check of risk, too many posts, a captcha), stop there, change nothing
|
|
28
|
+
and tell the user.
|
|
28
29
|
|
|
29
|
-
|
|
30
|
+
Then tell the user in one line where it went, with the links (and the day of any piece scheduled). Keep the links
|
|
31
|
+
as soon as you have them:
|
|
30
32
|
`ta call @celljs/ta-creator published <id> '[{"platform": "bilibili", "url": "https://..."}]' <minutes they took>`.
|
|
31
|
-
Read a link from the platform's page of their works only when they ask you to.
|
|
32
33
|
|
|
33
|
-
Never answer comments, never like, follow or message anyone as the user, never press anything that spends money.
|
|
34
|
+
Never answer comments, never like, follow or message anyone as the user, never press anything that spends money.
|