oh-my-knowledge 0.51.2 → 0.52.0

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.
Files changed (49) hide show
  1. package/README.md +27 -6
  2. package/README.zh.md +27 -6
  3. package/dist/assets/agent-skills/omk/SKILL.md +8 -8
  4. package/dist/observability/codex-conversation-index.d.ts +88 -0
  5. package/dist/observability/codex-conversation-index.js +566 -0
  6. package/dist/observability/codex-protocol.d.ts +12 -0
  7. package/dist/observability/codex-protocol.js +78 -0
  8. package/dist/observability/codex-tool-status.d.ts +16 -0
  9. package/dist/observability/codex-tool-status.js +114 -0
  10. package/dist/observability/codex-trace-adapter.js +342 -119
  11. package/dist/observability/conversation-catalog.d.ts +38 -0
  12. package/dist/observability/conversation-catalog.js +573 -0
  13. package/dist/observability/conversation-index-process.d.ts +1 -0
  14. package/dist/observability/conversation-index-process.js +31 -0
  15. package/dist/observability/conversation-view-model.d.ts +5 -0
  16. package/dist/observability/conversation-view-model.js +100 -0
  17. package/dist/observability/experience.d.ts +3 -1
  18. package/dist/observability/experience.js +248 -7
  19. package/dist/observability/inbox.js +40 -2
  20. package/dist/observability/knowledge-debugger.d.ts +4 -0
  21. package/dist/observability/knowledge-debugger.js +364 -0
  22. package/dist/observability/polling-subscription-hub.d.ts +27 -0
  23. package/dist/observability/polling-subscription-hub.js +149 -0
  24. package/dist/observability/source-record-archive.d.ts +13 -0
  25. package/dist/observability/source-record-archive.js +324 -0
  26. package/dist/observability/task-window.d.ts +8 -0
  27. package/dist/observability/task-window.js +36 -0
  28. package/dist/observability/trace-ir.d.ts +66 -1
  29. package/dist/observability/trace-source.d.ts +1 -0
  30. package/dist/observability/trace-source.js +12 -5
  31. package/dist/observability/turn-index.d.ts +3 -0
  32. package/dist/observability/turn-index.js +251 -0
  33. package/dist/renderer/conversation-renderer.d.ts +9 -0
  34. package/dist/renderer/conversation-renderer.js +410 -0
  35. package/dist/renderer/icons.js +1 -0
  36. package/dist/renderer/inline-markdown.d.ts +6 -0
  37. package/dist/renderer/inline-markdown.js +158 -0
  38. package/dist/renderer/knowledge-debugger-renderer.d.ts +9 -0
  39. package/dist/renderer/knowledge-debugger-renderer.js +2280 -0
  40. package/dist/renderer/observation-inbox-renderer.js +9 -0
  41. package/dist/renderer/skill-list-renderer.js +2 -1
  42. package/dist/renderer/trajectory-live.d.ts +42 -0
  43. package/dist/renderer/trajectory-live.js +258 -0
  44. package/dist/renderer/trajectory-routing.d.ts +60 -0
  45. package/dist/renderer/trajectory-routing.js +351 -0
  46. package/dist/server/report-server.d.ts +4 -1
  47. package/dist/server/report-server.js +274 -6
  48. package/dist/types/observability.d.ts +225 -1
  49. package/package.json +8 -5
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # oh-my-knowledge
1
+ # OMK
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/oh-my-knowledge.svg)](https://www.npmjs.com/package/oh-my-knowledge)
4
4
  [![npm weekly downloads](https://img.shields.io/npm/dw/oh-my-knowledge.svg)](https://www.npmjs.com/package/oh-my-knowledge)
@@ -8,14 +8,19 @@
8
8
 
9
9
  **English** | [简体中文](./README.zh.md)
10
10
 
11
- **Stop editing LLM knowledge inputs by gut feel.**
12
- `oh-my-knowledge` (omk) is a measurement workflow for prompts, RAG context, skills, agents, and workflows. It fixes the executor model and the evaluation samples, changes only the knowledge artifact, then answers the release question that matters: **can v2 ship, and where is it better?**
11
+ **Observe. Measure. Know.**
12
+
13
+ **OMK makes every knowledge change in your AI application evidence-backed.**
14
+
15
+ Observe real-world performance, measure version differences, and determine whether the change is effective and the version is ready to ship.
16
+
17
+ **Same model. Same evaluation samples. Only the knowledge artifact changes.**
13
18
 
14
19
  ![omk knowledge artifact evaluation flow: doctor / eval / observe / sample / evolve loop](./docs/public/omk-knowledge-flow-en-animated.gif)
15
20
 
16
21
  📖 **Full documentation: [oh-my-knowledge.pages.dev](https://oh-my-knowledge.pages.dev)** (searchable, English / 简体中文)
17
22
 
18
- ## What omk makes measurable
23
+ ## What OMK helps you know
19
24
 
20
25
  | Decision | Command | Evidence you get |
21
26
  |---|---|---|
@@ -23,6 +28,7 @@
23
28
  | Is v2 actually better than v1? | `omk eval` | one-line verdict, confidence interval, failed samples, cost |
24
29
  | Why did it pass or fail? | `omk studio` | report view with scores, diagnostics, and examples |
25
30
  | Should this version become the accepted one? | `omk promote` / `omk evolve` | evidence-gated accept or generate a better candidate |
31
+ | What happened during one real AI task? | `omk observe` / Studio Task Trajectory | a trace-backed view of the request, visible Knowledge, tool calls, results, response, and user correction |
26
32
  | What did real usage expose? | `omk observe` / `omk sample --from-traces` | production gaps drafted for review; reviewed drafts can become eval samples |
27
33
 
28
34
  ![omk report — verdict pill "v2 is clearly better than v1 — ready to ship"](./assets/screenshots/report-overview.png)
@@ -57,9 +63,23 @@ Walkthrough: [5-minute quickstart guide](docs/quickstart-skill-eval.md) (recomme
57
63
 
58
64
  Deeper: [who omk is for](docs/explanation/who-omk-is-for.md) · [CLI reference](docs/reference/cli.md) · [how it works](docs/explanation/architecture.md) · [eval sample format](docs/reference/eval-sample-format.md) · [executors](docs/reference/executors.md) · [artifact layout](docs/reference/artifact-layout.md)
59
65
 
60
- ## The omk loop
66
+ ## Inspect one Codex task
67
+
68
+ If you only want to see what happened behind one Codex conversation, you do not need to run `observe ingest` first:
69
+
70
+ ```bash
71
+ omk studio
72
+ ```
73
+
74
+ Studio opens the local Codex conversation overview at `http://127.0.0.1:7799` by default. Select a conversation, then a task, to open **Task Trajectory**. Its four lanes — **Conversation, Actions, Results, and Knowledge** — show the request, AI responses, tool calls, tool returns, and observable context, with drill-downs into normalized events and raw logs.
75
+
76
+ Running tasks are prioritized and update live. While **Following**, the trajectory advances smoothly as events arrive; after you inspect an earlier point, Studio keeps your position and offers **View updates**. Old logs without a terminal event are marked **End status not recorded** instead of remaining live forever.
77
+
78
+ Task Trajectory only reconstructs facts observable in the log. It does not reveal or infer hidden reasoning. See [Observe production traces](docs/guides/observe-production.md#inspect-one-task) for the full model.
79
+
80
+ ## The OMK loop
61
81
 
62
- omk is for authors and maintainers of LLM knowledge artifacts who need a release decision, not for passive end-users of a skill. The main loop is deliberately controlled:
82
+ OMK is for authors and maintainers of LLM knowledge artifacts who need a release decision, not for passive end-users of a skill. The main loop is deliberately controlled:
63
83
 
64
84
  ```text
65
85
  change a prompt / RAG / skill / agent artifact
@@ -166,6 +186,7 @@ The full docs are published at **[oh-my-knowledge.pages.dev](https://oh-my-knowl
166
186
  - **[CLI reference](docs/reference/cli.md)** — all top-level commands with bash examples and flag tables
167
187
  - **[Executors](docs/reference/executors.md)** & **[artifact layout](docs/reference/artifact-layout.md)** — built-in / custom executors; how `variant` resolves to an artifact + runtime context
168
188
  - **[How-to guides](docs/guides/agent-eval.md)** — [evaluate an agent](docs/guides/agent-eval.md) (project runtime context) and [use non-Claude models](docs/guides/non-claude-models.md) (GLM / Qwen / DeepSeek / Moonshot / Ollama)
189
+ - **[Observe & inspect task trajectories](docs/guides/observe-production.md)** — browse local Codex conversations, drill into one task, and follow its observable execution live
169
190
  - **[Quickstart](docs/quickstart-skill-eval.md)** — first-time five-minute walkthrough
170
191
  - **[Example gallery](https://github.com/lizhiyao/oh-my-knowledge/tree/main/examples)** — a set of runnable examples in the repo, arranged simplest-to-richest
171
192
  - **[Sample design spec](docs/specs/sample-design-spec.md)** — capability / construct / provenance metadata; industry-gap mapping
package/README.zh.md CHANGED
@@ -1,4 +1,4 @@
1
- # oh-my-knowledge
1
+ # OMK
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/oh-my-knowledge.svg)](https://www.npmjs.com/package/oh-my-knowledge)
4
4
  [![npm weekly downloads](https://img.shields.io/npm/dw/oh-my-knowledge.svg)](https://www.npmjs.com/package/oh-my-knowledge)
@@ -8,14 +8,19 @@
8
8
 
9
9
  [English](./README.md) | **简体中文**
10
10
 
11
- **别再凭感觉改 LLM 知识输入。**
12
- `oh-my-knowledge`(omk)是一套面向 prompt、RAG、skill、agent、workflow 的测量工作流。它固定执行模型和评测用例,只改变知识载体,然后回答发布时真正要追问的问题:**v2 能不能发,好在哪里?**
11
+ **Observe. Measure. Know.**
12
+
13
+ **OMK,让 AI 应用的知识改动有据可依。**
14
+
15
+ 观测真实表现,量出版本差异,判断改动是否有效、版本能否发布。
16
+
17
+ **相同模型,相同评测用例,只改变知识载体。**
13
18
 
14
19
  ![omk 知识载体评测流程:doctor / eval / observe / sample / evolve 闭环](./docs/public/omk-knowledge-flow-animated.gif)
15
20
 
16
21
  📖 **完整文档:[oh-my-knowledge.pages.dev/zh](https://oh-my-knowledge.pages.dev/zh/)**(可搜索,可切换英文)
17
22
 
18
- ## omk 让什么变得可测量
23
+ ## OMK 让你知道什么
19
24
 
20
25
  | 决策问题 | 命令 | 你会得到的证据 |
21
26
  |------|------|------|
@@ -23,6 +28,7 @@
23
28
  | v2 是否真的优于 v1? | `omk eval` | 一行 verdict、置信区间、失败样本、成本 |
24
29
  | 它为什么通过或失败? | `omk studio` | 分数、诊断、样本证据的报告视图 |
25
30
  | 这个版本是否应成为接受版本? | `omk promote` / `omk evolve` | 基于证据接受,或生成更好的候选版 |
31
+ | 一次真实 AI 任务中发生了什么? | `omk observe` / Studio 任务轨迹 | 请求、可见知识、工具调用与结果、回答和用户纠正的可核验轨迹 |
26
32
  | 真实使用暴露了哪些知识缺口? | `omk observe` / `omk sample --from-traces` | 将线上缺口生成待复核草稿,复核后再沉淀为评测样本 |
27
33
 
28
34
  ![omk 报告 — verdict pill「v2 明显优于 v1,可以发布」](./assets/screenshots/report-overview-zh.png)
@@ -57,9 +63,23 @@ export OMK_EXECUTOR=codex
57
63
 
58
64
  深入:[为谁、解决什么](docs/zh/explanation/who-omk-is-for.md) · [CLI 参考](docs/zh/reference/cli.md) · [工作原理](docs/zh/explanation/architecture.md) · [评测用例格式](docs/zh/reference/eval-sample-format.md) · [执行器](docs/zh/reference/executors.md) · [知识载体布局](docs/zh/reference/artifact-layout.md)
59
65
 
60
- ## omk 的闭环
66
+ ## 先看清一次 Codex 任务
67
+
68
+ 只想知道一次 Codex 对话背后发生了什么,不需要先运行 `observe ingest`:
69
+
70
+ ```bash
71
+ omk studio
72
+ ```
73
+
74
+ Studio 默认在 `http://127.0.0.1:7799` 打开本机 Codex 对话总览。先选择一段对话,再选择其中一次任务,即可进入「任务轨迹」:按**对话、执行、结果、知识**四条泳道查看请求、AI 回答、工具调用、工具返回和可见上下文,并可下钻到规范化事件与原始日志。
75
+
76
+ 进行中的任务会优先显示并实时更新。保持「跟随中」时,轨迹会随新事件平滑前进;手动查看历史位置后,页面保留当前位置并提示「查看更新」。旧日志如果没有记录结束事件,会标记为「未记录结束状态」,不会一直冒充进行中。
77
+
78
+ 任务轨迹只还原日志中可观测的事实,不展示或推断隐藏思维。完整说明见[观测与任务轨迹](docs/zh/guides/observe-production.md#查看一次任务)。
79
+
80
+ ## OMK 的闭环
61
81
 
62
- omk 主要给 LLM 知识载体的作者 / 维护者用,帮他们做发布判断;它不是给被动安装 skill 的普通使用者用的。主流程刻意保持受控:
82
+ OMK 主要给 LLM 知识载体的作者 / 维护者用,帮他们做发布判断;它不是给被动安装 skill 的普通使用者用的。主流程刻意保持受控:
63
83
 
64
84
  ```text
65
85
  改了一份 prompt / RAG / skill / agent 知识载体
@@ -166,6 +186,7 @@ RAG 专项评测请看 RAGAS(独立 niche,跟 omk 互补)。完整对比
166
186
  - **[CLI 参考](docs/zh/reference/cli.md)** —— 顶层命令的 bash 示例和 flag 表
167
187
  - **[执行器](docs/zh/reference/executors.md)** & **[知识载体布局](docs/zh/reference/artifact-layout.md)** —— 内置 / 自定义执行器;variant 如何解析为 artifact + runtime context
168
188
  - **[操作指南](docs/zh/guides/agent-eval.md)** —— [评测 agent](docs/zh/guides/agent-eval.md)(项目 runtime context)与[使用非 Claude 模型](docs/zh/guides/non-claude-models.md)(GLM / 通义 / DeepSeek / Moonshot / Ollama)
189
+ - **[观测与任务轨迹](docs/zh/guides/observe-production.md)** —— 浏览本机 Codex 对话,下钻一次任务,并实时跟随可观测执行过程
169
190
  - **[快速上手](docs/zh/quickstart-skill-eval.md)** —— 第一次跑评测的 5 分钟教程
170
191
  - **[示例画廊](https://github.com/lizhiyao/oh-my-knowledge/tree/main/examples)** —— 仓库里一组可直接跑的示例,按由简到全排成上手路径
171
192
  - **[用例设计规范](docs/zh/specs/sample-design-spec.md)** —— capability / construct / provenance 元数据;行业 gap 映射
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  name: omk
3
3
  description: |
4
- oh-my-knowledge 知识载体评测工具的智能代理。评测 skill(系统提示词)质量,对比不同版本效果,自动迭代改进。
4
+ OMK(Observe. Measure. Know.)让 AI 应用的知识改动有据可依。观测真实表现,受控测量 prompt / RAG / skill / agent / workflow 的版本差异,判断改动是否有效、版本能否发布,并支持自动迭代改进。
5
5
  Use when: 用户提到"评测"、"测评"、"eval"、"benchmark"、"对比 skill"、"改进 skill"、"evolve"、"生成测试用例"、"gen-samples"、"omk"。
6
6
  user-invocable: true
7
7
  argument-hint: "<doctor|eval|evolve|init|install|list|observe|promote|rollback|sample|studio> [options]"
8
8
  ---
9
9
 
10
- # OMK — 知识载体评测
10
+ # OMK — Observe. Measure. Know.
11
11
 
12
- 你是 oh-my-knowledge(omk)的智能代理。帮助用户评测、对比、改进 AI skill(系统提示词),用数据说话。
12
+ 你是 OMK 的智能代理。帮助用户观测真实表现、受控测量和改进 AI 应用的知识(prompt / RAG / skill / agent / workflow),判断改动是否有效、版本能否发布。
13
13
 
14
14
  ## 第一步:检查环境
15
15
 
@@ -37,7 +37,7 @@ Codex 是 omk 的一等 runtime。运行在 Codex 任务中时,`omk eval` / `d
37
37
  | 改进 / 优化 skill | → `omk evolve`(自动多轮迭代) |
38
38
  | 生成测试用例 | → `omk sample` |
39
39
  | 体检 skill 写法 | → `omk doctor` |
40
- | 查看 / 浏览报告 | → `omk studio`(启动本地报告浏览器) |
40
+ | 浏览对话、任务轨迹与报告 | → `omk studio`(启动本地知识工作台) |
41
41
  | 看真实使用 trace | → `omk observe` |
42
42
  | 查看受管 skill 状态 | → `omk list` |
43
43
  | 按证据接受 / 回退某版本 | → `omk promote` / `omk rollback` |
@@ -138,7 +138,7 @@ omk observe ingest ~/.codex/sessions
138
138
  omk observe ~/.claude/projects/<project> --last 7d
139
139
  ```
140
140
 
141
- Codex rollout 会保留 `sourceKind=codex`、模型、父子任务、tool call 和 token 证据,并从实际读取的 `skills/<name>/SKILL.md` 归因 skill。`observe ingest` 生成待复核 observation;确认真实知识缺口后,再用 `omk sample --from-traces` 草拟评测用例。
141
+ Codex rollout 会保留 `sourceKind=codex`、模型、父子任务、tool call 和 token 证据,并从实际读取的 `skills/<name>/SKILL.md` 归因 skill。`omk studio` 无需先 ingest,即可从本机 Codex 对话总览进入某次任务的实时轨迹;`observe ingest` 只在需要生成待复核 observation 时运行。任务轨迹按对话、执行、结果和知识呈现结构化事实,并联动检查配对后的工具调用与结果、AI 回答和用户纠正。该页面只呈现 trace 中可观测的执行过程,不推断隐藏思维或失败根因。确认真实知识缺口后,再用 `omk sample --from-traces` 草拟评测用例。
142
142
 
143
143
  ### 体检 skill 写法
144
144
 
@@ -155,16 +155,16 @@ omk doctor skills/my-skill.md
155
155
 
156
156
  `omk eval` 默认会先跑一次 doctor 当 preflight 门禁,所以一般不用单独跑;想在 eval 之前先把结构问题先扫一遍再跑评测,就单独跑 `omk doctor`。
157
157
 
158
- ### 查看 / 浏览报告
158
+ ### 浏览对话、任务轨迹与报告
159
159
 
160
160
  ```bash
161
- omk studio # 启动本地 web 报告浏览器
161
+ omk studio # 启动本地知识工作台(默认端口 7799)
162
162
  omk studio --port 8080 # 改端口
163
163
  omk studio --host 0.0.0.0 # 局域网访问(默认 127.0.0.1)
164
164
  omk studio --no-open # 不自动开浏览器
165
165
  ```
166
166
 
167
- Studio skill-centric:列表页(`/`)按 skill 卡片展示健康等级 / 0-100 参考分 / 待优化数 / 趋势;详情页(`/skills/<name>`)左栏列关键问题清单,右栏画健康趋势 + 三档阶段卡(doctor / eval / observe)。访问 `/observe-inbox` 查看 observe inbox 看板。
167
+ Studio 首页直接索引本机 Codex 对话。先选择对话,再选择任务查看四泳道任务轨迹;进行中的任务支持实时跟随。顶部「知识载体」入口用于浏览 doctor / eval / observe 报告,`/observe-inbox` 用于复核 observation。无需为了浏览本机 Codex 对话而先运行 `omk observe ingest`。
168
168
 
169
169
  ## 第五步:解读结果
170
170
 
@@ -0,0 +1,88 @@
1
+ import type { ExperienceTurnStatus } from '../types/index.js';
2
+ import type { TraceToolStatus } from './trace-ir.js';
3
+ export interface CodexIndexedTask {
4
+ turnId: string;
5
+ title: string;
6
+ startTimestamp?: string;
7
+ endTimestamp?: string;
8
+ status: ExperienceTurnStatus;
9
+ sourceRecordCount: number;
10
+ toolCallCount: number;
11
+ toolFailureCount: number;
12
+ startOffset: number;
13
+ endOffset: number;
14
+ startLine: number;
15
+ endLine: number;
16
+ }
17
+ export interface CodexRolloutIndex {
18
+ schemaVersion: 11;
19
+ sourcePath: string;
20
+ /** File size observed when the index was produced. */
21
+ sourceSize: number;
22
+ sourceMtimeMs: number;
23
+ /** Byte boundary after the last complete JSONL record. */
24
+ indexedSize: number;
25
+ /** Physical line number at indexedSize, including blank lines. */
26
+ indexedLineCount: number;
27
+ /** Whether indexedSize is immediately after a newline delimiter. */
28
+ indexedEndsWithNewline: boolean;
29
+ sourceThreadId: string;
30
+ sessionMeta?: unknown;
31
+ sessionMetaLine?: number;
32
+ tasks: CodexIndexedTask[];
33
+ /** Incremental matcher state for the final unclosed task only. */
34
+ activeToolOutcomeState?: CodexActiveToolOutcomeState;
35
+ sourceRecordCount: number;
36
+ malformedRecordCount: number;
37
+ }
38
+ export interface CodexActiveToolOutcomeState {
39
+ callOccurrences: Array<[string, number]>;
40
+ resultOccurrences: Array<[string, number]>;
41
+ runtimeOccurrences: Array<[string, number]>;
42
+ outcomes: Array<[string, IndexedToolOutcome]>;
43
+ }
44
+ interface IndexedToolOutcome {
45
+ outputStatus?: TraceToolStatus;
46
+ runtimeStatus?: TraceToolStatus;
47
+ }
48
+ export interface CodexJsonlLine {
49
+ text: string;
50
+ line: number;
51
+ startOffset: number;
52
+ endOffset: number;
53
+ }
54
+ /**
55
+ * Build a compact byte-range index without retaining the rollout. Only records
56
+ * needed for turn boundaries and list metrics are parsed.
57
+ */
58
+ export declare function buildCodexRolloutIndex(sourcePath: string, sourceThreadId: string): CodexRolloutIndex;
59
+ /**
60
+ * Extend an append-only rollout index from its last byte boundary. If the
61
+ * source was replaced or truncated, rebuild so callers never observe a mixed
62
+ * index from two different files.
63
+ */
64
+ export declare function extendCodexRolloutIndex(sourcePath: string, sourceThreadId: string, previous: CodexRolloutIndex): CodexRolloutIndex;
65
+ /**
66
+ * Catch an append-only rollout up to a snapshot that is still current after
67
+ * indexing. Returning a stale prefix here would violate current-read callers.
68
+ */
69
+ export declare function synchronizeCurrentCodexRolloutIndex(sourcePath: string, sourceThreadId: string, initial?: CodexRolloutIndex): CodexRolloutIndex;
70
+ /**
71
+ * A single Codex rollout is sequential: once a newer task starts, an older
72
+ * task without a terminal record can no longer be live. Normalize historical
73
+ * caches in memory so an omitted task_complete never becomes a permanent
74
+ * "running" conversation.
75
+ */
76
+ export declare function normalizeCodexRolloutIndex(index: CodexRolloutIndex): CodexRolloutIndex;
77
+ export declare function isCurrentCodexRolloutIndex(value: unknown, sourcePath: string): value is CodexRolloutIndex;
78
+ /**
79
+ * Codex rollouts are append-only while a conversation is active. A prefix
80
+ * index remains internally consistent even after newer records are appended.
81
+ */
82
+ export declare function isReusableCodexRolloutIndex(value: unknown, sourcePath: string): value is CodexRolloutIndex;
83
+ export declare function readCodexTaskRecords(index: CodexRolloutIndex, task: CodexIndexedTask): {
84
+ records: Array<unknown | undefined>;
85
+ lines: CodexJsonlLine[];
86
+ malformedRecordCount: number;
87
+ };
88
+ export {};