@principles/core 1.273.1 → 1.274.1
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/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/runtime-v2/__tests__/pain-signal-observability.test.js +93 -0
- package/dist/runtime-v2/__tests__/pain-signal-observability.test.js.map +1 -1
- package/dist/runtime-v2/config/__tests__/pd-config-provenance.test.d.ts +24 -0
- package/dist/runtime-v2/config/__tests__/pd-config-provenance.test.d.ts.map +1 -0
- package/dist/runtime-v2/config/__tests__/pd-config-provenance.test.js +208 -0
- package/dist/runtime-v2/config/__tests__/pd-config-provenance.test.js.map +1 -0
- package/dist/runtime-v2/config/index.d.ts +1 -1
- package/dist/runtime-v2/config/index.d.ts.map +1 -1
- package/dist/runtime-v2/config/index.js.map +1 -1
- package/dist/runtime-v2/config/pd-config-effective.d.ts.map +1 -1
- package/dist/runtime-v2/config/pd-config-effective.js +10 -2
- package/dist/runtime-v2/config/pd-config-effective.js.map +1 -1
- package/dist/runtime-v2/config/pd-config-feature-flags.d.ts +3 -1
- package/dist/runtime-v2/config/pd-config-feature-flags.d.ts.map +1 -1
- package/dist/runtime-v2/config/pd-config-feature-flags.js +2 -0
- package/dist/runtime-v2/config/pd-config-feature-flags.js.map +1 -1
- package/dist/runtime-v2/config/pd-config-types.d.ts +4 -0
- package/dist/runtime-v2/config/pd-config-types.d.ts.map +1 -1
- package/dist/runtime-v2/config/pd-config-types.js +23 -0
- package/dist/runtime-v2/config/pd-config-types.js.map +1 -1
- package/dist/runtime-v2/config/pd-config-validate.d.ts.map +1 -1
- package/dist/runtime-v2/config/pd-config-validate.js +12 -1
- package/dist/runtime-v2/config/pd-config-validate.js.map +1 -1
- package/dist/runtime-v2/feature-flags/__tests__/installer-config-parity.test.js +4 -3
- package/dist/runtime-v2/feature-flags/__tests__/installer-config-parity.test.js.map +1 -1
- package/dist/runtime-v2/index.d.ts +2 -0
- package/dist/runtime-v2/index.d.ts.map +1 -1
- package/dist/runtime-v2/index.js.map +1 -1
- package/dist/runtime-v2/pain-signal-bridge.d.ts +8 -1
- package/dist/runtime-v2/pain-signal-bridge.d.ts.map +1 -1
- package/dist/runtime-v2/pain-signal-bridge.js.map +1 -1
- package/dist/runtime-v2/pain-signal-observability.d.ts.map +1 -1
- package/dist/runtime-v2/pain-signal-observability.js +25 -10
- package/dist/runtime-v2/pain-signal-observability.js.map +1 -1
- package/package.json +1 -2
- package/dist/adapters/__tests__/code-review-pain-adapter.test.d.ts +0 -2
- package/dist/adapters/__tests__/code-review-pain-adapter.test.d.ts.map +0 -1
- package/dist/adapters/__tests__/code-review-pain-adapter.test.js +0 -346
- package/dist/adapters/__tests__/code-review-pain-adapter.test.js.map +0 -1
- package/dist/adapters/__tests__/openclaw-pain-adapter.test.d.ts +0 -2
- package/dist/adapters/__tests__/openclaw-pain-adapter.test.d.ts.map +0 -1
- package/dist/adapters/__tests__/openclaw-pain-adapter.test.js +0 -290
- package/dist/adapters/__tests__/openclaw-pain-adapter.test.js.map +0 -1
- package/dist/adapters/__tests__/writing-pain-adapter.test.d.ts +0 -2
- package/dist/adapters/__tests__/writing-pain-adapter.test.d.ts.map +0 -1
- package/dist/adapters/__tests__/writing-pain-adapter.test.js +0 -239
- package/dist/adapters/__tests__/writing-pain-adapter.test.js.map +0 -1
- package/dist/adapters/code-review/code-review-pain-adapter.d.ts +0 -13
- package/dist/adapters/code-review/code-review-pain-adapter.d.ts.map +0 -1
- package/dist/adapters/code-review/code-review-pain-adapter.js +0 -139
- package/dist/adapters/code-review/code-review-pain-adapter.js.map +0 -1
- package/dist/adapters/code-review/index.d.ts +0 -6
- package/dist/adapters/code-review/index.d.ts.map +0 -1
- package/dist/adapters/code-review/index.js +0 -2
- package/dist/adapters/code-review/index.js.map +0 -1
- package/dist/adapters/code-review/review-event-types.d.ts +0 -54
- package/dist/adapters/code-review/review-event-types.d.ts.map +0 -1
- package/dist/adapters/code-review/review-event-types.js +0 -8
- package/dist/adapters/code-review/review-event-types.js.map +0 -1
- package/dist/adapters/coding/index.d.ts +0 -6
- package/dist/adapters/coding/index.d.ts.map +0 -1
- package/dist/adapters/coding/index.js +0 -5
- package/dist/adapters/coding/index.js.map +0 -1
- package/dist/adapters/coding/openclaw-event-types.d.ts +0 -26
- package/dist/adapters/coding/openclaw-event-types.d.ts.map +0 -1
- package/dist/adapters/coding/openclaw-event-types.js +0 -9
- package/dist/adapters/coding/openclaw-event-types.js.map +0 -1
- package/dist/adapters/coding/openclaw-pain-adapter.d.ts +0 -27
- package/dist/adapters/coding/openclaw-pain-adapter.d.ts.map +0 -1
- package/dist/adapters/coding/openclaw-pain-adapter.js +0 -102
- package/dist/adapters/coding/openclaw-pain-adapter.js.map +0 -1
- package/dist/adapters/writing/index.d.ts +0 -6
- package/dist/adapters/writing/index.d.ts.map +0 -1
- package/dist/adapters/writing/index.js +0 -5
- package/dist/adapters/writing/index.js.map +0 -1
- package/dist/adapters/writing/writing-pain-adapter.d.ts +0 -22
- package/dist/adapters/writing/writing-pain-adapter.d.ts.map +0 -1
- package/dist/adapters/writing/writing-pain-adapter.js +0 -62
- package/dist/adapters/writing/writing-pain-adapter.js.map +0 -1
- package/dist/adapters/writing/writing-types.d.ts +0 -34
- package/dist/adapters/writing/writing-types.d.ts.map +0 -1
- package/dist/adapters/writing/writing-types.js +0 -9
- package/dist/adapters/writing/writing-types.js.map +0 -1
- package/dist/pain-signal-adapter.d.ts +0 -37
- package/dist/pain-signal-adapter.d.ts.map +0 -1
- package/dist/pain-signal-adapter.js +0 -2
- package/dist/pain-signal-adapter.js.map +0 -1
- package/dist/pain-signal.d.ts +0 -16
- package/dist/pain-signal.d.ts.map +0 -1
- package/dist/pain-signal.js +0 -15
- package/dist/pain-signal.js.map +0 -1
- package/dist/runtime-v2/__tests__/pain-signal-unification.test.d.ts +0 -2
- package/dist/runtime-v2/__tests__/pain-signal-unification.test.d.ts.map +0 -1
- package/dist/runtime-v2/__tests__/pain-signal-unification.test.js +0 -150
- package/dist/runtime-v2/__tests__/pain-signal-unification.test.js.map +0 -1
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import { deriveSeverity } from '../../pain-signal.js';
|
|
2
|
-
const SECURITY_LABELS = ['security', 'CVE', 'vulnerability', 'auth', 'crypto'];
|
|
3
|
-
export class CodeReviewPainAdapter {
|
|
4
|
-
capture(rawEvent) {
|
|
5
|
-
// Malformed: missing sessionId
|
|
6
|
-
if (!rawEvent.sessionId || typeof rawEvent.sessionId !== 'string') {
|
|
7
|
-
return null;
|
|
8
|
-
}
|
|
9
|
-
// Malformed: nothing to review
|
|
10
|
-
if ((!rawEvent.filesChanged || rawEvent.filesChanged.length === 0) &&
|
|
11
|
-
(!rawEvent.comments || rawEvent.comments.length === 0)) {
|
|
12
|
-
return null;
|
|
13
|
-
}
|
|
14
|
-
// Malformed: negative review age
|
|
15
|
-
if (typeof rawEvent.reviewAgeDays === 'number' && rawEvent.reviewAgeDays < 0) {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
const complexityScore = this.deriveComplexityScore(rawEvent);
|
|
19
|
-
const commentAnalysis = this.analyzeComments(rawEvent);
|
|
20
|
-
const sentimentScore = this.deriveSentimentScore(rawEvent, commentAnalysis);
|
|
21
|
-
const processViolationScore = this.deriveProcessViolationScore(rawEvent);
|
|
22
|
-
const score = Math.round(0.25 * complexityScore +
|
|
23
|
-
0.35 * sentimentScore +
|
|
24
|
-
0.40 * processViolationScore);
|
|
25
|
-
const primaryTrigger = this.derivePrimaryTrigger(complexityScore, sentimentScore, processViolationScore);
|
|
26
|
-
const triggerTextPreview = commentAnalysis.topNegativeComment
|
|
27
|
-
?? `Process violation: ${primaryTrigger}`;
|
|
28
|
-
return {
|
|
29
|
-
source: primaryTrigger,
|
|
30
|
-
score: Math.max(0, Math.min(100, score)),
|
|
31
|
-
timestamp: new Date().toISOString(),
|
|
32
|
-
reason: this.buildReason(primaryTrigger, rawEvent),
|
|
33
|
-
sessionId: rawEvent.sessionId,
|
|
34
|
-
agentId: 'code-review-evaluator',
|
|
35
|
-
traceId: rawEvent.traceId ?? 'unknown',
|
|
36
|
-
triggerTextPreview: triggerTextPreview.slice(0, 200),
|
|
37
|
-
domain: 'code-review',
|
|
38
|
-
severity: deriveSeverity(score),
|
|
39
|
-
context: {
|
|
40
|
-
primaryTrigger,
|
|
41
|
-
diffComplexityScore: complexityScore,
|
|
42
|
-
sentimentScore,
|
|
43
|
-
processViolationScore,
|
|
44
|
-
authorId: rawEvent.authorId,
|
|
45
|
-
reviewerIds: rawEvent.reviewerIds ?? [],
|
|
46
|
-
affectedFileCount: rawEvent.filesChanged?.length ?? 0,
|
|
47
|
-
affectedFiles: (rawEvent.filesChanged ?? []).slice(0, 10).map(f => f.path),
|
|
48
|
-
totalCommentCount: rawEvent.comments?.length ?? 0,
|
|
49
|
-
unresolvedThreadCount: rawEvent.unresolvedThreadCount ?? 0,
|
|
50
|
-
avgSentiment: Math.round(commentAnalysis.avgSentiment),
|
|
51
|
-
hasTests: rawEvent.hasTests ?? false,
|
|
52
|
-
isBreakingChange: rawEvent.isBreakingChange ?? false,
|
|
53
|
-
reviewAgeDays: rawEvent.reviewAgeDays ?? 0,
|
|
54
|
-
},
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
58
|
-
deriveComplexityScore(event) {
|
|
59
|
-
const fileCount = event.filesChanged?.length ?? 0;
|
|
60
|
-
const avgMagnitude = fileCount > 0
|
|
61
|
-
? (event.filesChanged ?? []).reduce((sum, f) => sum + (f.changeMagnitude ?? 0), 0) / fileCount
|
|
62
|
-
: 0;
|
|
63
|
-
const complexity = fileCount * avgMagnitude;
|
|
64
|
-
if (complexity < 500)
|
|
65
|
-
return Math.round(complexity / 500 * 40);
|
|
66
|
-
if (complexity < 2000)
|
|
67
|
-
return Math.round(40 + (complexity - 500) / 1500 * 25);
|
|
68
|
-
if (complexity < 5000)
|
|
69
|
-
return Math.round(65 + (complexity - 2000) / 3000 * 20);
|
|
70
|
-
return Math.min(100, 85 + (complexity - 5000) / 5000 * 15);
|
|
71
|
-
}
|
|
72
|
-
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
73
|
-
analyzeComments(event) {
|
|
74
|
-
const comments = event.comments ?? [];
|
|
75
|
-
if (comments.length === 0) {
|
|
76
|
-
return { avgSentiment: 0, topNegativeComment: null, unresolvedNegativeCount: 0 };
|
|
77
|
-
}
|
|
78
|
-
let totalSentiment = 0;
|
|
79
|
-
let topNegativeComment = null;
|
|
80
|
-
let topNegativeScore = Infinity;
|
|
81
|
-
for (const c of comments) {
|
|
82
|
-
const sentiment = c.sentimentScore ?? 0;
|
|
83
|
-
totalSentiment += sentiment;
|
|
84
|
-
if (sentiment < 0 && sentiment < topNegativeScore) {
|
|
85
|
-
topNegativeScore = sentiment;
|
|
86
|
-
topNegativeComment = c.body;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return {
|
|
90
|
-
avgSentiment: totalSentiment / comments.length,
|
|
91
|
-
topNegativeComment,
|
|
92
|
-
unresolvedNegativeCount: comments.filter(c => !c.resolvedAt && (c.sentimentScore ?? 0) < 0).length,
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
96
|
-
deriveSentimentScore(event, analysis) {
|
|
97
|
-
const recencyDays = event.reviewAgeDays ?? 0;
|
|
98
|
-
const recencyMultiplier = recencyDays > 7 ? 1.5 : 1.0;
|
|
99
|
-
const negativeCount = analysis.unresolvedNegativeCount * recencyMultiplier;
|
|
100
|
-
const sentimentPain = Math.round((100 - analysis.avgSentiment) / 2);
|
|
101
|
-
const commentPain = Math.min(50, negativeCount * 15);
|
|
102
|
-
return Math.min(100, sentimentPain + commentPain);
|
|
103
|
-
}
|
|
104
|
-
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
105
|
-
deriveProcessViolationScore(event) {
|
|
106
|
-
let score = 0;
|
|
107
|
-
const fileCount = event.filesChanged?.length ?? 0;
|
|
108
|
-
const totalLines = (event.totalLinesAdded ?? 0) + (event.totalLinesDeleted ?? 0);
|
|
109
|
-
const hasTests = event.hasTests ?? false;
|
|
110
|
-
if (!hasTests && fileCount > 2)
|
|
111
|
-
score += 35;
|
|
112
|
-
if (event.isBreakingChange && !(event.labels ?? []).some(l => l.includes('breaking')))
|
|
113
|
-
score += 40;
|
|
114
|
-
const hasSecurityChanges = (event.filesChanged ?? []).some(f => SECURITY_LABELS.some(s => (f.path ?? '').toLowerCase().includes(s)));
|
|
115
|
-
if (hasSecurityChanges && !(event.hasSecurityReview ?? false))
|
|
116
|
-
score += 50;
|
|
117
|
-
if (totalLines > 500 && !hasTests)
|
|
118
|
-
score += 20;
|
|
119
|
-
return Math.min(100, score);
|
|
120
|
-
}
|
|
121
|
-
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
122
|
-
derivePrimaryTrigger(complexity, sentiment, process) {
|
|
123
|
-
if (process >= 40)
|
|
124
|
-
return 'process_violation';
|
|
125
|
-
if (sentiment >= 40)
|
|
126
|
-
return 'negative_sentiment';
|
|
127
|
-
return 'diff_complexity';
|
|
128
|
-
}
|
|
129
|
-
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
130
|
-
buildReason(trigger, event) {
|
|
131
|
-
const reasons = {
|
|
132
|
-
diff_complexity: `Diff complexity pain in ${event.filesChanged?.length ?? 0} files, ${(event.totalLinesAdded ?? 0) + (event.totalLinesDeleted ?? 0)} lines changed`,
|
|
133
|
-
negative_sentiment: `Negative review sentiment: ${event.unresolvedThreadCount ?? 0} unresolved threads`,
|
|
134
|
-
process_violation: `Process violation: no tests=${!event.hasTests}, breaking=${event.isBreakingChange}, security_review=${event.hasSecurityReview}`,
|
|
135
|
-
};
|
|
136
|
-
return reasons[trigger];
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
//# sourceMappingURL=code-review-pain-adapter.js.map
|
|
@@ -1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AAC,CAAC,CAAC,CAAC,CACpE,CAAC;QACF,IAAI,kBAAkB,IAAI,CAAC,CAAC,KAAK,CAAC,iBAAiB,IAAI,KAAK,CAAC;YAAE,KAAK,IAAI,EAAE,CAAC;QAC3E,IAAI,UAAU,GAAG,GAAG,IAAI,CAAC,QAAQ;YAAE,KAAK,IAAI,EAAE,CAAC;QAC/C,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC9B,CAAC;IAED,qEAAqE;IAC7D,oBAAoB,CAAC,UAAkB,EAAE,SAAiB,EAAE,OAAe;QACjF,IAAI,OAAO,IAAI,EAAE;YAAE,OAAO,mBAAmB,CAAC;QAC9C,IAAI,SAAS,IAAI,EAAE;YAAE,OAAO,oBAAoB,CAAC;QACjD,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAED,qEAAqE;IAC7D,WAAW,CAAC,OAA8B,EAAE,KAAkB;QACpE,MAAM,OAAO,GAA0C;YACrD,eAAe,EAAE,2BAA2B,KAAK,CAAC,YAAY,EAAE,MAAM,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,eAAe,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,iBAAiB,IAAI,CAAC,CAAC,gBAAgB;YACnK,kBAAkB,EAAE,8BAA8B,KAAK,CAAC,qBAAqB,IAAI,CAAC,qBAAqB;YACvG,iBAAiB,EAAE,+BAA+B,CAAC,KAAK,CAAC,QAAQ,cAAc,KAAK,CAAC,gBAAgB,qBAAqB,KAAK,CAAC,iBAAiB,EAAE;SACpJ,CAAC;QACF,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC;IAC1B,CAAC;CACF"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Code review domain adapter for principles-core.
|
|
3
|
-
*/
|
|
4
|
-
export type { ReviewEvent, ReviewComment, ChangedFile, ReviewPainTriggerType } from './review-event-types.js';
|
|
5
|
-
export { CodeReviewPainAdapter } from './code-review-pain-adapter.js';
|
|
6
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/code-review/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAC9G,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/adapters/code-review/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Code review event types for principles-core.
|
|
3
|
-
*
|
|
4
|
-
* Per D-01: Code review is an extreme non-coding domain.
|
|
5
|
-
* Pain signals come from human judgment, not tool failures.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Types of pain triggers in code review.
|
|
9
|
-
*/
|
|
10
|
-
export type ReviewPainTriggerType = 'diff_complexity' | 'negative_sentiment' | 'process_violation';
|
|
11
|
-
/**
|
|
12
|
-
* Represents a single review comment or comment thread.
|
|
13
|
-
*/
|
|
14
|
-
export interface ReviewComment {
|
|
15
|
-
id: string;
|
|
16
|
-
authorId: string;
|
|
17
|
-
body: string;
|
|
18
|
-
sentimentScore: number;
|
|
19
|
-
createdAt: string;
|
|
20
|
-
resolvedAt?: string;
|
|
21
|
-
filePath?: string;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* File changed in a PR/review.
|
|
25
|
-
*/
|
|
26
|
-
export interface ChangedFile {
|
|
27
|
-
path: string;
|
|
28
|
-
linesAdded: number;
|
|
29
|
-
linesDeleted: number;
|
|
30
|
-
changeMagnitude: number;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Structured code review event.
|
|
34
|
-
*/
|
|
35
|
-
export interface ReviewEvent {
|
|
36
|
-
prId: string;
|
|
37
|
-
repositoryId: string;
|
|
38
|
-
authorId: string;
|
|
39
|
-
reviewerIds: string[];
|
|
40
|
-
filesChanged: ChangedFile[];
|
|
41
|
-
totalLinesAdded: number;
|
|
42
|
-
totalLinesDeleted: number;
|
|
43
|
-
comments: ReviewComment[];
|
|
44
|
-
unresolvedThreadCount: number;
|
|
45
|
-
createdAt: string;
|
|
46
|
-
reviewAgeDays: number;
|
|
47
|
-
hasTests: boolean;
|
|
48
|
-
hasSecurityReview: boolean;
|
|
49
|
-
isBreakingChange: boolean;
|
|
50
|
-
labels: string[];
|
|
51
|
-
sessionId: string;
|
|
52
|
-
traceId?: string;
|
|
53
|
-
}
|
|
54
|
-
//# sourceMappingURL=review-event-types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"review-event-types.d.ts","sourceRoot":"","sources":["../../../src/adapters/code-review/review-event-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAC7B,iBAAiB,GACjB,oBAAoB,GACpB,mBAAmB,CAAC;AAExB;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,qBAAqB,EAAE,MAAM,CAAC;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC;IAClB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"review-event-types.js","sourceRoot":"","sources":["../../../src/adapters/code-review/review-event-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/coding/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,YAAY,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/adapters/coding/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* OpenClaw event type shims for principles-core.
|
|
3
|
-
*
|
|
4
|
-
* These are DUPLICATED minimal type shapes, NOT imports from openclaw-plugin.
|
|
5
|
-
* principles-core must NOT import from openclaw-plugin.
|
|
6
|
-
* If OpenClaw SDK changes event shapes, these shims must be updated manually.
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Minimal shape of OpenClaw's after_tool_call hook event.
|
|
10
|
-
* Only includes fields used by OpenClawPainAdapter.capture().
|
|
11
|
-
*/
|
|
12
|
-
export interface PluginHookAfterToolCallEvent {
|
|
13
|
-
/** Name of the tool that was called */
|
|
14
|
-
toolName: string;
|
|
15
|
-
/** Error message if the tool call failed */
|
|
16
|
-
error?: string;
|
|
17
|
-
/** Tool call parameters */
|
|
18
|
-
params?: Record<string, unknown>;
|
|
19
|
-
/** Result returned by the tool (success) */
|
|
20
|
-
result?: unknown;
|
|
21
|
-
/** Session ID from the hook context */
|
|
22
|
-
sessionId?: string;
|
|
23
|
-
/** Agent ID from the hook context */
|
|
24
|
-
agentId?: string;
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=openclaw-event-types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"openclaw-event-types.d.ts","sourceRoot":"","sources":["../../../src/adapters/coding/openclaw-event-types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;GAGG;AACH,MAAM,WAAW,4BAA4B;IAC3C,uCAAuC;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2BAA2B;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,4CAA4C;IAC5C,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,uCAAuC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qCAAqC;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* OpenClaw event type shims for principles-core.
|
|
3
|
-
*
|
|
4
|
-
* These are DUPLICATED minimal type shapes, NOT imports from openclaw-plugin.
|
|
5
|
-
* principles-core must NOT import from openclaw-plugin.
|
|
6
|
-
* If OpenClaw SDK changes event shapes, these shims must be updated manually.
|
|
7
|
-
*/
|
|
8
|
-
export {};
|
|
9
|
-
//# sourceMappingURL=openclaw-event-types.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"openclaw-event-types.js","sourceRoot":"","sources":["../../../src/adapters/coding/openclaw-event-types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { PainSignalAdapter } from '../../pain-signal-adapter.js';
|
|
2
|
-
import type { PainSignal } from '../../pain-signal.js';
|
|
3
|
-
import type { PluginHookAfterToolCallEvent } from './openclaw-event-types.js';
|
|
4
|
-
/**
|
|
5
|
-
* OpenClaw-specific PainSignal adapter.
|
|
6
|
-
*
|
|
7
|
-
* Translates OpenClaw after_tool_call hook events to PainSignals.
|
|
8
|
-
* Per D-02: pure translation only. No GFI checks, no session logic.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* const adapter = new OpenClawPainAdapter();
|
|
12
|
-
* const signal = adapter.capture({ toolName: 'write', error: 'ENOENT' });
|
|
13
|
-
* if (signal) { /* process signal *\/ }
|
|
14
|
-
*/
|
|
15
|
-
export declare class OpenClawPainAdapter implements PainSignalAdapter<PluginHookAfterToolCallEvent> {
|
|
16
|
-
capture(rawEvent: PluginHookAfterToolCallEvent): PainSignal | null;
|
|
17
|
-
/**
|
|
18
|
-
* Derive pain score from error message and tool name.
|
|
19
|
-
* Higher scores for more severe/critical errors.
|
|
20
|
-
*/
|
|
21
|
-
private deriveScoreFromError;
|
|
22
|
-
/**
|
|
23
|
-
* Build trigger text preview from tool params.
|
|
24
|
-
*/
|
|
25
|
-
private buildTriggerPreview;
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=openclaw-pain-adapter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"openclaw-pain-adapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/coding/openclaw-pain-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AAE9E;;;;;;;;;;GAUG;AACH,qBAAa,mBAAoB,YAAW,iBAAiB,CAAC,4BAA4B,CAAC;IACzF,OAAO,CAAC,QAAQ,EAAE,4BAA4B,GAAG,UAAU,GAAG,IAAI,CA8BjE;IAED;;;OAGG;IAEH,OAAO,CAAC,oBAAoB;IAwC5B;;OAEG;IAEH,OAAO,CAAC,mBAAmB;CAgB5B"}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { deriveSeverity } from '../../pain-signal.js';
|
|
2
|
-
/**
|
|
3
|
-
* OpenClaw-specific PainSignal adapter.
|
|
4
|
-
*
|
|
5
|
-
* Translates OpenClaw after_tool_call hook events to PainSignals.
|
|
6
|
-
* Per D-02: pure translation only. No GFI checks, no session logic.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* const adapter = new OpenClawPainAdapter();
|
|
10
|
-
* const signal = adapter.capture({ toolName: 'write', error: 'ENOENT' });
|
|
11
|
-
* if (signal) { /* process signal *\/ }
|
|
12
|
-
*/
|
|
13
|
-
export class OpenClawPainAdapter {
|
|
14
|
-
capture(rawEvent) {
|
|
15
|
-
// Non-failure: return null
|
|
16
|
-
if (!rawEvent.error) {
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
// Malformed: missing required fields
|
|
20
|
-
if (!rawEvent.toolName || typeof rawEvent.toolName !== 'string') {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
// Derive score from error characteristics
|
|
24
|
-
const score = this.deriveScoreFromError(rawEvent.error, rawEvent.toolName);
|
|
25
|
-
return {
|
|
26
|
-
source: 'tool_failure',
|
|
27
|
-
score,
|
|
28
|
-
timestamp: new Date().toISOString(),
|
|
29
|
-
reason: `Tool ${rawEvent.toolName} failed: ${rawEvent.error}`,
|
|
30
|
-
sessionId: rawEvent.sessionId ?? 'unknown',
|
|
31
|
-
agentId: rawEvent.agentId ?? 'unknown',
|
|
32
|
-
traceId: rawEvent.sessionId ?? 'unknown', // Use sessionId as traceId proxy
|
|
33
|
-
triggerTextPreview: this.buildTriggerPreview(rawEvent),
|
|
34
|
-
domain: 'coding',
|
|
35
|
-
severity: deriveSeverity(score),
|
|
36
|
-
context: {
|
|
37
|
-
toolName: rawEvent.toolName,
|
|
38
|
-
hasParams: !!rawEvent.params,
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Derive pain score from error message and tool name.
|
|
44
|
-
* Higher scores for more severe/critical errors.
|
|
45
|
-
*/
|
|
46
|
-
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
47
|
-
deriveScoreFromError(error, _toolName) {
|
|
48
|
-
const err = error.toLowerCase();
|
|
49
|
-
// Critical errors: file system corruption, security violations
|
|
50
|
-
if (err.includes('permission denied') || err.includes('eacces')) {
|
|
51
|
-
return 95;
|
|
52
|
-
}
|
|
53
|
-
if (err.includes('enoent') || err.includes('no such file')) {
|
|
54
|
-
return 80; // Common but severe in coding context
|
|
55
|
-
}
|
|
56
|
-
if (err.includes('eisdir') || err.includes('eisfdir')) {
|
|
57
|
-
return 85;
|
|
58
|
-
}
|
|
59
|
-
// High severity: validation failures, type errors
|
|
60
|
-
if (err.includes('syntaxerror') || err.includes('parseerror')) {
|
|
61
|
-
return 82;
|
|
62
|
-
}
|
|
63
|
-
if (err.includes('typeerror') || err.includes('invalid type')) {
|
|
64
|
-
return 75;
|
|
65
|
-
}
|
|
66
|
-
if (err.includes('referenceerror')) {
|
|
67
|
-
return 72;
|
|
68
|
-
}
|
|
69
|
-
// Medium severity: operational failures
|
|
70
|
-
if (err.includes('timeout') || err.includes('etimedout')) {
|
|
71
|
-
return 60;
|
|
72
|
-
}
|
|
73
|
-
if (err.includes('econnrefused') || err.includes('network')) {
|
|
74
|
-
return 65;
|
|
75
|
-
}
|
|
76
|
-
if (err.includes('enotempty') || err.includes('eexist')) {
|
|
77
|
-
return 55;
|
|
78
|
-
}
|
|
79
|
-
// Default: treat as moderate operational failure
|
|
80
|
-
return 50;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Build trigger text preview from tool params.
|
|
84
|
-
*/
|
|
85
|
-
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
86
|
-
buildTriggerPreview(event) {
|
|
87
|
-
if (!event.params)
|
|
88
|
-
return '';
|
|
89
|
-
const p = event.params;
|
|
90
|
-
// Common params across write/edit tools
|
|
91
|
-
const filePath = p.file_path || p.path || p.file || '';
|
|
92
|
-
const newString = p.new_string || p.content || '';
|
|
93
|
-
if (filePath) {
|
|
94
|
-
return `${event.toolName}(${filePath})`;
|
|
95
|
-
}
|
|
96
|
-
if (newString && newString.length > 50) {
|
|
97
|
-
return `${event.toolName}(${newString.slice(0, 50)}...)`;
|
|
98
|
-
}
|
|
99
|
-
return event.toolName;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
//# sourceMappingURL=openclaw-pain-adapter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"openclaw-pain-adapter.js","sourceRoot":"","sources":["../../../src/adapters/coding/openclaw-pain-adapter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD;;;;;;;;;;GAUG;AACH,MAAM,OAAO,mBAAmB;IAC9B,OAAO,CAAC,QAAsC;QAC5C,2BAA2B;QAC3B,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;YACpB,OAAO,IAAI,CAAC;QACd,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AE7B,MAAM,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC;QACvB,wCAAwC;QACxC,MAAM,QAAQ,GAAI,CAAC,CAAC,SAAoB,IAAK,CAAC,CAAC,IAAe,IAAK,CAAC,CAAC,IAAe,IAAI,EAAE,CAAC;QAC3F,MAAM,SAAS,GAAI,CAAC,CAAC,UAAqB,IAAK,CAAC,CAAC,OAAkB,IAAI,EAAE,CAAC;QAE1E,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,GAAG,KAAK,CAAC,QAAQ,IAAI,QAAQ,GAAG,CAAC;QAC1C,CAAC;QACD,IAAI,SAAS,IAAI,SAAS,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;YACvC,OAAO,GAAG,KAAK,CAAC,QAAQ,IAAI,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC;QAC3D,CAAC;QACD,OAAO,KAAK,CAAC,QAAQ,CAAC;IACxB,CAAC;CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/writing/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,YAAY,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/adapters/writing/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { PainSignalAdapter } from '../../pain-signal-adapter.js';
|
|
2
|
-
import type { PainSignal } from '../../pain-signal.js';
|
|
3
|
-
import type { TextAnalysisResult } from './writing-types.js';
|
|
4
|
-
/**
|
|
5
|
-
* Writing domain PainSignal adapter.
|
|
6
|
-
*
|
|
7
|
-
* Translates upstream text quality analysis results into PainSignals.
|
|
8
|
-
* Per D-02: pure translation only. No LLM calls, no quality evaluation.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* const adapter = new WritingPainAdapter();
|
|
12
|
-
* const analysis = { issueType: 'style_inconsistency', severityScore: 65, description: '...', excerpt: '...', sessionId: 'sess-1' };
|
|
13
|
-
* const signal = adapter.capture(analysis);
|
|
14
|
-
*/
|
|
15
|
-
export declare class WritingPainAdapter implements PainSignalAdapter<TextAnalysisResult> {
|
|
16
|
-
capture(rawEvent: TextAnalysisResult): PainSignal | null;
|
|
17
|
-
/**
|
|
18
|
-
* Build human-readable reason string.
|
|
19
|
-
*/
|
|
20
|
-
private buildReason;
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=writing-pain-adapter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"writing-pain-adapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/writing/writing-pain-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,KAAK,EAAE,kBAAkB,EAAoB,MAAM,oBAAoB,CAAC;AAE/E;;;;;;;;;;GAUG;AACH,qBAAa,kBAAmB,YAAW,iBAAiB,CAAC,kBAAkB,CAAC;IAC9E,OAAO,CAAC,QAAQ,EAAE,kBAAkB,GAAG,UAAU,GAAG,IAAI,CAuCvD;IAED;;OAEG;IAEH,OAAO,CAAC,WAAW;CASpB"}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { deriveSeverity } from '../../pain-signal.js';
|
|
2
|
-
/**
|
|
3
|
-
* Writing domain PainSignal adapter.
|
|
4
|
-
*
|
|
5
|
-
* Translates upstream text quality analysis results into PainSignals.
|
|
6
|
-
* Per D-02: pure translation only. No LLM calls, no quality evaluation.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* const adapter = new WritingPainAdapter();
|
|
10
|
-
* const analysis = { issueType: 'style_inconsistency', severityScore: 65, description: '...', excerpt: '...', sessionId: 'sess-1' };
|
|
11
|
-
* const signal = adapter.capture(analysis);
|
|
12
|
-
*/
|
|
13
|
-
export class WritingPainAdapter {
|
|
14
|
-
capture(rawEvent) {
|
|
15
|
-
// Malformed: missing required fields
|
|
16
|
-
if (!rawEvent.issueType || rawEvent.severityScore === undefined) {
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
// Malformed: severityScore out of range
|
|
20
|
-
if (typeof rawEvent.severityScore !== 'number' ||
|
|
21
|
-
rawEvent.severityScore < 0 ||
|
|
22
|
-
rawEvent.severityScore > 100) {
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
// Malformed: missing sessionId
|
|
26
|
-
if (!rawEvent.sessionId || typeof rawEvent.sessionId !== 'string') {
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
// Derive score from upstream severityScore
|
|
30
|
-
const score = Math.round(rawEvent.severityScore);
|
|
31
|
-
return {
|
|
32
|
-
source: rawEvent.issueType,
|
|
33
|
-
score,
|
|
34
|
-
timestamp: new Date().toISOString(),
|
|
35
|
-
reason: this.buildReason(rawEvent.issueType, rawEvent.description),
|
|
36
|
-
sessionId: rawEvent.sessionId,
|
|
37
|
-
agentId: 'writing-evaluator',
|
|
38
|
-
traceId: rawEvent.traceId ?? 'unknown',
|
|
39
|
-
triggerTextPreview: rawEvent.excerpt.slice(0, 200),
|
|
40
|
-
domain: 'writing',
|
|
41
|
-
severity: deriveSeverity(score),
|
|
42
|
-
context: {
|
|
43
|
-
issueType: rawEvent.issueType,
|
|
44
|
-
excerptLength: rawEvent.excerpt.length,
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Build human-readable reason string.
|
|
50
|
-
*/
|
|
51
|
-
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
52
|
-
buildReason(issueType, description) {
|
|
53
|
-
const labels = {
|
|
54
|
-
text_coherence_violation: 'Text coherence violation',
|
|
55
|
-
style_inconsistency: 'Style inconsistency',
|
|
56
|
-
narrative_arc_break: 'Narrative arc break',
|
|
57
|
-
tone_mismatch: 'Tone mismatch',
|
|
58
|
-
};
|
|
59
|
-
return `${labels[issueType]}: ${description}`;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
//# sourceMappingURL=writing-pain-adapter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"writing-pain-adapter.js","sourceRoot":"","sources":["../../../src/adapters/writing/writing-pain-adapter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD;;;;;;;;;;GAUG;AACH,MAAM,OAAO,kBAAkB;IAC7B,OAAO,CAAC,QAA4B;QAClC,qCAAqC;QACrC,IAAI,CAAC,QAAQ,CAAC,SAAS,IAAI,QAAQ,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;YAChE,OAAO,IAAI,CAAC;QACd,CAAC;QAED,wCAAwC;QACxC,IACE,OAAO,QAAQ,CAAC,aAAa,KAAK,QAAQ;YAC1C,QAAQ,CAAC,aAAa,GAAG,CAAC;YAC1B,QAAQ,CAAC,aAAa,GAAG,GAAG,EAC5B,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;QAED,+BAA+B;QAC/B,IAAI,CAAC,QAAQ,CAAC,SAAS,IAAI,OAAO,QAAQ,CAAC,SAAS,KAAK,QAAQ,EAAE,CAAC;YAClE,OAAO,IAAI,CAAC;QACd,CAAC;QAED,2CAA2C;QAC3C,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;QAEjD,OAAO;YACL,MAAM,EAAE,QAAQ,CAAC,SAAS;YAC1B,KAAK;YACL,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,WAAW,CAAC;YAClE,SAAS,EAAE,QAAQ,CAAC,SAAS;YAC7B,OAAO,EAAE,mBAAmB;YAC5B,OAAO,EAAE,QAAQ,CAAC,OAAO,IAAI,SAAS;YACtC,kBAAkB,EAAE,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC;YAClD,MAAM,EAAE,SAAS;YACjB,QAAQ,EAAE,cAAc,CAAC,KAAK,CAAC;YAC/B,OAAO,EAAE;gBACP,SAAS,EAAE,QAAQ,CAAC,SAAS;gBAC7B,aAAa,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM;aACvC;SACF,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,qEAAqE;IAC7D,WAAW,CAAC,SAA2B,EAAE,WAAmB;QAClE,MAAM,MAAM,GAAqC;YAC/C,wBAAwB,EAAE,0BAA0B;YACpD,mBAAmB,EAAE,qBAAqB;YAC1C,mBAAmB,EAAE,qBAAqB;YAC1C,aAAa,EAAE,eAAe;SAC/B,CAAC;QACF,OAAO,GAAG,MAAM,CAAC,SAAS,CAAC,KAAK,WAAW,EAAE,CAAC;IAChD,CAAC;CACF"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Writing domain types for principles-core.
|
|
3
|
-
*
|
|
4
|
-
* Per D-01: Writing adapter receives pre-evaluated TextAnalysisResult
|
|
5
|
-
* from an upstream quality evaluator. The adapter does pure translation
|
|
6
|
-
* only — no LLM calls, no external dependencies.
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Issue types for creative writing quality problems.
|
|
10
|
-
* These are produced by an upstream text quality evaluator.
|
|
11
|
-
*/
|
|
12
|
-
export type WritingIssueType = 'text_coherence_violation' | 'style_inconsistency' | 'narrative_arc_break' | 'tone_mismatch';
|
|
13
|
-
/**
|
|
14
|
-
* Structured text analysis result from upstream quality evaluator.
|
|
15
|
-
*
|
|
16
|
-
* The evaluator is OUTSIDE this adapter. The adapter only translates
|
|
17
|
-
* this structured result into a PainSignal. This keeps the adapter
|
|
18
|
-
* pure and testable with synthetic data.
|
|
19
|
-
*/
|
|
20
|
-
export interface TextAnalysisResult {
|
|
21
|
-
/** Type of quality issue detected */
|
|
22
|
-
issueType: WritingIssueType;
|
|
23
|
-
/** Quality score 0-100 (higher = more severe issue) */
|
|
24
|
-
severityScore: number;
|
|
25
|
-
/** Description of the quality issue */
|
|
26
|
-
description: string;
|
|
27
|
-
/** Text snippet that triggered the issue */
|
|
28
|
-
excerpt: string;
|
|
29
|
-
/** Session ID from the conversation */
|
|
30
|
-
sessionId: string;
|
|
31
|
-
/** Optional trace ID for correlation */
|
|
32
|
-
traceId?: string;
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=writing-types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"writing-types.d.ts","sourceRoot":"","sources":["../../../src/adapters/writing/writing-types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GACxB,0BAA0B,GAC1B,qBAAqB,GACrB,qBAAqB,GACrB,eAAe,CAAC;AAEpB;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IACjC,qCAAqC;IACrC,SAAS,EAAE,gBAAgB,CAAC;IAC5B,uDAAuD;IACvD,aAAa,EAAE,MAAM,CAAC;IACtB,uCAAuC;IACvC,WAAW,EAAE,MAAM,CAAC;IACpB,4CAA4C;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,uCAAuC;IACvC,SAAS,EAAE,MAAM,CAAC;IAClB,wCAAwC;IACxC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Writing domain types for principles-core.
|
|
3
|
-
*
|
|
4
|
-
* Per D-01: Writing adapter receives pre-evaluated TextAnalysisResult
|
|
5
|
-
* from an upstream quality evaluator. The adapter does pure translation
|
|
6
|
-
* only — no LLM calls, no external dependencies.
|
|
7
|
-
*/
|
|
8
|
-
export {};
|
|
9
|
-
//# sourceMappingURL=writing-types.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"writing-types.js","sourceRoot":"","sources":["../../../src/adapters/writing/writing-types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|