cortico-world-coo-doc 0.4.2 → 0.4.3
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/CHANGELOG.md +6 -0
- package/index.js +33 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# 更新说明
|
|
2
2
|
|
|
3
|
+
## 0.4.3
|
|
4
|
+
|
|
5
|
+
- 时间按本机时区显示。之前存的是 UTC,`list` 里那句「扫于」、文档开头的「快照:扫描时(…)」、`index.md` 的「刷新时间」都比本地时间早 8 小时,看着像上午扫的。
|
|
6
|
+
- 覆盖文件开头加一行记号,说明这行由说明书写、换回手边时会整份删掉。
|
|
7
|
+
- 同步时清掉已卸载扩展留在 `worlds/<id>/ENV_PROMPT.md` 的覆盖文件:那些世界已经不会加载,留着只是一堆指向不存在文件的影子。
|
|
8
|
+
|
|
3
9
|
## 0.4.2
|
|
4
10
|
|
|
5
11
|
- 库改放 Coopanion 的数据目录(`data/home/companion/data/coo-doc`),不再放扩展包目录里:从市场升级扩展时 pnpm 会替换整个包目录,放里面的 `docs/`、`state.json` 会一起丢。第一次启动会把旧位置的东西搬过去。
|
package/index.js
CHANGED
|
@@ -90,6 +90,14 @@ function oneLine(text, n = 60) {
|
|
|
90
90
|
return s.length > n ? `${s.slice(0, n - 1)}…` : s
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
/** 存的是 UTC,给人看的一律按本机时区写成「2026-12-05 19:07」。 */
|
|
94
|
+
function stamp(iso) {
|
|
95
|
+
const d = iso ? new Date(iso) : new Date()
|
|
96
|
+
if (Number.isNaN(d.getTime())) return ''
|
|
97
|
+
const p = (n) => String(n).padStart(2, '0')
|
|
98
|
+
return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}`
|
|
99
|
+
}
|
|
100
|
+
|
|
93
101
|
const botFile = (...parts) => join(ctxRef.botDir, ...parts)
|
|
94
102
|
|
|
95
103
|
/* ───────────── 状态:谁留手边 ───────────── */
|
|
@@ -387,7 +395,7 @@ async function scan() {
|
|
|
387
395
|
/* ───────────── 文档 ───────────── */
|
|
388
396
|
|
|
389
397
|
function promptDoc(w) {
|
|
390
|
-
const at =
|
|
398
|
+
const at = stamp(w.at)
|
|
391
399
|
const lines = [
|
|
392
400
|
`<!-- 来源:${w.pkgName}@${w.version} · ${w.envFile ?? '(包里没有 ENV_PROMPT.md)'} -->`,
|
|
393
401
|
]
|
|
@@ -444,7 +452,7 @@ function indexDoc(worlds, state) {
|
|
|
444
452
|
cold.length ? cold.map(row).join('\n') : '(都留手边了)',
|
|
445
453
|
'',
|
|
446
454
|
'取法:`coodoc_run(action="read", doc="<id>", section="<章节号或几个字>")`;`coodoc_run(action="find", q="…")` 只回命中的行。',
|
|
447
|
-
`刷新时间:${state.syncedAt || '(还没扫过)'}`,
|
|
455
|
+
`刷新时间:${stamp(state.syncedAt) || '(还没扫过)'}`,
|
|
448
456
|
].join('\n')
|
|
449
457
|
}
|
|
450
458
|
|
|
@@ -453,6 +461,8 @@ function indexDoc(worlds, state) {
|
|
|
453
461
|
const stubFile = () => botFile('docs-tool-stub.json')
|
|
454
462
|
const overrideFile = (id) => botFile('worlds', id, 'ENV_PROMPT.md')
|
|
455
463
|
const docPaths = (id) => ({ prompt: join(PROMPTS_DIR, `${id}.md`), tools: join(TOOLS_DIR, `${id}.md`) })
|
|
464
|
+
// 覆盖文件开头的记号:谁写的、什么时候会被删,顺带让清理认得出来。
|
|
465
|
+
const OVERRIDE_MARK = '<!-- coodoc:这段由说明书库改写,换回手边时这个文件会被删掉,别手改 -->'
|
|
456
466
|
|
|
457
467
|
function writeStubs(map) {
|
|
458
468
|
writeAtomic(stubFile(), `${JSON.stringify(map, null, 2)}\n`)
|
|
@@ -462,6 +472,7 @@ function applyCold(w) {
|
|
|
462
472
|
const { prompt, tools } = docPaths(w.id)
|
|
463
473
|
// 路径写绝对路径:覆盖文件由引擎在部署目录渲染,相对路径在那边找不到。
|
|
464
474
|
const lines = [
|
|
475
|
+
OVERRIDE_MARK,
|
|
465
476
|
`## ${w.label}`,
|
|
466
477
|
'',
|
|
467
478
|
`说明和用法在库里:\`${prompt}\`(${w.prompt.length} 字)`,
|
|
@@ -492,6 +503,23 @@ function rebuildStubs(worlds, state) {
|
|
|
492
503
|
writeStubs(map)
|
|
493
504
|
}
|
|
494
505
|
|
|
506
|
+
/** 卸载掉的扩展留在 worlds/<id>/ 里的覆盖文件也清掉:那些世界已经不会被加载,留着只是一堆找不到库的影子。 */
|
|
507
|
+
function cleanOverrides(live) {
|
|
508
|
+
const root = botFile('worlds')
|
|
509
|
+
let names = []
|
|
510
|
+
try { names = readdirSync(root, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name) } catch { return }
|
|
511
|
+
for (const id of names) {
|
|
512
|
+
if (live.has(id)) continue
|
|
513
|
+
const p = join(root, id, 'ENV_PROMPT.md')
|
|
514
|
+
const text = readText(p)
|
|
515
|
+
if (!text) continue
|
|
516
|
+
// 只认自己写的:新版带记号,0.4.3 之前的老格式认「说明和用法在库里 + docs/prompts/」。
|
|
517
|
+
const mine = text.includes(OVERRIDE_MARK) || (text.includes('说明和用法在库里') && text.includes('docs/prompts/'))
|
|
518
|
+
if (!mine) continue
|
|
519
|
+
try { rmSync(p, { force: true }) } catch { /* 删不掉就算了 */ }
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
|
|
495
523
|
async function syncAll() {
|
|
496
524
|
for (const d of [PROMPTS_DIR, TOOLS_DIR]) { try { mkdirSync(d, { recursive: true }) } catch { /* 只读包 */ } }
|
|
497
525
|
const { worlds, error } = await scan()
|
|
@@ -544,6 +572,7 @@ async function syncAll() {
|
|
|
544
572
|
else applyCold(w)
|
|
545
573
|
}
|
|
546
574
|
rebuildStubs(worlds, state)
|
|
575
|
+
cleanOverrides(live)
|
|
547
576
|
return { ok: true, worlds, state }
|
|
548
577
|
}
|
|
549
578
|
|
|
@@ -659,12 +688,12 @@ function listText() {
|
|
|
659
688
|
const state = readState()
|
|
660
689
|
const hot = Array.isArray(catalog.hot) ? catalog.hot : []
|
|
661
690
|
const cold = Array.isArray(catalog.cold) ? catalog.cold : []
|
|
662
|
-
const at =
|
|
691
|
+
const at = stamp(catalog.at)
|
|
663
692
|
const line = (w, inLib) => {
|
|
664
693
|
const t = tempOf(w.id, state)
|
|
665
694
|
const n = readsThisWeek(w.id, state)
|
|
666
695
|
const tags = []
|
|
667
|
-
if (t) tags.push(`临时留手边,${t.until.slice(0, 10)} 收回`)
|
|
696
|
+
if (t) tags.push(`临时留手边,${stamp(t.until).slice(0, 10)} 收回`)
|
|
668
697
|
if (n >= 3) tags.push(`常用(这周取了 ${n} 次)`)
|
|
669
698
|
if (w.dynamic) tags.push('动态快照')
|
|
670
699
|
const head = `- ${w.label}(${w.id})${w.hook ? `|${w.hook}` : ''} · ${w.chars} 字 · ${w.tools} 件${tags.length ? ` · ${tags.join(' · ')}` : ''}`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cortico-world-coo-doc",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "说明书库:把已装且启用扩展的环境提示词和工具说明抄成 docs/ 下的文件,系统提示词里只留一句「什么时候用」加路径;哪几本留在手边、哪几本收进库里,由机器人在对话里自己切(hot / cold,可临时留几天、到期自动收回)。附带每 5 分钟自动扫一遍新装扩展、目录与常用标记、按节读取和关键词定位、模板型提示词的扫描快照与实时值提醒;Windows 的 install.ps1、macOS 与 Linux 的 install.sh 随包发出,可选地给引擎打补丁,把工具说明也缩成一句加路径。",
|
|
6
6
|
"license": "MIT",
|