stella-timeline-plugin 2.0.1 → 2.0.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.
@@ -317,35 +317,35 @@ function makePlannerRequestId() {
317
317
  }
318
318
  function buildTimelineQueryPlannerSystemPrompt() {
319
319
  return [
320
- '你是 Timeline 插件内部的时间查询归一化器。',
321
- '你的唯一任务,是把自然语言时间请求归一化为 Timeline 内部可执行的结构化时间计划。',
322
- '禁止调用任何工具,禁止输出 Markdown、解释或多余文本,只输出严格 JSON',
323
- '必须遵守这些约束:',
324
- '1. 你必须先判断请求属于 nowpast_pointpast_range 中的哪一类。',
325
- '2. 不能靠关键词机械枚举,而要真正理解用户语言中的时间语义。',
326
- '3. now 不输出 normalized_point / normalized_start / normalized_end',
327
- '4. past_point 必须输出 normalized_point。',
328
- '5. past_range 必须输出 normalized_start normalized_end',
329
- '6. 对“最近”这类口语范围,要结合 anchor.now 归一化成具体起止时间。',
330
- '7. 对“昨晚”“今天”“昨天上午”这类表达,要给出符合现实习惯的合理时间范围。',
331
- '8. 输出时间必须是带时区偏移的 ISO-like 时间戳。',
332
- '9. 只有用户明确指向某个时刻时,才允许判为 past_point;例如“昨晚八点”“昨天上午十点”“上周六晚上九点”。',
333
- '10. 只要用户问的是一个时间段或一整个时段,就必须判为 past_range;例如“昨晚在做什么”“今天都忙了什么”“最近有什么有趣的事吗”“这几天怎么样”。',
334
- '11. “昨晚”本身不是时间点,而是一个晚间范围;只有“昨晚八点”这类带明确时点锚点的表达才是 past_point',
320
+ 'You are the internal Timeline plugin query normalizer.',
321
+ 'Your only task is to normalize a natural-language time request into a structured time plan that Timeline can execute.',
322
+ 'Do not call tools. Do not output Markdown, explanations, or extra text. Output strict JSON only.',
323
+ 'You must follow these constraints:',
324
+ '1. First classify the request as now, past_point, or past_range.',
325
+ '2. Do not classify mechanically from keywords. Interpret the actual time semantics in the user request.',
326
+ '3. For now, do not output normalized_point / normalized_start / normalized_end.',
327
+ '4. For past_point, normalized_point is required.',
328
+ '5. For past_range, normalized_start and normalized_end are required.',
329
+ '6. For colloquial ranges such as “最近”, normalize into concrete bounds using anchor.now.',
330
+ '7. For expressions such as “昨晚”, “今天”, or “昨天上午”, produce a realistic range that fits ordinary usage.',
331
+ '8. All output times must be ISO-like timestamps with timezone offsets.',
332
+ '9. Classify as past_point only when the user clearly points to a specific moment, for example “昨晚八点”, “昨天上午十点”, or “上周六晚上九点”.',
333
+ '10. If the user is asking about a duration or a whole period, it must be past_range, for example “昨晚在做什么”, “今天都忙了什么”, “最近有什么有趣的事吗”, or “这几天怎么样”.',
334
+ '11. “昨晚” by itself is not a point in time. It is an evening range. Only expressions with an explicit anchor such as “昨晚八点” are past_point.',
335
335
  ].join('\n');
336
336
  }
337
337
  function buildTimelineQueryPlannerMessage(input, anchor, requestId) {
338
338
  return [
339
- '请只根据下面的信息做时间归一化。',
340
- '输出 JSON 对象,字段必须满足下列结构:',
339
+ 'Normalize time only from the information below.',
340
+ 'Output a JSON object with the following shape:',
341
341
  JSON.stringify({
342
342
  schema_version: '1.0',
343
343
  request_id: requestId,
344
344
  target_time_range: 'now | past_point | past_range',
345
- normalized_point: 'past_point 时必填,其余省略',
346
- normalized_start: 'past_range 时必填,其余省略',
347
- normalized_end: 'past_range 时必填,其余省略',
348
- summary: '你如何理解用户时间语义的简短说明',
345
+ normalized_point: 'required for past_point, omit otherwise',
346
+ normalized_start: 'required for past_range, omit otherwise',
347
+ normalized_end: 'required for past_range, omit otherwise',
348
+ summary: 'short summary of how you interpreted the user time semantics',
349
349
  }, null, 2),
350
350
  '',
351
351
  'input:',
@@ -357,36 +357,36 @@ function buildTimelineQueryPlannerMessage(input, anchor, requestId) {
357
357
  }
358
358
  function buildTimelineReasonerSystemPrompt() {
359
359
  return [
360
- '你是 Timeline 插件内部的时间语义推理器。',
361
- '你的唯一任务,是基于 collector 提供的事实包,输出一个严格符合 TimelineReasonerOutput 结构的 JSON 对象。',
362
- '禁止调用任何工具,禁止引用 collector 之外的新既有事实,禁止输出 Markdown、解释或多余文本。',
363
- '必须遵守这些约束:',
364
- '1. 会话硬事实和已存在 canon 优先于生成。',
365
- '2. 如果 collector.request.mode read_only,则绝不能 generate_new_fact',
366
- '3. 如果 decision.action reuse_existing_factselected_fact_id 必须来自 candidate_facts',
367
- '4. 如果 decision.action generate_new_fact,必须给出完整 generated_fact,并且 should_write_canon=true',
368
- '5. 如果当前信息不足且不应复用或生成,才允许 return_empty',
369
- '6. continuity 字段必须如实表达是否做了延续性判断,以及判断理由。',
370
- '7. request_type 只能是 nowpast_pointpast_range',
371
- '8. continuity 不是独立请求类型;它只是 now past_point 查询中的推理结果。',
372
- '9. past_point 可以通过精确命中,或通过“较早事实自然持续到目标时间点”的方式命中。',
373
- '10. past_range 需要先理解已经归一化的时间范围,再从该范围内挑选最相关、最鲜活、最值得提的事实。',
374
- '11. 如果用户在问“有趣”“好玩”“忙不忙”这类语义筛选词,必须先理解筛选语义,再决定复用什么事实或生成什么事实。',
375
- '12. 如果为 past_point past_range 生成新事实,generated_fact 应尽量提供一个合理的 timestamp,并保证它落在目标时间点或目标时间范围内,而不是默认落在当前时刻。',
376
- '13. generated_fact 只输出结构化字段,不要输出自然正文、解释或额外叙述。',
377
- '14. 如果 collector.persona_context.should_constrain_generation=true,则生成的新事实必须显式参考 SOUL / MEMORY / IDENTITY 中的稳定人格、语气、兴趣、生活习惯或长期约定,不能生成与这些内容冲突的生活片段。',
378
- '15. persona_context 中存在明确人格线索时,rationale.persona_basis 不能为空,且必须指出本次生成具体参考了哪些 persona 线索。',
379
- '16. persona_context 中存在明确人格线索时,rationale.constraint_basis 不能为空,且必须指出哪些长期约束限制了生成结果。',
380
- '17. 不要生成通用、模板化、任何人格都能成立的空泛日常;应尽量让 locationactionemotionappearanceinternalMonologue 都体现该 persona 的生活连续性。',
381
- '18. MEMORY 中的长期偏好、关系、生活节奏和与用户的长期约定,都是编织时间记忆时的重要约束;它们不是时间事实本身,但会限制什么样的生成是可信的。',
382
- '19. 还必须遵守 collector.world_context 提供的现实时间逻辑:一日三餐、睡眠、工作/学习、休闲、周末、工作日、节假日的安排都应尽量符合普通现实生活节奏。',
383
- '20. 如果生成的是凌晨或深夜时段,优先考虑睡眠、休息、安静活动;如果生成的是早餐/午餐/晚餐,则时间应落在合理餐段;不要生成明显违背现实作息的片段。',
384
- '21. 如果 decision.action generate_new_factgenerated_fact.sceneSemantics 必须完整输出,用来说明本次编织的事件属于什么活动类型、与当天已知状态是什么连续关系,以及为什么这样判断。',
385
- '22. 如果 decision.action generate_new_factgenerated_fact.appearanceLogic 必须完整输出,用来说明这次事件是否延续当天穿着、是否需要换装、换装原因是什么、最终服装类型属于哪一类。',
386
- '23. 外貌与穿着必须依赖具体事件本身,而不是脱离事件单独生成;例如运动、洗澡、入睡、正式出门、买到并换上新衣物,都会显著影响 appearanceLogic。',
387
- '24. 如果没有足够理由触发换装,优先认为当天穿着具有连续性;不要无缘无故在同一天内频繁改变外貌描述。',
388
- '25. now 查询,如果 collector.conversation_context.should_prefer_conversation_continuity_for_now=true,则“刚刚还在和用户继续这段对话”应被视为最高优先级的近场现实。',
389
- '26. 如果当前会话仍处于粘连窗口内,优先把当前状态理解为还在和用户继续刚才的话题、思考上一轮内容或准备回应,而不是立即跳到脱离当前会话的生活片段。',
360
+ 'You are the internal Timeline plugin time-semantics reasoner.',
361
+ 'Your only task is to use the collector fact bundle and output a JSON object that strictly matches TimelineReasonerOutput.',
362
+ 'Do not call tools. Do not introduce pre-existing facts beyond the collector input. Do not output Markdown, explanations, or extra text.',
363
+ 'You must follow these constraints:',
364
+ '1. Session hard facts and existing canon facts take priority over generation.',
365
+ '2. If collector.request.mode is read_only, you must never generate_new_fact.',
366
+ '3. If decision.action is reuse_existing_fact, selected_fact_id must come from candidate_facts.',
367
+ '4. If decision.action is generate_new_fact, you must provide a complete generated_fact and set should_write_canon=true.',
368
+ '5. Use return_empty only when the available information is insufficient and neither reuse nor generation is justified.',
369
+ '6. The continuity field must truthfully report whether continuity reasoning was used and why.',
370
+ '7. request_type must be one of now, past_point, or past_range.',
371
+ '8. continuity is not a separate request type. It is a reasoning result inside now or past_point queries.',
372
+ '9. past_point may hit either by exact match or by a prior fact that naturally continues to the target time.',
373
+ '10. For past_range, first understand the normalized range, then choose the most relevant, vivid, and worth-mentioning facts from that range.',
374
+ '11. If the user asks with semantic filters such as “有趣”, “好玩”, or “忙不忙”, interpret that filter first before deciding which fact to reuse or generate.',
375
+ '12. When generating a new fact for past_point or past_range, provide a reasonable timestamp that lands inside the target point or range instead of defaulting to the current moment.',
376
+ '13. generated_fact must contain structured fields only, with no free-form prose, explanation, or extra narration.',
377
+ '14. If collector.persona_context.should_constrain_generation=true, the new fact must explicitly respect the stable persona, tone, interests, habits, and long-term commitments described in SOUL / MEMORY / IDENTITY, and must not conflict with them.',
378
+ '15. When persona_context contains concrete persona signals, rationale.persona_basis must be non-empty and must name the specific persona signals used.',
379
+ '16. When persona_context contains concrete persona signals, rationale.constraint_basis must be non-empty and must name the long-term constraints that limited generation.',
380
+ '17. Do not generate generic, template-like daily scenes that could fit anyone. Let location, action, emotion, appearance, and internalMonologue reflect this persona\'s lived continuity.',
381
+ '18. Long-term preferences, relationships, life rhythm, and standing commitments from MEMORY are important constraints when weaving time memories. They are not time facts themselves, but they constrain what generation is believable.',
382
+ '19. You must also respect the real-world temporal logic in collector.world_context: meals, sleep, work/study, leisure, weekends, weekdays, and holidays should broadly fit ordinary life rhythm.',
383
+ '20. For late-night or pre-dawn generation, prefer sleep, rest, or quiet activities. For breakfast, lunch, or dinner scenes, keep the timestamp inside a plausible meal window. Do not generate scenes that obviously violate ordinary routine.',
384
+ '21. If decision.action is generate_new_fact, generated_fact.sceneSemantics must be fully populated to explain the activity type, how it relates to known same-day state, and why that judgment fits.',
385
+ '22. If decision.action is generate_new_fact, generated_fact.appearanceLogic must be fully populated to explain whether the day\'s outfit continues, whether a change is needed, why, and what outfit class results.',
386
+ '23. Appearance and clothing must depend on the concrete event itself rather than being generated independently. Exercise, bathing, sleep, formal outings, and buying/changing into new clothes are all strong appearance drivers.',
387
+ '24. If there is not enough reason for an outfit change, prefer same-day clothing continuity. Do not change appearance descriptions repeatedly within one day without cause.',
388
+ '25. For now queries, if collector.conversation_context.should_prefer_conversation_continuity_for_now=true, then “still continuing the just-active conversation with the user” should be treated as the highest-priority near-field reality.',
389
+ '26. If the current session is still inside the stickiness window, prefer interpreting the current state as continuing the recent topic, thinking about the last turn, or preparing a response, instead of jumping immediately to an unrelated off-thread life scene.',
390
390
  ].join('\n');
391
391
  }
392
392
  function setClock(parts, hour, minute = 0, second = 0) {
@@ -682,8 +682,8 @@ function createTimelineQueryPlanner(pluginApi, toolContext, runtimeConfig) {
682
682
  }
683
683
  function buildTimelineReasonerMessage(collector) {
684
684
  return [
685
- '请只根据下面的 collector JSON 做结构化时间推理。',
686
- '输出一个 JSON 对象,字段必须满足 TimelineReasonerOutput',
685
+ 'Perform structured time reasoning using only the collector JSON below.',
686
+ 'Output a JSON object matching TimelineReasonerOutput:',
687
687
  JSON.stringify({
688
688
  schema_version: '1.0',
689
689
  request_id: collector.request_id,
@@ -698,7 +698,7 @@ function buildTimelineReasonerMessage(collector) {
698
698
  },
699
699
  decision: {
700
700
  action: 'reuse_existing_fact | generate_new_fact | return_empty',
701
- selected_fact_id: 'reuse_existing_fact 时必填',
701
+ selected_fact_id: 'required when action is reuse_existing_fact',
702
702
  should_write_canon: true,
703
703
  },
704
704
  continuity: {
@@ -684,7 +684,7 @@ async function timelineResolve(input, dependencyOverrides) {
684
684
  }
685
685
  exports.timelineResolveToolSpec = {
686
686
  name: 'timeline_resolve',
687
- description: '处理“你在干嘛”“你现在在哪”“最近有什么有趣的事吗”“昨晚八点你在做什么”这类时间现实与回忆问题的统一入口;直接接收自然语言 query,内部会先理解时间语义,再检索或生成并 append-only 写入 canon',
687
+ description: 'Unified entry point for time-grounded reality and recall questions such as “你在干嘛”, “你现在在哪”, “最近有什么有趣的事吗”, or “昨晚八点你在做什么”. It accepts a natural-language query, interprets the time semantics internally, then retrieves or generates and append-only writes canon facts.',
688
688
  inputSchema: {
689
689
  type: 'object',
690
690
  properties: {
@@ -1,54 +1,54 @@
1
- {
2
- "id": "stella-timeline-plugin",
3
- "name": "Stella Timeline Plugin",
4
- "version": "2.0.0",
5
- "description": "OpenClaw timeline runtime with canonical timeline_resolve, LLM-based temporal reasoning, and guarded append-only writes.",
6
- "entry": "dist/index.js",
7
- "skills": [
8
- "skills/timeline"
9
- ],
10
- "configSchema": {
11
- "type": "object",
12
- "properties": {
13
- "enableTrace": {
14
- "type": "boolean",
15
- "default": true,
16
- "description": "Whether Timeline writes trace records for each runtime execution."
17
- },
18
- "traceLogPath": {
19
- "type": "string",
20
- "description": "Optional trace log path. Relative paths are resolved from the workspace."
21
- },
22
- "canonicalMemoryRoot": {
23
- "type": "string",
24
- "description": "Root directory for canonical timeline daily logs. Relative paths are resolved from the workspace."
25
- },
26
- "reasonerTimeoutMs": {
27
- "type": "integer",
28
- "default": 90000,
29
- "description": "Timeout for the internal timeline reasoner subagent, in milliseconds."
30
- },
31
- "reasonerSessionPrefix": {
32
- "type": "string",
33
- "default": "timeline-reasoner",
34
- "description": "Session key prefix used for the internal timeline reasoner subagent."
35
- },
36
- "reasonerMessageLimit": {
37
- "type": "integer",
38
- "default": 24,
39
- "description": "Maximum number of messages retained when reading the internal reasoner transcript."
40
- },
41
- "sessionHistoryLimit": {
42
- "type": "integer",
43
- "default": 12,
44
- "description": "Maximum number of current-session messages retained by the collector."
45
- },
46
- "memorySearchMaxResults": {
47
- "type": "integer",
48
- "default": 6,
49
- "description": "Maximum number of results requested when the collector calls OpenClaw memory_search."
50
- }
51
- },
52
- "additionalProperties": false
53
- }
54
- }
1
+ {
2
+ "id": "stella-timeline-plugin",
3
+ "name": "Stella Timeline Plugin",
4
+ "version": "2.0.0",
5
+ "description": "OpenClaw timeline runtime with canonical timeline_resolve, LLM-based temporal reasoning, and guarded append-only writes.",
6
+ "entry": "dist/index.js",
7
+ "skills": [
8
+ "skills/timeline"
9
+ ],
10
+ "configSchema": {
11
+ "type": "object",
12
+ "properties": {
13
+ "enableTrace": {
14
+ "type": "boolean",
15
+ "default": true,
16
+ "description": "Whether Timeline writes trace records for each runtime execution."
17
+ },
18
+ "traceLogPath": {
19
+ "type": "string",
20
+ "description": "Optional trace log path. Relative paths are resolved from the workspace."
21
+ },
22
+ "canonicalMemoryRoot": {
23
+ "type": "string",
24
+ "description": "Root directory for canonical timeline daily logs. Relative paths are resolved from the workspace."
25
+ },
26
+ "reasonerTimeoutMs": {
27
+ "type": "integer",
28
+ "default": 90000,
29
+ "description": "Timeout for the internal timeline reasoner subagent, in milliseconds."
30
+ },
31
+ "reasonerSessionPrefix": {
32
+ "type": "string",
33
+ "default": "timeline-reasoner",
34
+ "description": "Session key prefix used for the internal timeline reasoner subagent."
35
+ },
36
+ "reasonerMessageLimit": {
37
+ "type": "integer",
38
+ "default": 24,
39
+ "description": "Maximum number of messages retained when reading the internal reasoner transcript."
40
+ },
41
+ "sessionHistoryLimit": {
42
+ "type": "integer",
43
+ "default": 12,
44
+ "description": "Maximum number of current-session messages retained by the collector."
45
+ },
46
+ "memorySearchMaxResults": {
47
+ "type": "integer",
48
+ "default": 6,
49
+ "description": "Maximum number of results requested when the collector calls OpenClaw memory_search."
50
+ }
51
+ },
52
+ "additionalProperties": false
53
+ }
54
+ }
package/package.json CHANGED
@@ -1,73 +1,73 @@
1
- {
2
- "name": "stella-timeline-plugin",
3
- "version": "2.0.1",
4
- "description": "Native OpenClaw timeline plugin with a canonical timeline_resolve tool, bundled skill routing, and guarded append-only writes.",
5
- "keywords": [
6
- "openclaw",
7
- "skill",
8
- "timeline",
9
- "memory",
10
- "ai-agent",
11
- "episode",
12
- "persona"
13
- ],
14
- "author": "tao.zang",
15
- "license": "MIT-0",
16
- "repository": {
17
- "type": "git",
18
- "url": "https://github.com/tower1229/Her"
19
- },
20
- "homepage": "https://github.com/tower1229/Her#readme",
21
- "bugs": {
22
- "url": "https://github.com/tower1229/Her/issues"
23
- },
24
- "engines": {
25
- "node": ">=22.0.0"
26
- },
27
- "scripts": {
28
- "prebuild": "node -e \"require('fs').rmSync('dist', { recursive: true, force: true })\"",
29
- "build": "tsc -p tsconfig.build.json",
30
- "typecheck": "tsc --noEmit",
31
- "test": "node node_modules/jest/bin/jest.js --runInBand",
32
- "test:unit": "node node_modules/jest/bin/jest.js --runInBand",
33
- "test:smoke": "node ./scripts/run-openclaw-smoke.mjs",
34
- "test:live-experience": "node ./scripts/run-openclaw-live-e2e.mjs",
35
- "migrate:memory": "node ./scripts/migrate-existing-memory.mjs --apply",
36
- "setup:workspace": "node ./scripts/setup-openclaw-workspace.mjs",
37
- "doctor:workspace": "node ./scripts/doctor-openclaw-workspace.mjs",
38
- "verify": "npm run typecheck && npm run build && npm run test:unit",
39
- "pack:plugin": "npm pack",
40
- "release": "node ./scripts/release.mjs"
41
- },
42
- "bin": {
43
- "openclaw-timeline-setup": "./bin/openclaw-timeline-setup.mjs",
44
- "openclaw-timeline-doctor": "./bin/openclaw-timeline-doctor.mjs"
45
- },
46
- "publishConfig": {
47
- "access": "public"
48
- },
49
- "devDependencies": {
50
- "@types/jest": "^30.0.0",
51
- "@types/node": "^20.x",
52
- "jest": "^29.x",
53
- "ts-jest": "^29.x",
54
- "typescript": "^5.x"
55
- },
56
- "main": "dist/index.js",
57
- "files": [
58
- "dist",
59
- "bin",
60
- "scripts",
61
- "templates",
62
- "skills",
63
- "openclaw.plugin.json",
64
- "LICENSE",
65
- "README.md",
66
- "README_ZH.md"
67
- ],
68
- "openclaw": {
69
- "extensions": [
70
- "./dist/index.js"
71
- ]
72
- }
1
+ {
2
+ "name": "stella-timeline-plugin",
3
+ "version": "2.0.3",
4
+ "description": "Native OpenClaw timeline plugin with a canonical timeline_resolve tool, bundled skill routing, and guarded append-only writes.",
5
+ "keywords": [
6
+ "openclaw",
7
+ "skill",
8
+ "timeline",
9
+ "memory",
10
+ "ai-agent",
11
+ "episode",
12
+ "persona"
13
+ ],
14
+ "author": "tao.zang",
15
+ "license": "MIT-0",
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "https://github.com/tower1229/Her"
19
+ },
20
+ "homepage": "https://github.com/tower1229/Her#readme",
21
+ "bugs": {
22
+ "url": "https://github.com/tower1229/Her/issues"
23
+ },
24
+ "engines": {
25
+ "node": ">=22.0.0"
26
+ },
27
+ "scripts": {
28
+ "prebuild": "node -e \"require('fs').rmSync('dist', { recursive: true, force: true })\"",
29
+ "build": "tsc -p tsconfig.build.json",
30
+ "typecheck": "tsc --noEmit",
31
+ "test": "node node_modules/jest/bin/jest.js --runInBand",
32
+ "test:unit": "node node_modules/jest/bin/jest.js --runInBand",
33
+ "test:smoke": "node ./scripts/run-openclaw-smoke.mjs",
34
+ "test:live-experience": "node ./scripts/run-openclaw-live-e2e.mjs",
35
+ "migrate:memory": "node ./scripts/migrate-existing-memory.mjs --apply",
36
+ "setup:workspace": "node ./scripts/setup-openclaw-workspace.mjs",
37
+ "doctor:workspace": "node ./scripts/doctor-openclaw-workspace.mjs",
38
+ "verify": "npm run typecheck && npm run build && npm run test:unit",
39
+ "pack:plugin": "npm pack",
40
+ "release": "node ./scripts/release.mjs"
41
+ },
42
+ "bin": {
43
+ "openclaw-timeline-setup": "./bin/openclaw-timeline-setup.mjs",
44
+ "openclaw-timeline-doctor": "./bin/openclaw-timeline-doctor.mjs"
45
+ },
46
+ "publishConfig": {
47
+ "access": "public"
48
+ },
49
+ "devDependencies": {
50
+ "@types/jest": "^30.0.0",
51
+ "@types/node": "^20.x",
52
+ "jest": "^29.x",
53
+ "ts-jest": "^29.x",
54
+ "typescript": "^5.x"
55
+ },
56
+ "main": "dist/index.js",
57
+ "files": [
58
+ "dist",
59
+ "bin",
60
+ "scripts",
61
+ "templates",
62
+ "skills",
63
+ "openclaw.plugin.json",
64
+ "LICENSE",
65
+ "README.md",
66
+ "README_ZH.md"
67
+ ],
68
+ "openclaw": {
69
+ "extensions": [
70
+ "./dist/index.js"
71
+ ]
72
+ }
73
73
  }
@@ -1,94 +1,94 @@
1
- #!/usr/bin/env node
2
- import fs from 'node:fs';
3
- import path from 'node:path';
4
- import {
5
- detectAgentsContract,
6
- detectSoulContract,
7
- normalizeRootName,
8
- resolveCanonicalRootPath,
9
- } from './workspace-contract.mjs';
10
-
11
- function parseArgs(argv) {
12
- const options = {
13
- workspace: path.resolve(process.cwd()),
14
- canonicalRootName: 'memory',
15
- };
16
-
17
- for (let i = 0; i < argv.length; i += 1) {
18
- const arg = argv[i];
19
- if (arg === '--workspace') {
20
- options.workspace = path.resolve(argv[++i] || '');
21
- continue;
22
- }
23
- if (arg === '--canonical-root-name') {
24
- options.canonicalRootName = normalizeRootName(argv[++i] || '');
25
- continue;
26
- }
27
- if (arg === '--help' || arg === '-h') {
28
- printHelp();
29
- process.exit(0);
30
- }
31
- throw new Error(`Unknown argument: ${arg}`);
32
- }
33
-
34
- return options;
35
- }
36
-
37
- function printHelp() {
38
- console.log([
39
- 'Usage: openclaw-timeline-doctor [--workspace <dir>] [--canonical-root-name <name>]',
40
- '',
41
- 'Checks whether the required Timeline workspace contracts are present.',
42
- ].join('\n'));
43
- }
44
-
45
- function readText(filePath) {
46
- return fs.existsSync(filePath) ? fs.readFileSync(filePath, 'utf8') : '';
47
- }
48
-
49
- function check(label, passed, successDetail, failureDetail) {
50
- const prefix = passed ? '[ok]' : '[missing]';
51
- console.log(`${prefix} ${label}: ${passed ? successDetail : failureDetail}`);
52
- return passed;
53
- }
54
-
55
- function main() {
56
- const options = parseArgs(process.argv.slice(2));
57
- const agentsPath = path.join(options.workspace, 'AGENTS.md');
58
- const soulPath = path.join(options.workspace, 'SOUL.md');
59
- const canonicalRootPath = resolveCanonicalRootPath(options.workspace, options.canonicalRootName);
60
-
61
- const agentsContent = readText(agentsPath);
62
- const soulContent = readText(soulPath);
63
-
64
- let ok = true;
65
- ok = check(
66
- 'AGENTS contract',
67
- fs.existsSync(agentsPath) && detectAgentsContract(agentsContent),
68
- agentsPath,
69
- `${agentsPath} is missing the Timeline daily-log contract`,
70
- ) && ok;
71
- ok = check(
72
- 'SOUL contract',
73
- fs.existsSync(soulPath) && detectSoulContract(soulContent),
74
- soulPath,
75
- `${soulPath} is missing the Timeline recall contract`,
76
- ) && ok;
77
- ok = check(
78
- 'Canonical memory root',
79
- fs.existsSync(canonicalRootPath),
80
- canonicalRootPath,
81
- `${canonicalRootPath} does not exist`,
82
- ) && ok;
83
-
84
- if (!ok) {
85
- process.exitCode = 1;
86
- }
87
- }
88
-
89
- try {
90
- main();
91
- } catch (error) {
92
- console.error(error instanceof Error ? error.message : String(error));
93
- process.exit(1);
94
- }
1
+ #!/usr/bin/env node
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+ import {
5
+ detectAgentsContract,
6
+ detectSoulContract,
7
+ normalizeRootName,
8
+ resolveCanonicalRootPath,
9
+ } from './workspace-contract.mjs';
10
+
11
+ function parseArgs(argv) {
12
+ const options = {
13
+ workspace: path.resolve(process.cwd()),
14
+ canonicalRootName: 'memory',
15
+ };
16
+
17
+ for (let i = 0; i < argv.length; i += 1) {
18
+ const arg = argv[i];
19
+ if (arg === '--workspace') {
20
+ options.workspace = path.resolve(argv[++i] || '');
21
+ continue;
22
+ }
23
+ if (arg === '--canonical-root-name') {
24
+ options.canonicalRootName = normalizeRootName(argv[++i] || '');
25
+ continue;
26
+ }
27
+ if (arg === '--help' || arg === '-h') {
28
+ printHelp();
29
+ process.exit(0);
30
+ }
31
+ throw new Error(`Unknown argument: ${arg}`);
32
+ }
33
+
34
+ return options;
35
+ }
36
+
37
+ function printHelp() {
38
+ console.log([
39
+ 'Usage: openclaw-timeline-doctor [--workspace <dir>] [--canonical-root-name <name>]',
40
+ '',
41
+ 'Checks whether the required Timeline workspace contracts are present.',
42
+ ].join('\n'));
43
+ }
44
+
45
+ function readText(filePath) {
46
+ return fs.existsSync(filePath) ? fs.readFileSync(filePath, 'utf8') : '';
47
+ }
48
+
49
+ function check(label, passed, successDetail, failureDetail) {
50
+ const prefix = passed ? '[ok]' : '[missing]';
51
+ console.log(`${prefix} ${label}: ${passed ? successDetail : failureDetail}`);
52
+ return passed;
53
+ }
54
+
55
+ function main() {
56
+ const options = parseArgs(process.argv.slice(2));
57
+ const agentsPath = path.join(options.workspace, 'AGENTS.md');
58
+ const soulPath = path.join(options.workspace, 'SOUL.md');
59
+ const canonicalRootPath = resolveCanonicalRootPath(options.workspace, options.canonicalRootName);
60
+
61
+ const agentsContent = readText(agentsPath);
62
+ const soulContent = readText(soulPath);
63
+
64
+ let ok = true;
65
+ ok = check(
66
+ 'AGENTS contract',
67
+ fs.existsSync(agentsPath) && detectAgentsContract(agentsContent),
68
+ agentsPath,
69
+ `${agentsPath} is missing the Timeline daily-log contract`,
70
+ ) && ok;
71
+ ok = check(
72
+ 'SOUL contract',
73
+ fs.existsSync(soulPath) && detectSoulContract(soulContent),
74
+ soulPath,
75
+ `${soulPath} is missing the Timeline recall contract`,
76
+ ) && ok;
77
+ ok = check(
78
+ 'Canonical memory root',
79
+ fs.existsSync(canonicalRootPath),
80
+ canonicalRootPath,
81
+ `${canonicalRootPath} does not exist`,
82
+ ) && ok;
83
+
84
+ if (!ok) {
85
+ process.exitCode = 1;
86
+ }
87
+ }
88
+
89
+ try {
90
+ main();
91
+ } catch (error) {
92
+ console.error(error instanceof Error ? error.message : String(error));
93
+ process.exit(1);
94
+ }