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.
- package/README.md +50 -18
- package/README.zh.md +55 -23
- package/dist/analysis/coverage-analyzer.d.ts +1 -0
- package/dist/analysis/coverage-analyzer.js +125 -62
- package/dist/analysis/failure-clusterer.js +2 -1
- package/dist/analysis/gap-analyzer.d.ts +2 -2
- package/dist/analysis/gap-analyzer.js +13 -3
- package/dist/analysis/hedging-classifier.d.ts +2 -2
- package/dist/analysis/hedging-classifier.js +3 -4
- package/dist/analysis/report-diagnostics.js +9 -7
- package/dist/analysis/sample-diagnostics.js +6 -6
- package/dist/artifact-graph/doctor.js +15 -7
- package/dist/assets/agent-skills/omk/SKILL.md +27 -7
- package/dist/assets/agent-skills/omk/references/commands.md +18 -17
- package/dist/authoring/evolver.d.ts +10 -6
- package/dist/authoring/evolver.js +496 -83
- package/dist/authoring/generator.d.ts +3 -3
- package/dist/authoring/generator.js +5 -10
- package/dist/authoring/sample-fixer.d.ts +8 -6
- package/dist/authoring/sample-fixer.js +76 -5
- package/dist/cli/commands/doctor.js +31 -14
- package/dist/cli/commands/eval/index.d.ts +3 -0
- package/dist/cli/commands/eval/index.js +163 -17
- package/dist/cli/commands/evolve.d.ts +4 -4
- package/dist/cli/commands/evolve.js +27 -13
- package/dist/cli/commands/init.js +16 -3
- package/dist/cli/commands/observe/inbox.js +28 -21
- package/dist/cli/commands/observe/index.js +20 -11
- package/dist/cli/commands/observe/ingest.d.ts +3 -0
- package/dist/cli/commands/observe/ingest.js +30 -2
- package/dist/cli/commands/sample.d.ts +6 -3
- package/dist/cli/commands/sample.js +72 -68
- package/dist/cli/lib/codex-model-hint.d.ts +9 -0
- package/dist/cli/lib/codex-model-hint.js +45 -0
- package/dist/cli/lib/generation-failure-hint.d.ts +2 -0
- package/dist/cli/lib/generation-failure-hint.js +61 -0
- package/dist/cli/lib/i18n-dict/common.d.ts +1 -1
- package/dist/cli/lib/i18n-dict/common.js +4 -0
- package/dist/cli/lib/i18n-dict/gen.d.ts +1 -1
- package/dist/cli/lib/i18n-dict/gen.js +38 -6
- package/dist/cli/lib/i18n-dict/help.js +6 -6
- package/dist/cli/lib/i18n-dict/init.d.ts +1 -1
- package/dist/cli/lib/i18n-dict/init.js +13 -9
- package/dist/cli/lib/i18n-dict/run.d.ts +1 -1
- package/dist/cli/lib/i18n-dict/run.js +34 -2
- package/dist/cli/lib/llm-failure-classifier.d.ts +2 -0
- package/dist/cli/lib/llm-failure-classifier.js +8 -0
- package/dist/cli/lib/parse-run-config.d.ts +6 -5
- package/dist/cli/lib/parse-run-config.js +16 -9
- package/dist/cli/lib/runtime-defaults.d.ts +21 -0
- package/dist/cli/lib/runtime-defaults.js +79 -0
- package/dist/diagnosis/observe-mapper.js +14 -15
- package/dist/diagnosis/observe-producer.js +3 -1
- package/dist/diagnosis/studio-projection.js +14 -7
- package/dist/diagnosis/types.d.ts +2 -0
- package/dist/diagnosis/types.js +12 -0
- package/dist/doctor/endpoint-rule.js +2 -1
- package/dist/eval-core/artifact-file-names.js +18 -1
- package/dist/eval-core/artifact-index.d.ts +7 -11
- package/dist/eval-core/artifact-index.js +139 -80
- package/dist/eval-core/cache.d.ts +12 -3
- package/dist/eval-core/cache.js +89 -29
- package/dist/eval-core/comparability.js +10 -6
- package/dist/eval-core/evaluation-execution.d.ts +2 -1
- package/dist/eval-core/evaluation-execution.js +122 -37
- package/dist/eval-core/evaluation-job.d.ts +4 -1
- package/dist/eval-core/evaluation-job.js +4 -1
- package/dist/eval-core/evaluation-reporting.d.ts +15 -13
- package/dist/eval-core/evaluation-reporting.js +54 -52
- package/dist/eval-core/execution-strategy.d.ts +2 -0
- package/dist/eval-core/execution-strategy.js +11 -9
- package/dist/eval-core/fact-checker.js +15 -7
- package/dist/eval-core/holdout.js +3 -2
- package/dist/eval-core/judge-independence.d.ts +2 -2
- package/dist/eval-core/mock-hook.cjs +23 -6
- package/dist/eval-core/mocks-runtime.js +30 -8
- package/dist/eval-core/report-document.d.ts +12 -0
- package/dist/eval-core/report-document.js +1151 -0
- package/dist/eval-core/report-extensions.d.ts +4 -0
- package/dist/eval-core/report-extensions.js +500 -0
- package/dist/eval-core/report-file-migration.js +7 -2
- package/dist/eval-core/resume-compatibility.d.ts +31 -0
- package/dist/eval-core/resume-compatibility.js +141 -0
- package/dist/eval-core/sample-fingerprint.d.ts +12 -0
- package/dist/eval-core/sample-fingerprint.js +193 -0
- package/dist/eval-core/schema.js +86 -31
- package/dist/eval-core/verdict.d.ts +8 -4
- package/dist/eval-core/verdict.js +24 -10
- package/dist/eval-workflows/batch-evaluation-workflow.d.ts +2 -1
- package/dist/eval-workflows/batch-evaluation-workflow.js +25 -12
- package/dist/eval-workflows/evaluation-pipeline/preflight-warnings.d.ts +10 -5
- package/dist/eval-workflows/evaluation-pipeline/preflight-warnings.js +58 -21
- package/dist/eval-workflows/evaluation-pipeline/report-finalize.js +3 -1
- package/dist/eval-workflows/evaluation-pipeline/run-state.d.ts +4 -1
- package/dist/eval-workflows/evaluation-pipeline/run-state.js +4 -1
- package/dist/eval-workflows/evaluation-pipeline/test-set-hash.d.ts +6 -5
- package/dist/eval-workflows/evaluation-pipeline/test-set-hash.js +17 -10
- package/dist/eval-workflows/evaluation-pipeline.js +12 -7
- package/dist/eval-workflows/run-evaluation.d.ts +9 -7
- package/dist/eval-workflows/run-evaluation.js +79 -51
- package/dist/executors/anthropic-api.js +65 -9
- package/dist/executors/claude-cli.js +16 -79
- package/dist/executors/claude-protocol.d.ts +28 -0
- package/dist/executors/claude-protocol.js +180 -0
- package/dist/executors/claude-sdk-trace.js +56 -28
- package/dist/executors/claude-sdk.d.ts +1 -0
- package/dist/executors/claude-sdk.js +39 -93
- package/dist/executors/codex-cli-trace.js +166 -31
- package/dist/executors/codex-cli.d.ts +6 -8
- package/dist/executors/codex-cli.js +49 -151
- package/dist/executors/codex-protocol.d.ts +24 -0
- package/dist/executors/codex-protocol.js +234 -0
- package/dist/executors/codex-sdk.js +68 -120
- package/dist/executors/gemini.js +88 -13
- package/dist/executors/index.d.ts +2 -3
- package/dist/executors/index.js +5 -3
- package/dist/executors/openai-api.js +70 -9
- package/dist/executors/runtime-fingerprint.js +88 -11
- package/dist/executors/script-command.d.ts +8 -0
- package/dist/executors/script-command.js +87 -0
- package/dist/executors/script.js +202 -29
- package/dist/executors/shared.d.ts +35 -3
- package/dist/executors/shared.js +113 -15
- package/dist/grading/assertions.d.ts +1 -1
- package/dist/grading/assertions.js +19 -9
- package/dist/grading/diagnostic.d.ts +9 -2
- package/dist/grading/diagnostic.js +25 -2
- package/dist/grading/index.js +10 -4
- package/dist/grading/judge.js +19 -6
- package/dist/grading/layered-scores.d.ts +2 -3
- package/dist/grading/layered-scores.js +2 -3
- package/dist/inputs/load-samples.d.ts +1 -2
- package/dist/inputs/load-samples.js +23 -1
- package/dist/inputs/mcp-resolver.js +6 -3
- package/dist/inputs/sample-document.d.ts +11 -0
- package/dist/inputs/sample-document.js +96 -0
- package/dist/managed/evidence.d.ts +1 -0
- package/dist/managed/evidence.js +1 -1
- package/dist/managed/store.js +200 -91
- package/dist/observability/codex-trace-adapter.d.ts +5 -0
- package/dist/observability/codex-trace-adapter.js +850 -0
- package/dist/observability/experience.d.ts +32 -6
- package/dist/observability/experience.js +2695 -459
- package/dist/observability/feedback-matchers.js +16 -1
- package/dist/observability/inbox-view-model.d.ts +1 -1
- package/dist/observability/inbox-view-model.js +19 -14
- package/dist/observability/inbox.d.ts +7 -1
- package/dist/observability/inbox.js +632 -124
- package/dist/observability/problem-patterns.js +2 -0
- package/dist/observability/review-state.d.ts +6 -0
- package/dist/observability/review-state.js +235 -63
- package/dist/observability/skill-chain-advisories.js +1 -1
- package/dist/observability/skill-chain.js +17 -4
- package/dist/observability/skill-health-analyzer.d.ts +32 -7
- package/dist/observability/skill-health-analyzer.js +194 -121
- package/dist/observability/skill-health-report.d.ts +10 -0
- package/dist/observability/skill-health-report.js +620 -0
- package/dist/observability/soft-standards/constants.d.ts +0 -1
- package/dist/observability/soft-standards/constants.js +0 -1
- package/dist/observability/soft-standards/index.d.ts +1 -1
- package/dist/observability/soft-standards/index.js +1 -1
- package/dist/observability/soft-standards/llm-extractor.js +8 -10
- package/dist/observability/soft-standards/skill-standards-store.d.ts +2 -1
- package/dist/observability/soft-standards/skill-standards-store.js +59 -18
- package/dist/observability/soft-standards/types.d.ts +2 -2
- package/dist/observability/trace-adapter.d.ts +12 -7
- package/dist/observability/trace-adapter.js +11 -9
- package/dist/observability/trace-attribution.d.ts +13 -5
- package/dist/observability/trace-attribution.js +315 -21
- package/dist/observability/trace-ingestion.d.ts +9 -0
- package/dist/observability/trace-ingestion.js +80 -0
- package/dist/observability/trace-ir.d.ts +113 -0
- package/dist/observability/trace-ir.js +87 -0
- package/dist/observability/trace-segmenter.d.ts +19 -6
- package/dist/observability/trace-segmenter.js +377 -196
- package/dist/observability/trace-session-index.d.ts +19 -0
- package/dist/observability/trace-session-index.js +68 -0
- package/dist/observability/trace-source.d.ts +12 -4
- package/dist/observability/trace-source.js +939 -215
- package/dist/renderer/html-renderer.js +37 -6
- package/dist/renderer/icons.js +3 -0
- package/dist/renderer/observation-inbox-renderer.js +208 -90
- package/dist/renderer/skill-detail-renderer.js +452 -109
- package/dist/renderer/skill-health-renderer.js +69 -12
- package/dist/renderer/summary.js +28 -7
- package/dist/renderer/table.js +21 -4
- package/dist/renderer/test-view.d.ts +1 -0
- package/dist/renderer/test-view.js +44 -9
- package/dist/server/indexed-report-store.js +14 -18
- package/dist/server/job-store.js +64 -26
- package/dist/server/report-server.js +190 -78
- package/dist/server/report-store.js +57 -80
- package/dist/server/skill-index.js +143 -49
- package/dist/server/skill-insights.js +44 -5
- package/dist/shared/artifact-graph.d.ts +3 -0
- package/dist/shared/artifact-graph.js +224 -0
- package/dist/shared/assertion-types.d.ts +8 -0
- package/dist/shared/assertion-types.js +46 -0
- package/dist/shared/atomic-json.d.ts +8 -0
- package/dist/shared/atomic-json.js +33 -0
- package/dist/shared/diagnosis-schema.d.ts +9 -0
- package/dist/shared/diagnosis-schema.js +181 -0
- package/dist/shared/doctor-report.d.ts +3 -0
- package/dist/shared/doctor-report.js +103 -0
- package/dist/shared/evaluation-job.d.ts +6 -0
- package/dist/shared/evaluation-job.js +217 -0
- package/dist/shared/executor-result.d.ts +17 -0
- package/dist/shared/executor-result.js +221 -0
- package/dist/shared/file-lock.d.ts +12 -0
- package/dist/shared/file-lock.js +129 -0
- package/dist/shared/json-value.d.ts +5 -0
- package/dist/shared/json-value.js +36 -0
- package/dist/shared/keyed-mutex.d.ts +7 -0
- package/dist/shared/keyed-mutex.js +24 -0
- package/dist/shared/record-count.d.ts +8 -0
- package/dist/shared/record-count.js +43 -0
- package/dist/shared/sample-contract.d.ts +3 -0
- package/dist/shared/sample-contract.js +332 -0
- package/dist/shared/timestamp.d.ts +6 -0
- package/dist/shared/timestamp.js +64 -0
- package/dist/shared/token-usage.d.ts +19 -0
- package/dist/shared/token-usage.js +50 -0
- package/dist/shared/tool-call-status.d.ts +8 -0
- package/dist/shared/tool-call-status.js +28 -0
- package/dist/shared/tool-identity.d.ts +21 -0
- package/dist/shared/tool-identity.js +84 -0
- package/dist/shared/tool-search.js +73 -16
- package/dist/shared/trace-projection.d.ts +5 -0
- package/dist/shared/trace-projection.js +20 -0
- package/dist/shared/trace-source-kind.d.ts +3 -0
- package/dist/shared/trace-source-kind.js +12 -0
- package/dist/types/diagnosis.d.ts +2 -0
- package/dist/types/eval.d.ts +4 -0
- package/dist/types/executor.d.ts +32 -5
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/judge.d.ts +2 -0
- package/dist/types/observability.d.ts +116 -9
- package/dist/types/report.d.ts +58 -6
- package/dist/types/skill-index.d.ts +7 -0
- package/dist/types/trace.d.ts +2 -0
- package/dist/types/trace.js +1 -0
- 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 {
|
|
5
|
-
import {
|
|
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
|
|
10
|
-
const executorName = options.executorName
|
|
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 =
|
|
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
|
-
|
|
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
|
-
|
|
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,
|
|
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
|
|
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
|
-
|
|
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
|
|
83
|
+
? normalizeSkillDerivedStandards(ownRecordValue(options.derivedStandards, skillName))
|
|
58
84
|
: undefined;
|
|
59
85
|
const derived = directDerived
|
|
60
86
|
?? mappedDerived
|
|
61
|
-
?? loadSkillDerivedStandards(options.observationsDir)
|
|
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 (
|
|
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 (
|
|
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
|
|
151
|
-
|
|
152
|
-
|
|
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
|
|
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 (
|
|
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
|
|
201
|
-
executorName
|
|
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
|
-
*
|
|
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 {
|
|
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 {
|
|
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
|
|
20
|
+
export declare function tracesToResultEntries(path: string): {
|
|
19
21
|
entries: ResultEntry[];
|
|
20
|
-
sessions:
|
|
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
|
-
*
|
|
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 {
|
|
8
|
-
import {
|
|
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
|
|
16
|
-
const sessions =
|
|
17
|
-
const segments = sessions.flatMap(
|
|
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
|
|
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
|
-
*
|
|
44
|
-
*
|
|
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;
|