@celljs/ta-creator 4.32.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 +8 -4
- package/README.md +8 -4
- package/bin/render.mjs +22 -0
- package/host/index.mjs +263 -21
- package/package.json +8 -8
- package/skills/creator-make/SKILL.md +19 -11
- package/skills/creator-publish/SKILL.md +15 -14
- package/web/index.js +1342 -357
package/README.en.md
CHANGED
|
@@ -2,13 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
The content creation package of Ta (built in and off by default, `pi.offByDefault`: turned on from Industries in the market or in Settings → Extensions): a channel without showing your face. Design and research: [docs/design/ta-creator.md](../../docs/design/ta-creator.md).
|
|
4
4
|
|
|
5
|
-
- **The Creator page**: a row of the double's list opens it,
|
|
5
|
+
- **The Creator page**: a row of the double's list opens it. On top, the way a piece goes: topics → making → to review → published → numbers, each station with its count and what goes on there ("voice · Post-training", "2 wait for you"); the one picked shows below, the series to filter by under the stations. The first time you say what the channel is about and where you publish (Bilibili, Xiaohongshu, Channels, Douyin, Kuaishou, YouTube and Official Accounts to start from; change or add any), and may start a 30-day goal.
|
|
6
|
+
- **Series**: several at once (AI news explained, three-minute lessons, Agent Harness from easy to deep), each with what it is about and how many a week; a course numbers its pieces, its next topic the next lesson. Topics, pieces in the making and to review are grouped by series.
|
|
7
|
+
- **Removed and put back**: topics, pieces in the making and to review can be removed (the last two asked first) and put back from Removed under their station; nothing published is removed.
|
|
8
|
+
- **Making, drawn**: each piece in the making is a line of six stations (script, visuals, voice, captions, versions, checks), those done ticked, the one going on breathing, and a line of what Ta does now.
|
|
9
|
+
- **Numbers**: published, views, views last week, new followers, your time this week; what the review found (3 to 5 conclusions each Monday, which the next topics follow; or review now); views a piece and how much was watched by series, kind, form and platform; views by week; the pieces that did best.
|
|
6
10
|
- **Hot topics** (scheduled tasks the server of the package makes, at 8, 12 and 18 each day): news of the field while it is hot, how-tos, and good work abroad explained; you are told of one of heat 85 or more. A work explained names and links its source and quotes it shortly; it is translated whole only when its licence allows it.
|
|
7
11
|
- **Making** (creator-make): topic → script → `episode.json` → `bin/render.mjs`: a pixel dinosaur hosting it, the series' opening and one cover for all, code typed in a terminal, a phone showing progress and a notification, a summing up written by hand, the voice read aloud, captions burned in, the label "AI 合成" on every picture, in 16:9, 9:16 and 3:4 with covers, or the pictures of a post; the pictures drawn by this computer's browser without a window (plainly without one), with ffmpeg; no dependency added.
|
|
8
12
|
- **The review card** (```ta-creator-review`): each platform's version, its title and words, and the checks, in one card on your phone; pass it or ask for a change.
|
|
9
|
-
- **
|
|
10
|
-
- **The review each Monday**: each platform against the week before,
|
|
13
|
+
- **Publishing** (creator-publish): once passed, Ta opens each platform's page for creators in your browser, uploads the files, fills in the title, words and tags, ticks the declaration of AI content, and publishes it (scheduled for the next free day when the platform had a piece today), then keeps the links: you pass it, and press nothing more. It never signs in for you, answers comments or inflates numbers.
|
|
14
|
+
- **The review each Monday**: the numbers of each piece read (`stats`), compared by series, kind and form (`brief analysis`), the conclusions kept (`insights`) for the topics to come; then a card: each platform against the week before, the series side by side, the time it took you (past your cap, fewer topics are offered), the goal, and a topic for each series. When the package words its tasks anew, only their prompts change; their names and times stay as you set them.
|
|
11
15
|
|
|
12
16
|
## Data
|
|
13
17
|
|
|
14
|
-
The data of the package (`pi.storage`, written by its server alone): `settings` (niche, platforms, sources, goal, weekly minutes cap, voice), `items` (each piece from topic to published; at most 200 topics never made are kept), `weeks` (each platform's numbers and your minutes, 26 weeks kept), `tasks` (the scheduled tasks made; one removed is not made again). Ta and the tasks change them with `ta call @celljs/ta-creator <method>`.
|
|
18
|
+
The data of the package (`pi.storage`, written by its server alone): `settings` (niche, series, platforms, sources, goal, weekly minutes cap, voice), `items` (each piece from topic to published, with its series, number and numbers on each platform; at most 200 topics never made are kept), `weeks` (each platform's numbers and your minutes, 26 weeks kept), `insights` (what reviews concluded, the latest 30), `tasks` (the scheduled tasks made and the version of their prompts; one removed is not made again). Ta and the tasks change them with `ta call @celljs/ta-creator <method>`.
|
package/README.md
CHANGED
|
@@ -2,13 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
Ta 的内容创作行业包(随 Ta 内置、默认关闭:`pi.offByDefault`;在扩展市场的「行业」或 设置 → 扩展 里开启):不出镜也能做内容号。设计与调研见 [docs/design/ta-creator.md](../../docs/design/ta-creator.md)。
|
|
4
4
|
|
|
5
|
-
-
|
|
5
|
+
- **创作者页**:分身列表里的「创作者」一行打开。顶部一条流程:选题 → 制作中 → 待审 → 已发布 → 数据,每站显示条数和正在发生的事(如「配音 · 后训练」「2 条等你审」),点哪站看哪站;下面按系列筛选。首次打开先写内容号做什么、选发在哪些平台(内置 B站、小红书、视频号、抖音、快手、YouTube、公众号,可改可加),可开启 30 天目标。
|
|
6
|
+
- **系列**:同时做几个系列(如 AI 热点解读、AI 三分钟科普、Agent Harness 由浅入深),每个有定位、每周几条;「由浅入深按期」的系列给选题编期数,下一批选题接着上一课往深走。选题、制作、待审都按系列分组显示。
|
|
7
|
+
- **删除与找回**:选题、制作中、待审的内容可以删除(制作中和待审会先确认),删掉的在该栏底部「已删除」里能恢复;已发布的不能删。
|
|
8
|
+
- **制作流程**:每条在做的内容是一行六站(脚本、画面、配音、字幕、各平台版本、检查),做完的打勾、正在做的一站在呼吸,下面一句说 Ta 现在在做什么。
|
|
9
|
+
- **数据**:已发布、累计播放、上周播放、新增关注、本周花的时间;复盘结论(每周一复盘写下 3–5 条,下一批选题照着调,也可「现在复盘」);按系列、类型、形式、平台的条均播放与完播;每周播放走势;表现最好的几条。
|
|
6
10
|
- **热点选题**(`pi.host` 建的定时任务,每天 8、12、18 点):按领域看信息源与当天新闻,找热点、实操、国外好内容的解读三类选题;热度 ≥ 85 时提醒你。解读注明出处并附链接、只短引用,许可允许才全文翻译。
|
|
7
11
|
- **出片**(creator-make):选题 → 脚本 → `episode.json` → `bin/render.mjs`:像素恐龙主播 + 栏目片头与统一封面,终端里逐行打代码、手机里看进度和弹通知、手绘笔记本做总结,本机配音、字幕烧进画面、每个画面带「AI 合成」标识,按平台出 16:9 / 9:16 / 3:4 视频与封面,或图文图片;画面由本机浏览器无窗口绘制(没有浏览器就出朴素版),只用本机 ffmpeg 与浏览器,不新增依赖。
|
|
8
12
|
- **审稿卡**(```ta-creator-review`):手机上一张卡看各平台版本、标题文案、检查项;「通过」或「改一句」。
|
|
9
|
-
-
|
|
10
|
-
-
|
|
13
|
+
- **发布**(creator-publish):通过后 Ta 在你的浏览器里打开各平台创作者中心,上传文件、填标题文案话题、勾选 AI 生成声明,直接点发布(同一平台当天已发过就用平台的定时发布排到下一个空的日子),再记下链接;你审过就行,不用再点。不替你登录、不回评论、不刷量。
|
|
14
|
+
- **每周一复盘**:读各平台每条内容的数据(`stats`),按系列、类型、形式对比(`brief analysis`),把结论记下(`insights`)供选题使用;再发一张卡:各平台对比上周、系列横向对比、本周花了你多少时间(超过上限就少给选题)、目标进度、每个系列本周一个选题。包更新了任务提示词时,已建的两个定时任务只更新提示词,名称和时间保留你改过的。
|
|
11
15
|
|
|
12
16
|
## 数据
|
|
13
17
|
|
|
14
|
-
包数据(`pi.storage`,只由服务端写):`settings
|
|
18
|
+
包数据(`pi.storage`,只由服务端写):`settings`(领域、系列、平台、信息源、目标、每周时间上限、配音)、`items`(选题到已发布的每条内容,含所属系列与期数、各平台数据;最多保留 200 条未做的选题)、`weeks`(每周各平台数据与你花的时间,保留 26 周)、`insights`(复盘结论,保留最近 30 条)、`tasks`(建过的定时任务及其提示词版本,删掉的不再重建)。Ta 与定时任务用 `ta call @celljs/ta-creator <方法>` 改它们。
|
package/bin/render.mjs
CHANGED
|
@@ -35,6 +35,12 @@ class StageBrowser {
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
|
+
socket.addEventListener("close", () => {
|
|
39
|
+
for (const one of this.waiting.values()) {
|
|
40
|
+
one.fail(new Error("The browser closed."));
|
|
41
|
+
}
|
|
42
|
+
this.waiting.clear();
|
|
43
|
+
});
|
|
38
44
|
}
|
|
39
45
|
static find() {
|
|
40
46
|
const candidates = [
|
|
@@ -67,6 +73,17 @@ class StageBrowser {
|
|
|
67
73
|
"--mute-audio",
|
|
68
74
|
"about:blank"
|
|
69
75
|
], { stdio: ["ignore", "ignore", "pipe"] });
|
|
76
|
+
try {
|
|
77
|
+
return await StageBrowser.attach(child, profile);
|
|
78
|
+
} catch (error) {
|
|
79
|
+
child.kill();
|
|
80
|
+
await rm(profile, { recursive: true, force: true }).catch(() => {
|
|
81
|
+
return;
|
|
82
|
+
});
|
|
83
|
+
throw error;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
static async attach(child, profile) {
|
|
70
87
|
const endpoint = await new Promise((done, fail) => {
|
|
71
88
|
let said = "";
|
|
72
89
|
const timer = setTimeout(() => fail(new Error(`The browser did not start: ${said.slice(-300)}`)), 20000);
|
|
@@ -82,6 +99,10 @@ class StageBrowser {
|
|
|
82
99
|
clearTimeout(timer);
|
|
83
100
|
fail(error);
|
|
84
101
|
});
|
|
102
|
+
child.on("exit", () => {
|
|
103
|
+
clearTimeout(timer);
|
|
104
|
+
fail(new Error(`The browser ended before it started: ${said.slice(-300)}`));
|
|
105
|
+
});
|
|
85
106
|
});
|
|
86
107
|
const socket = new WebSocket(endpoint);
|
|
87
108
|
await new Promise((done, fail) => {
|
|
@@ -388,6 +409,7 @@ var HunyuanVoice;
|
|
|
388
409
|
const timer = setTimeout(() => end(new Error("Hunyuan did not finish reading in time.")), timeout);
|
|
389
410
|
const send = (message) => socket.send(JSON.stringify(message));
|
|
390
411
|
socket.addEventListener("error", () => end(new Error(`Could not reach Hunyuan at ${service2.url}.`)));
|
|
412
|
+
socket.addEventListener("close", () => end(new Error("Hunyuan closed before it finished reading.")));
|
|
391
413
|
socket.addEventListener("message", (event) => {
|
|
392
414
|
const message = JSON.parse(String(event.data));
|
|
393
415
|
switch (message.type) {
|
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.32.
|
|
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.32.
|
|
33
|
-
"@celljs/ta-web": "4.32.
|
|
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": [
|