oh-my-knowledge 0.48.0 → 0.49.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 (243) hide show
  1. package/README.md +50 -18
  2. package/README.zh.md +55 -23
  3. package/dist/analysis/coverage-analyzer.d.ts +1 -0
  4. package/dist/analysis/coverage-analyzer.js +125 -62
  5. package/dist/analysis/failure-clusterer.js +2 -1
  6. package/dist/analysis/gap-analyzer.d.ts +2 -2
  7. package/dist/analysis/gap-analyzer.js +13 -3
  8. package/dist/analysis/hedging-classifier.d.ts +2 -2
  9. package/dist/analysis/hedging-classifier.js +3 -4
  10. package/dist/analysis/report-diagnostics.js +9 -7
  11. package/dist/analysis/sample-diagnostics.js +6 -6
  12. package/dist/artifact-graph/doctor.js +15 -7
  13. package/dist/assets/agent-skills/omk/SKILL.md +27 -7
  14. package/dist/assets/agent-skills/omk/references/commands.md +18 -17
  15. package/dist/authoring/evolver.d.ts +10 -6
  16. package/dist/authoring/evolver.js +496 -83
  17. package/dist/authoring/generator.d.ts +3 -3
  18. package/dist/authoring/generator.js +5 -10
  19. package/dist/authoring/sample-fixer.d.ts +8 -6
  20. package/dist/authoring/sample-fixer.js +76 -5
  21. package/dist/cli/commands/doctor.js +31 -14
  22. package/dist/cli/commands/eval/index.d.ts +3 -0
  23. package/dist/cli/commands/eval/index.js +163 -17
  24. package/dist/cli/commands/evolve.d.ts +4 -4
  25. package/dist/cli/commands/evolve.js +27 -13
  26. package/dist/cli/commands/init.js +16 -3
  27. package/dist/cli/commands/observe/inbox.js +28 -21
  28. package/dist/cli/commands/observe/index.js +20 -11
  29. package/dist/cli/commands/observe/ingest.d.ts +3 -0
  30. package/dist/cli/commands/observe/ingest.js +30 -2
  31. package/dist/cli/commands/sample.d.ts +6 -3
  32. package/dist/cli/commands/sample.js +72 -68
  33. package/dist/cli/lib/codex-model-hint.d.ts +9 -0
  34. package/dist/cli/lib/codex-model-hint.js +45 -0
  35. package/dist/cli/lib/generation-failure-hint.d.ts +2 -0
  36. package/dist/cli/lib/generation-failure-hint.js +61 -0
  37. package/dist/cli/lib/i18n-dict/common.d.ts +1 -1
  38. package/dist/cli/lib/i18n-dict/common.js +4 -0
  39. package/dist/cli/lib/i18n-dict/gen.d.ts +1 -1
  40. package/dist/cli/lib/i18n-dict/gen.js +38 -6
  41. package/dist/cli/lib/i18n-dict/help.js +6 -6
  42. package/dist/cli/lib/i18n-dict/init.d.ts +1 -1
  43. package/dist/cli/lib/i18n-dict/init.js +13 -9
  44. package/dist/cli/lib/i18n-dict/run.d.ts +1 -1
  45. package/dist/cli/lib/i18n-dict/run.js +34 -2
  46. package/dist/cli/lib/llm-failure-classifier.d.ts +2 -0
  47. package/dist/cli/lib/llm-failure-classifier.js +8 -0
  48. package/dist/cli/lib/parse-run-config.d.ts +6 -5
  49. package/dist/cli/lib/parse-run-config.js +16 -9
  50. package/dist/cli/lib/runtime-defaults.d.ts +21 -0
  51. package/dist/cli/lib/runtime-defaults.js +79 -0
  52. package/dist/diagnosis/observe-mapper.js +14 -15
  53. package/dist/diagnosis/observe-producer.js +3 -1
  54. package/dist/diagnosis/studio-projection.js +14 -7
  55. package/dist/diagnosis/types.d.ts +2 -0
  56. package/dist/diagnosis/types.js +12 -0
  57. package/dist/doctor/endpoint-rule.js +2 -1
  58. package/dist/eval-core/artifact-file-names.js +18 -1
  59. package/dist/eval-core/artifact-index.d.ts +7 -11
  60. package/dist/eval-core/artifact-index.js +139 -80
  61. package/dist/eval-core/cache.d.ts +12 -3
  62. package/dist/eval-core/cache.js +89 -29
  63. package/dist/eval-core/comparability.js +10 -6
  64. package/dist/eval-core/evaluation-execution.d.ts +2 -1
  65. package/dist/eval-core/evaluation-execution.js +122 -37
  66. package/dist/eval-core/evaluation-job.d.ts +4 -1
  67. package/dist/eval-core/evaluation-job.js +4 -1
  68. package/dist/eval-core/evaluation-reporting.d.ts +15 -13
  69. package/dist/eval-core/evaluation-reporting.js +54 -52
  70. package/dist/eval-core/execution-strategy.d.ts +2 -0
  71. package/dist/eval-core/execution-strategy.js +11 -9
  72. package/dist/eval-core/fact-checker.js +15 -7
  73. package/dist/eval-core/holdout.js +3 -2
  74. package/dist/eval-core/judge-independence.d.ts +2 -2
  75. package/dist/eval-core/mock-hook.cjs +23 -6
  76. package/dist/eval-core/mocks-runtime.js +30 -8
  77. package/dist/eval-core/report-document.d.ts +12 -0
  78. package/dist/eval-core/report-document.js +1151 -0
  79. package/dist/eval-core/report-extensions.d.ts +4 -0
  80. package/dist/eval-core/report-extensions.js +500 -0
  81. package/dist/eval-core/report-file-migration.js +7 -2
  82. package/dist/eval-core/resume-compatibility.d.ts +31 -0
  83. package/dist/eval-core/resume-compatibility.js +141 -0
  84. package/dist/eval-core/sample-fingerprint.d.ts +12 -0
  85. package/dist/eval-core/sample-fingerprint.js +193 -0
  86. package/dist/eval-core/schema.js +86 -31
  87. package/dist/eval-core/verdict.d.ts +8 -4
  88. package/dist/eval-core/verdict.js +24 -10
  89. package/dist/eval-workflows/batch-evaluation-workflow.d.ts +2 -1
  90. package/dist/eval-workflows/batch-evaluation-workflow.js +25 -12
  91. package/dist/eval-workflows/evaluation-pipeline/preflight-warnings.d.ts +10 -5
  92. package/dist/eval-workflows/evaluation-pipeline/preflight-warnings.js +58 -21
  93. package/dist/eval-workflows/evaluation-pipeline/report-finalize.js +3 -1
  94. package/dist/eval-workflows/evaluation-pipeline/run-state.d.ts +4 -1
  95. package/dist/eval-workflows/evaluation-pipeline/run-state.js +4 -1
  96. package/dist/eval-workflows/evaluation-pipeline/test-set-hash.d.ts +6 -5
  97. package/dist/eval-workflows/evaluation-pipeline/test-set-hash.js +17 -10
  98. package/dist/eval-workflows/evaluation-pipeline.js +12 -7
  99. package/dist/eval-workflows/run-evaluation.d.ts +9 -7
  100. package/dist/eval-workflows/run-evaluation.js +79 -51
  101. package/dist/executors/anthropic-api.js +65 -9
  102. package/dist/executors/claude-cli.js +16 -79
  103. package/dist/executors/claude-protocol.d.ts +28 -0
  104. package/dist/executors/claude-protocol.js +180 -0
  105. package/dist/executors/claude-sdk-trace.js +56 -28
  106. package/dist/executors/claude-sdk.d.ts +1 -0
  107. package/dist/executors/claude-sdk.js +39 -93
  108. package/dist/executors/codex-cli-trace.js +166 -31
  109. package/dist/executors/codex-cli.d.ts +6 -8
  110. package/dist/executors/codex-cli.js +49 -151
  111. package/dist/executors/codex-protocol.d.ts +24 -0
  112. package/dist/executors/codex-protocol.js +234 -0
  113. package/dist/executors/codex-sdk.js +68 -120
  114. package/dist/executors/gemini.js +88 -13
  115. package/dist/executors/index.d.ts +2 -3
  116. package/dist/executors/index.js +5 -3
  117. package/dist/executors/openai-api.js +70 -9
  118. package/dist/executors/runtime-fingerprint.js +88 -11
  119. package/dist/executors/script-command.d.ts +8 -0
  120. package/dist/executors/script-command.js +87 -0
  121. package/dist/executors/script.js +202 -29
  122. package/dist/executors/shared.d.ts +35 -3
  123. package/dist/executors/shared.js +113 -15
  124. package/dist/grading/assertions.d.ts +1 -1
  125. package/dist/grading/assertions.js +19 -9
  126. package/dist/grading/diagnostic.d.ts +9 -2
  127. package/dist/grading/diagnostic.js +25 -2
  128. package/dist/grading/index.js +10 -4
  129. package/dist/grading/judge.js +19 -6
  130. package/dist/grading/layered-scores.d.ts +2 -3
  131. package/dist/grading/layered-scores.js +2 -3
  132. package/dist/inputs/load-samples.d.ts +1 -2
  133. package/dist/inputs/load-samples.js +23 -1
  134. package/dist/inputs/mcp-resolver.js +6 -3
  135. package/dist/inputs/sample-document.d.ts +11 -0
  136. package/dist/inputs/sample-document.js +96 -0
  137. package/dist/managed/evidence.d.ts +1 -0
  138. package/dist/managed/evidence.js +1 -1
  139. package/dist/managed/store.js +200 -91
  140. package/dist/observability/codex-trace-adapter.d.ts +5 -0
  141. package/dist/observability/codex-trace-adapter.js +850 -0
  142. package/dist/observability/experience.d.ts +32 -6
  143. package/dist/observability/experience.js +2695 -459
  144. package/dist/observability/feedback-matchers.js +16 -1
  145. package/dist/observability/inbox-view-model.d.ts +1 -1
  146. package/dist/observability/inbox-view-model.js +19 -14
  147. package/dist/observability/inbox.d.ts +7 -1
  148. package/dist/observability/inbox.js +632 -124
  149. package/dist/observability/problem-patterns.js +2 -0
  150. package/dist/observability/review-state.d.ts +6 -0
  151. package/dist/observability/review-state.js +235 -63
  152. package/dist/observability/skill-chain-advisories.js +1 -1
  153. package/dist/observability/skill-chain.js +17 -4
  154. package/dist/observability/skill-health-analyzer.d.ts +32 -7
  155. package/dist/observability/skill-health-analyzer.js +194 -121
  156. package/dist/observability/skill-health-report.d.ts +10 -0
  157. package/dist/observability/skill-health-report.js +620 -0
  158. package/dist/observability/soft-standards/constants.d.ts +0 -1
  159. package/dist/observability/soft-standards/constants.js +0 -1
  160. package/dist/observability/soft-standards/index.d.ts +1 -1
  161. package/dist/observability/soft-standards/index.js +1 -1
  162. package/dist/observability/soft-standards/llm-extractor.js +8 -10
  163. package/dist/observability/soft-standards/skill-standards-store.d.ts +2 -1
  164. package/dist/observability/soft-standards/skill-standards-store.js +59 -18
  165. package/dist/observability/soft-standards/types.d.ts +2 -2
  166. package/dist/observability/trace-adapter.d.ts +12 -7
  167. package/dist/observability/trace-adapter.js +11 -9
  168. package/dist/observability/trace-attribution.d.ts +13 -5
  169. package/dist/observability/trace-attribution.js +315 -21
  170. package/dist/observability/trace-ingestion.d.ts +9 -0
  171. package/dist/observability/trace-ingestion.js +80 -0
  172. package/dist/observability/trace-ir.d.ts +113 -0
  173. package/dist/observability/trace-ir.js +87 -0
  174. package/dist/observability/trace-segmenter.d.ts +19 -6
  175. package/dist/observability/trace-segmenter.js +377 -196
  176. package/dist/observability/trace-session-index.d.ts +19 -0
  177. package/dist/observability/trace-session-index.js +68 -0
  178. package/dist/observability/trace-source.d.ts +12 -4
  179. package/dist/observability/trace-source.js +939 -215
  180. package/dist/renderer/html-renderer.js +37 -6
  181. package/dist/renderer/icons.js +3 -0
  182. package/dist/renderer/observation-inbox-renderer.js +208 -90
  183. package/dist/renderer/skill-detail-renderer.js +452 -109
  184. package/dist/renderer/skill-health-renderer.js +69 -12
  185. package/dist/renderer/summary.js +28 -7
  186. package/dist/renderer/table.js +21 -4
  187. package/dist/renderer/test-view.d.ts +1 -0
  188. package/dist/renderer/test-view.js +44 -9
  189. package/dist/server/indexed-report-store.js +14 -18
  190. package/dist/server/job-store.js +64 -26
  191. package/dist/server/report-server.js +190 -78
  192. package/dist/server/report-store.js +57 -80
  193. package/dist/server/skill-index.js +143 -49
  194. package/dist/server/skill-insights.js +44 -5
  195. package/dist/shared/artifact-graph.d.ts +3 -0
  196. package/dist/shared/artifact-graph.js +224 -0
  197. package/dist/shared/assertion-types.d.ts +8 -0
  198. package/dist/shared/assertion-types.js +46 -0
  199. package/dist/shared/atomic-json.d.ts +8 -0
  200. package/dist/shared/atomic-json.js +33 -0
  201. package/dist/shared/diagnosis-schema.d.ts +9 -0
  202. package/dist/shared/diagnosis-schema.js +181 -0
  203. package/dist/shared/doctor-report.d.ts +3 -0
  204. package/dist/shared/doctor-report.js +103 -0
  205. package/dist/shared/evaluation-job.d.ts +6 -0
  206. package/dist/shared/evaluation-job.js +217 -0
  207. package/dist/shared/executor-result.d.ts +17 -0
  208. package/dist/shared/executor-result.js +221 -0
  209. package/dist/shared/file-lock.d.ts +12 -0
  210. package/dist/shared/file-lock.js +129 -0
  211. package/dist/shared/json-value.d.ts +5 -0
  212. package/dist/shared/json-value.js +36 -0
  213. package/dist/shared/keyed-mutex.d.ts +7 -0
  214. package/dist/shared/keyed-mutex.js +24 -0
  215. package/dist/shared/record-count.d.ts +8 -0
  216. package/dist/shared/record-count.js +43 -0
  217. package/dist/shared/sample-contract.d.ts +3 -0
  218. package/dist/shared/sample-contract.js +332 -0
  219. package/dist/shared/timestamp.d.ts +6 -0
  220. package/dist/shared/timestamp.js +64 -0
  221. package/dist/shared/token-usage.d.ts +19 -0
  222. package/dist/shared/token-usage.js +50 -0
  223. package/dist/shared/tool-call-status.d.ts +8 -0
  224. package/dist/shared/tool-call-status.js +28 -0
  225. package/dist/shared/tool-identity.d.ts +21 -0
  226. package/dist/shared/tool-identity.js +84 -0
  227. package/dist/shared/tool-search.js +73 -16
  228. package/dist/shared/trace-projection.d.ts +5 -0
  229. package/dist/shared/trace-projection.js +20 -0
  230. package/dist/shared/trace-source-kind.d.ts +3 -0
  231. package/dist/shared/trace-source-kind.js +12 -0
  232. package/dist/types/diagnosis.d.ts +2 -0
  233. package/dist/types/eval.d.ts +4 -0
  234. package/dist/types/executor.d.ts +32 -5
  235. package/dist/types/index.d.ts +1 -0
  236. package/dist/types/index.js +1 -0
  237. package/dist/types/judge.d.ts +2 -0
  238. package/dist/types/observability.d.ts +116 -9
  239. package/dist/types/report.d.ts +58 -6
  240. package/dist/types/skill-index.d.ts +7 -0
  241. package/dist/types/trace.d.ts +2 -0
  242. package/dist/types/trace.js +1 -0
  243. package/package.json +9 -5
@@ -1,18 +1,18 @@
1
- import { mkdirSync, writeFileSync } from 'node:fs';
2
1
  import { createExecutor } from '../../executors/index.js';
3
2
  import { readPromptDocument } from '../../shared/llm-prompts/index.js';
4
- import { DEFAULT_LLM_ENHANCED_REVIEW_MODEL, PROMPTS_DIR, SOFT_STANDARD_PROMPT_ID, SOFT_STANDARD_PROMPT_VERSION, } from './constants.js';
5
- import { hashText, loadExisting, markStale, SKILL_DERIVED_STANDARDS_SCHEMA_VERSION, skillDerivedStandardsDir, skillDerivedStandardsPath, } from './skill-standards-store.js';
3
+ import { writeJsonFileAtomic } from '../../shared/atomic-json.js';
4
+ import { PROMPTS_DIR, SOFT_STANDARD_PROMPT_ID, SOFT_STANDARD_PROMPT_VERSION, } from './constants.js';
5
+ import { hashText, loadSkillDerivedStandards, markStale, SKILL_DERIVED_STANDARDS_SCHEMA_VERSION, skillDerivedStandardsPath, } from './skill-standards-store.js';
6
6
  import { evaluateRuntimeStandardNodes } from './runtime-evaluator.js';
7
7
  export async function extractSkillSoftStandards(options) {
8
8
  const { observationsDir, skillChain } = options;
9
- const model = options.model || DEFAULT_LLM_ENHANCED_REVIEW_MODEL;
10
- const executorName = options.executorName || 'claude';
9
+ const model = options.model;
10
+ const executorName = options.executorName;
11
11
  const generatedAt = options.now || new Date().toISOString();
12
12
  const path = skillDerivedStandardsPath(observationsDir, skillChain.skillName);
13
13
  const sourceHash = skillChain.definition.content ? hashText(skillChain.definition.content) : undefined;
14
14
  const runtimeEvidenceHash = options.runtimeEvidence ? hashText(JSON.stringify(options.runtimeEvidence)) : undefined;
15
- const existing = loadExisting(path);
15
+ const existing = loadSkillDerivedStandards(observationsDir)[skillChain.skillName];
16
16
  const promptDocument = readPromptTemplate();
17
17
  const hasReviewedStandards = existing?.standards.some((item) => item.status === 'author_confirmed' || item.status === 'rejected' || item.status === 'stale') ?? false;
18
18
  const compatibleCache = existing
@@ -21,8 +21,7 @@ export async function extractSkillSoftStandards(options) {
21
21
  && existing.promptHash === promptDocument.hash;
22
22
  if (existing && hasReviewedStandards && !options.refresh) {
23
23
  const stale = markStale(existing, generatedAt);
24
- mkdirSync(skillDerivedStandardsDir(observationsDir), { recursive: true });
25
- writeFileSync(path, JSON.stringify(stale, null, 2));
24
+ writeJsonFileAtomic(path, stale);
26
25
  return stale;
27
26
  }
28
27
  if (compatibleCache && !options.refresh && existing.sourceHash === sourceHash && existing.runtimeEvidenceHash === runtimeEvidenceHash)
@@ -62,8 +61,7 @@ export async function extractSkillSoftStandards(options) {
62
61
  enhancedReview,
63
62
  standards,
64
63
  };
65
- mkdirSync(skillDerivedStandardsDir(observationsDir), { recursive: true });
66
- writeFileSync(path, JSON.stringify(record, null, 2));
64
+ writeJsonFileAtomic(path, record);
67
65
  return record;
68
66
  }
69
67
  function buildSoftStandardPrompt(skillChain, flags, runtimeEvidence) {
@@ -1,8 +1,9 @@
1
+ import { type ObservationReviewState } from '../review-state.js';
1
2
  import type { ResolveSkillStandardsOptions, ResolvedSkillStandards, SkillDerivedStandardStatus, SkillDerivedStandards } from './types.js';
2
3
  export declare const SKILL_DERIVED_STANDARDS_SCHEMA_VERSION = 2;
3
4
  export declare function skillDerivedStandardsDir(observationsDir: string): string;
4
5
  export declare function skillDerivedStandardsPath(observationsDir: string, skillName: string): string;
5
- export declare function loadSkillDerivedStandards(observationsDir: string): Record<string, SkillDerivedStandards>;
6
+ export declare function loadSkillDerivedStandards(observationsDir: string, reviewState?: ObservationReviewState): Record<string, SkillDerivedStandards>;
6
7
  export declare function updateSkillDerivedStandardStatus(observationsDir: string, skillName: string, standardId: string, status: SkillDerivedStandardStatus, now?: string): SkillDerivedStandards;
7
8
  export declare function resolveSkillStandards(skillName: string, options: ResolveSkillStandardsOptions): ResolvedSkillStandards;
8
9
  export declare function loadExisting(path: string): SkillDerivedStandards | undefined;
@@ -1,7 +1,11 @@
1
1
  import { createHash } from 'node:crypto';
2
- import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from 'node:fs';
2
+ import { existsSync, readFileSync, readdirSync } from 'node:fs';
3
3
  import { join } from 'node:path';
4
4
  import { buildObservationSkillChain } from '../skill-chain.js';
5
+ import { ownRecordValue, setOwnRecordValue, } from '../../shared/record-count.js';
6
+ import { loadObservationReviewState, observationReviewStateKey, } from '../review-state.js';
7
+ import { writeJsonFileAtomic } from '../../shared/atomic-json.js';
8
+ import { isRfc3339Timestamp } from '../../shared/timestamp.js';
5
9
  export const SKILL_DERIVED_STANDARDS_SCHEMA_VERSION = 2;
6
10
  export function skillDerivedStandardsDir(observationsDir) {
7
11
  return join(observationsDir, 'skill-derived');
@@ -9,7 +13,7 @@ export function skillDerivedStandardsDir(observationsDir) {
9
13
  export function skillDerivedStandardsPath(observationsDir, skillName) {
10
14
  return join(skillDerivedStandardsDir(observationsDir), `${safeSkillFileName(skillName)}.json`);
11
15
  }
12
- export function loadSkillDerivedStandards(observationsDir) {
16
+ export function loadSkillDerivedStandards(observationsDir, reviewState = loadObservationReviewState(observationsDir)) {
13
17
  const dir = skillDerivedStandardsDir(observationsDir);
14
18
  if (!existsSync(dir))
15
19
  return {};
@@ -19,8 +23,9 @@ export function loadSkillDerivedStandards(observationsDir) {
19
23
  continue;
20
24
  try {
21
25
  const parsed = normalizeSkillDerivedStandards(JSON.parse(readFileSync(join(dir, file), 'utf-8')));
22
- if (parsed)
23
- out[parsed.skillName] = parsed;
26
+ if (parsed) {
27
+ setOwnRecordValue(out, parsed.skillName, applySoftStandardReviews(parsed, reviewState));
28
+ }
24
29
  }
25
30
  catch {
26
31
  // Ignore broken cache files; the extraction command can refresh them.
@@ -28,6 +33,28 @@ export function loadSkillDerivedStandards(observationsDir) {
28
33
  }
29
34
  return out;
30
35
  }
36
+ function applySoftStandardReviews(record, reviewState) {
37
+ const generatedAt = Date.parse(record.generatedAt);
38
+ return {
39
+ ...record,
40
+ standards: record.standards.map((standard) => {
41
+ if (standard.status === 'stale')
42
+ return standard;
43
+ const targetId = `${record.skillName}:${standard.id}`;
44
+ const entry = reviewState.entries[observationReviewStateKey('soft_standard', targetId)];
45
+ if (!entry || Date.parse(entry.reviewedAt) < generatedAt)
46
+ return standard;
47
+ if (entry.verdict === 'real_issue')
48
+ return { ...standard, status: 'author_confirmed' };
49
+ if (entry.verdict === 'not_issue')
50
+ return { ...standard, status: 'rejected' };
51
+ if (entry.verdict === 'needs_more_context' || entry.verdict === 'reviewed') {
52
+ return { ...standard, status: 'pending_review' };
53
+ }
54
+ return standard;
55
+ }),
56
+ };
57
+ }
31
58
  export function updateSkillDerivedStandardStatus(observationsDir, skillName, standardId, status, now = new Date().toISOString()) {
32
59
  const filePath = skillDerivedStandardsPath(observationsDir, skillName);
33
60
  const existing = loadExisting(filePath);
@@ -46,19 +73,18 @@ export function updateSkillDerivedStandardStatus(observationsDir, skillName, sta
46
73
  };
47
74
  if (!found)
48
75
  throw new Error(`skill derived standard not found: ${standardId}`);
49
- mkdirSync(skillDerivedStandardsDir(observationsDir), { recursive: true });
50
- writeFileSync(filePath, JSON.stringify(next, null, 2));
76
+ writeJsonFileAtomic(filePath, next);
51
77
  return next;
52
78
  }
53
79
  export function resolveSkillStandards(skillName, options) {
54
80
  const skillChain = options.skillChain ?? buildObservationSkillChain(skillName, options.cwd ?? process.cwd());
55
81
  const directDerived = normalizeSkillDerivedStandards(options.derivedStandards);
56
82
  const mappedDerived = options.derivedStandards && !isSkillDerivedStandards(options.derivedStandards)
57
- ? normalizeSkillDerivedStandards(options.derivedStandards[skillName])
83
+ ? normalizeSkillDerivedStandards(ownRecordValue(options.derivedStandards, skillName))
58
84
  : undefined;
59
85
  const derived = directDerived
60
86
  ?? mappedDerived
61
- ?? loadSkillDerivedStandards(options.observationsDir)[skillName];
87
+ ?? ownRecordValue(loadSkillDerivedStandards(options.observationsDir), skillName);
62
88
  const active = [];
63
89
  const candidates = [];
64
90
  const hasFrontmatterHardRules = skillChain.healthCheck.hardRules.declared && skillChain.healthCheck.hardRules.rules.length > 0;
@@ -134,7 +160,7 @@ export function isSkillDerivedStandards(value) {
134
160
  return normalizeSkillDerivedStandards(value) !== undefined;
135
161
  }
136
162
  function normalizeSkillDerivedStandards(value) {
137
- if (!value || typeof value !== 'object')
163
+ if (!value || typeof value !== 'object' || Array.isArray(value))
138
164
  return undefined;
139
165
  const item = value;
140
166
  const kind = item.kind === 'observe-skill-derived-standards' ? item.kind : null;
@@ -142,14 +168,23 @@ function normalizeSkillDerivedStandards(value) {
142
168
  return undefined;
143
169
  if (item.schemaVersion !== SKILL_DERIVED_STANDARDS_SCHEMA_VERSION)
144
170
  return undefined;
145
- if (typeof item.skillName !== 'string' || typeof item.generatedAt !== 'string' || typeof item.model !== 'string' || typeof item.executor !== 'string') {
171
+ if (!isNonEmptyString(item.skillName)
172
+ || !isTimestamp(item.generatedAt)
173
+ || !isNonEmptyString(item.model)
174
+ || !isNonEmptyString(item.executor)) {
146
175
  return undefined;
147
176
  }
148
- if (typeof item.promptId !== 'string' || typeof item.promptVersion !== 'string' || !Array.isArray(item.standards))
177
+ if (!isNonEmptyString(item.promptId) || !isNonEmptyString(item.promptVersion) || !Array.isArray(item.standards))
178
+ return undefined;
179
+ const standards = item.standards.map(normalizeSkillDerivedStandard);
180
+ if (standards.some((record) => record === null))
149
181
  return undefined;
150
- const standards = item.standards
151
- .map(normalizeSkillDerivedStandard)
152
- .filter((record) => record !== null);
182
+ const validStandards = standards;
183
+ if (new Set(validStandards.map((record) => record.id)).size !== validStandards.length)
184
+ return undefined;
185
+ if (item.enhancedReview !== undefined && (!item.enhancedReview || typeof item.enhancedReview !== 'object' || Array.isArray(item.enhancedReview))) {
186
+ return undefined;
187
+ }
153
188
  return {
154
189
  kind: 'observe-skill-derived-standards',
155
190
  schemaVersion: SKILL_DERIVED_STANDARDS_SCHEMA_VERSION,
@@ -163,12 +198,12 @@ function normalizeSkillDerivedStandards(value) {
163
198
  promptVersion: item.promptVersion,
164
199
  ...(typeof item.promptHash === 'string' ? { promptHash: item.promptHash } : {}),
165
200
  ...(typeof item.runtimeEvidenceHash === 'string' ? { runtimeEvidenceHash: item.runtimeEvidenceHash } : {}),
166
- ...(item.enhancedReview && typeof item.enhancedReview === 'object' ? { enhancedReview: item.enhancedReview } : {}),
167
- standards,
201
+ ...(item.enhancedReview ? { enhancedReview: item.enhancedReview } : {}),
202
+ standards: validStandards,
168
203
  };
169
204
  }
170
205
  function normalizeSkillDerivedStandard(value) {
171
- if (!value || typeof value !== 'object')
206
+ if (!value || typeof value !== 'object' || Array.isArray(value))
172
207
  return null;
173
208
  const item = value;
174
209
  const standardKind = item.standardKind === 'hard_rule_candidate' || item.standardKind === 'workflow_candidate'
@@ -178,7 +213,7 @@ function normalizeSkillDerivedStandard(value) {
178
213
  : null;
179
214
  if (!standardKind)
180
215
  return null;
181
- if (typeof item.id !== 'string' || typeof item.title !== 'string' || typeof item.body !== 'string')
216
+ if (!isNonEmptyString(item.id) || !isNonEmptyString(item.title) || typeof item.body !== 'string')
182
217
  return null;
183
218
  if (item.status !== 'pending_review' && item.status !== 'author_confirmed' && item.status !== 'rejected' && item.status !== 'stale') {
184
219
  return null;
@@ -200,6 +235,12 @@ function normalizeSkillDerivedStandard(value) {
200
235
  evidence: item.evidence,
201
236
  };
202
237
  }
238
+ function isNonEmptyString(value) {
239
+ return typeof value === 'string' && value.trim().length > 0;
240
+ }
241
+ function isTimestamp(value) {
242
+ return isRfc3339Timestamp(value);
243
+ }
203
244
  function candidateRank(status) {
204
245
  if (status === 'pending_review')
205
246
  return 0;
@@ -197,8 +197,8 @@ export interface ExtractSkillSoftStandardsOptions {
197
197
  observationsDir: string;
198
198
  skillChain: ObservationSkillChain;
199
199
  runtimeEvidence?: SkillLlmEnhancedRuntimeEvidence;
200
- model?: string;
201
- executorName?: string;
200
+ model: string;
201
+ executorName: string;
202
202
  refresh?: boolean;
203
203
  now?: string;
204
204
  executor?: ExecutorFn;
@@ -1,22 +1,27 @@
1
1
  /**
2
- * cc session JSONL / agent markdown log → omk ResultEntry adapter.
2
+ * Source traces / agent markdown logs → omk ResultEntry adapter.
3
3
  *
4
4
  * This file is intentionally thin: source parsing, attribution, and segmentation
5
5
  * live in sibling modules so studio/report code does not inherit one large adapter.
6
6
  */
7
- import type { ResultEntry } from '../types/index.js';
8
- import { type CcSession } from './trace-source.js';
7
+ import type { ResultEntry, TraceIngestionSummary } from '../types/index.js';
8
+ import type { TraceSession } from './trace-ir.js';
9
9
  import { type SkillSegment } from './trace-segmenter.js';
10
10
  export type { CcAssistantContent, CcAssistantRecord, CcRecord, CcSession, CcUserRecord, CcUserTextContent, CcUserToolResultContent, } from './trace-source.js';
11
- export { loadCcSessions } from './trace-source.js';
11
+ export type { TraceEvent, TraceLifecycleEvent, TraceMessageEvent, TraceMessageOrigin, TraceSession, TraceToolCallEvent, TraceToolRef, TraceToolResultEvent, TraceToolStatus, TraceUsageEvent, } from './trace-ir.js';
12
+ export type { TraceIngestionSummary } from '../types/index.js';
13
+ export { loadCcSessions, loadTraceCorpus, loadTraceSessions } from './trace-source.js';
12
14
  export { extractAttributionSkill, extractAttributionSkillRef, extractCommandSkill, extractCommandSkillRef, extractCommandEnvelopeText, extractMarkdownLogSkill, extractSkillReadFileRef, extractSkillReadFile, extractSkillToolUse, extractSkillToolUseRef, normalizeSkillName, parseSkillRef, stripCommandEnvelopeText, } from './trace-attribution.js';
13
15
  export type { SkillSegment } from './trace-segmenter.js';
14
- export { segmentBySkill, segmentsToResultEntries } from './trace-segmenter.js';
16
+ export { segmentBySkill, segmentTraceBySkill, segmentsToResultEntries, skillSegmentTimestampObserved, UNOBSERVED_TRACE_TIMESTAMP, } from './trace-segmenter.js';
15
17
  /**
16
18
  * One-stop conversion: trace path → ResultEntry[].
17
19
  */
18
- export declare function ccTracesToResultEntries(path: string): {
20
+ export declare function tracesToResultEntries(path: string): {
19
21
  entries: ResultEntry[];
20
- sessions: CcSession[];
22
+ sessions: TraceSession[];
21
23
  segments: SkillSegment[];
24
+ ingestion: TraceIngestionSummary;
22
25
  };
26
+ /** @deprecated Use `tracesToResultEntries`. */
27
+ export declare const ccTracesToResultEntries: typeof tracesToResultEntries;
@@ -1,20 +1,22 @@
1
1
  /**
2
- * cc session JSONL / agent markdown log → omk ResultEntry adapter.
2
+ * Source traces / agent markdown logs → omk ResultEntry adapter.
3
3
  *
4
4
  * This file is intentionally thin: source parsing, attribution, and segmentation
5
5
  * live in sibling modules so studio/report code does not inherit one large adapter.
6
6
  */
7
- import { loadCcSessions } from './trace-source.js';
8
- import { segmentBySkill, segmentsToResultEntries } from './trace-segmenter.js';
9
- export { loadCcSessions } from './trace-source.js';
7
+ import { loadTraceCorpus } from './trace-source.js';
8
+ import { segmentTraceBySkill, segmentsToResultEntries } from './trace-segmenter.js';
9
+ export { loadCcSessions, loadTraceCorpus, loadTraceSessions } from './trace-source.js';
10
10
  export { extractAttributionSkill, extractAttributionSkillRef, extractCommandSkill, extractCommandSkillRef, extractCommandEnvelopeText, extractMarkdownLogSkill, extractSkillReadFileRef, extractSkillReadFile, extractSkillToolUse, extractSkillToolUseRef, normalizeSkillName, parseSkillRef, stripCommandEnvelopeText, } from './trace-attribution.js';
11
- export { segmentBySkill, segmentsToResultEntries } from './trace-segmenter.js';
11
+ export { segmentBySkill, segmentTraceBySkill, segmentsToResultEntries, skillSegmentTimestampObserved, UNOBSERVED_TRACE_TIMESTAMP, } from './trace-segmenter.js';
12
12
  /**
13
13
  * One-stop conversion: trace path → ResultEntry[].
14
14
  */
15
- export function ccTracesToResultEntries(path) {
16
- const sessions = loadCcSessions(path);
17
- const segments = sessions.flatMap(segmentBySkill);
15
+ export function tracesToResultEntries(path) {
16
+ const { sessions, ingestion } = loadTraceCorpus(path);
17
+ const segments = sessions.flatMap(segmentTraceBySkill);
18
18
  const entries = segmentsToResultEntries(segments);
19
- return { entries, sessions, segments };
19
+ return { entries, sessions, segments, ingestion };
20
20
  }
21
+ /** @deprecated Use `tracesToResultEntries`. */
22
+ export const ccTracesToResultEntries = tracesToResultEntries;
@@ -1,5 +1,6 @@
1
1
  /** Skill attribution rules for trace records. */
2
2
  import type { CcAssistantRecord, CcUserRecord } from './trace-source.js';
3
+ import type { TraceMessageEvent, TraceToolCallEvent } from './trace-ir.js';
3
4
  export interface SkillRef {
4
5
  skillName: string;
5
6
  rawSkillRef: string;
@@ -7,10 +8,9 @@ export interface SkillRef {
7
8
  }
8
9
  export declare function extractMarkdownLogSkill(text: string): string | null;
9
10
  /**
10
- * 归一化 skill 名: 去掉 plugin 前缀, 过滤 cc 内置命令。
11
+ * 归一化 skill 名:去掉 plugin 前缀并校验稳定身份。
11
12
  * - "impeccable:audit" → "audit"
12
13
  * - "pbakaus/impeccable:audit" → "audit"
13
- * - "clear" / "exit" 等 → null(表示不是 skill)
14
14
  */
15
15
  export declare function normalizeSkillName(raw: string): string | null;
16
16
  export declare function parseSkillRef(raw: string): SkillRef | null;
@@ -22,6 +22,7 @@ export declare function extractCommandEnvelopeText(text: string): string | null;
22
22
  */
23
23
  export declare function extractCommandSkill(record: CcUserRecord): string | null;
24
24
  export declare function extractCommandSkillRef(record: CcUserRecord): SkillRef | null;
25
+ export declare function isClaudeBuiltinCommand(raw: string): boolean;
25
26
  /**
26
27
  * 从 OpenClaw user message 的业务动作标签里提取 skill 名字(信号 4)。
27
28
  *
@@ -38,10 +39,11 @@ export declare function extractSkillToolUse(record: CcAssistantRecord): string |
38
39
  export declare function extractSkillToolUseRef(record: CcAssistantRecord): SkillRef | null;
39
40
  export declare function extractAttributionSkill(record: CcAssistantRecord): string | null;
40
41
  export declare function extractAttributionSkillRef(record: CcAssistantRecord): SkillRef | null;
42
+ export declare function isInstalledSkillAssetPath(value: string, skillName: string): boolean;
41
43
  /**
42
- * 从 assistant message 的 Read tool_use 里提取 skill 名字(信号 3, fallback)。
43
- * 匹配 file_path 形如 ".claude/skills/<name>/SKILL.md"
44
- * 或 ".openclaw/workspace/skills/<name>/SKILL.md" 的模式。
44
+ * 从 assistant message 的 Read / Bash tool_use 里提取 skill 名字(信号 3, fallback)。
45
+ * Codex 通常用 shell 读取 `.agents/skills/<name>/SKILL.md`,Claude Code 与
46
+ * OpenClaw 则更常用结构化 Read tool;两种形式统一识别。
45
47
  * 返回 null 表示没命中。
46
48
  */
47
49
  export declare function extractSkillReadFile(record: CcAssistantRecord): string | null;
@@ -53,3 +55,9 @@ export declare function extractSkillReadFileRef(record: CcAssistantRecord): Skil
53
55
  * 只会直接执行 ~/.openclaw/workspace-main/skills/<skill>/scripts/*.sh。
54
56
  */
55
57
  export declare function extractSkillScriptCommandRef(record: CcUserRecord | CcAssistantRecord): SkillRef | null;
58
+ export declare function extractCommandSkillRefFromEvent(event: TraceMessageEvent): SkillRef | null;
59
+ export declare function extractBusinessActionSkillRefFromEvent(event: TraceMessageEvent): SkillRef | null;
60
+ export declare function extractAttributionSkillRefFromEvent(event: TraceMessageEvent): SkillRef | null;
61
+ export declare function extractSkillToolUseRefFromEvent(event: TraceToolCallEvent): SkillRef | null;
62
+ export declare function extractSkillReadFileRefFromEvent(event: TraceToolCallEvent): SkillRef | null;
63
+ export declare function extractSkillScriptCommandRefFromEvent(event: TraceMessageEvent | TraceToolCallEvent): SkillRef | null;