principles-disciple 1.7.6 → 1.7.8
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/commands/context.js +5 -15
- package/dist/commands/evolution-status.js +2 -9
- package/dist/commands/export.js +61 -8
- package/dist/commands/nocturnal-review.d.ts +24 -0
- package/dist/commands/nocturnal-review.js +265 -0
- package/dist/commands/nocturnal-rollout.d.ts +27 -0
- package/dist/commands/nocturnal-rollout.js +671 -0
- package/dist/commands/nocturnal-train.d.ts +25 -0
- package/dist/commands/nocturnal-train.js +919 -0
- package/dist/commands/pain.js +8 -21
- package/dist/constants/tools.d.ts +2 -2
- package/dist/constants/tools.js +1 -1
- package/dist/core/adaptive-thresholds.d.ts +186 -0
- package/dist/core/adaptive-thresholds.js +300 -0
- package/dist/core/config.d.ts +2 -38
- package/dist/core/config.js +6 -61
- package/dist/core/event-log.d.ts +1 -2
- package/dist/core/event-log.js +0 -3
- package/dist/core/evolution-engine.js +1 -21
- package/dist/core/evolution-reducer.d.ts +7 -1
- package/dist/core/evolution-reducer.js +56 -4
- package/dist/core/evolution-types.d.ts +61 -9
- package/dist/core/evolution-types.js +31 -9
- package/dist/core/external-training-contract.d.ts +276 -0
- package/dist/core/external-training-contract.js +269 -0
- package/dist/core/local-worker-routing.d.ts +175 -0
- package/dist/core/local-worker-routing.js +525 -0
- package/dist/core/model-deployment-registry.d.ts +218 -0
- package/dist/core/model-deployment-registry.js +503 -0
- package/dist/core/model-training-registry.d.ts +295 -0
- package/dist/core/model-training-registry.js +475 -0
- package/dist/core/nocturnal-arbiter.d.ts +159 -0
- package/dist/core/nocturnal-arbiter.js +534 -0
- package/dist/core/nocturnal-candidate-scoring.d.ts +137 -0
- package/dist/core/nocturnal-candidate-scoring.js +266 -0
- package/dist/core/nocturnal-compliance.d.ts +175 -0
- package/dist/core/nocturnal-compliance.js +824 -0
- package/dist/core/nocturnal-dataset.d.ts +224 -0
- package/dist/core/nocturnal-dataset.js +443 -0
- package/dist/core/nocturnal-executability.d.ts +85 -0
- package/dist/core/nocturnal-executability.js +331 -0
- package/dist/core/nocturnal-export.d.ts +124 -0
- package/dist/core/nocturnal-export.js +275 -0
- package/dist/core/nocturnal-paths.d.ts +124 -0
- package/dist/core/nocturnal-paths.js +214 -0
- package/dist/core/nocturnal-trajectory-extractor.d.ts +242 -0
- package/dist/core/nocturnal-trajectory-extractor.js +307 -0
- package/dist/core/nocturnal-trinity.d.ts +311 -0
- package/dist/core/nocturnal-trinity.js +880 -0
- package/dist/core/paths.d.ts +6 -0
- package/dist/core/paths.js +6 -0
- package/dist/core/principle-training-state.d.ts +121 -0
- package/dist/core/principle-training-state.js +321 -0
- package/dist/core/promotion-gate.d.ts +238 -0
- package/dist/core/promotion-gate.js +529 -0
- package/dist/core/session-tracker.d.ts +10 -0
- package/dist/core/session-tracker.js +14 -0
- package/dist/core/shadow-observation-registry.d.ts +217 -0
- package/dist/core/shadow-observation-registry.js +308 -0
- package/dist/core/training-program.d.ts +233 -0
- package/dist/core/training-program.js +433 -0
- package/dist/core/trajectory.d.ts +95 -1
- package/dist/core/trajectory.js +220 -6
- package/dist/core/workspace-context.d.ts +0 -6
- package/dist/core/workspace-context.js +0 -12
- package/dist/hooks/bash-risk.d.ts +6 -6
- package/dist/hooks/bash-risk.js +8 -8
- package/dist/hooks/gate-block-helper.js +1 -1
- package/dist/hooks/gate.d.ts +1 -1
- package/dist/hooks/gate.js +2 -2
- package/dist/hooks/gfi-gate.d.ts +3 -3
- package/dist/hooks/gfi-gate.js +15 -14
- package/dist/hooks/pain.js +6 -9
- package/dist/hooks/progressive-trust-gate.d.ts +21 -49
- package/dist/hooks/progressive-trust-gate.js +51 -204
- package/dist/hooks/prompt.d.ts +11 -11
- package/dist/hooks/prompt.js +158 -72
- package/dist/hooks/subagent.js +43 -6
- package/dist/i18n/commands.js +8 -8
- package/dist/index.js +129 -28
- package/dist/service/evolution-worker.d.ts +42 -4
- package/dist/service/evolution-worker.js +321 -13
- package/dist/service/nocturnal-runtime.d.ts +183 -0
- package/dist/service/nocturnal-runtime.js +352 -0
- package/dist/service/nocturnal-service.d.ts +163 -0
- package/dist/service/nocturnal-service.js +787 -0
- package/dist/service/nocturnal-target-selector.d.ts +145 -0
- package/dist/service/nocturnal-target-selector.js +315 -0
- package/dist/service/phase3-input-filter.d.ts +2 -23
- package/dist/service/phase3-input-filter.js +3 -27
- package/dist/service/runtime-summary-service.d.ts +0 -10
- package/dist/service/runtime-summary-service.js +1 -54
- package/dist/tools/deep-reflect.js +2 -1
- package/dist/types/event-types.d.ts +2 -10
- package/dist/types/runtime-summary.d.ts +1 -8
- package/dist/types.d.ts +0 -3
- package/dist/types.js +0 -2
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/templates/langs/en/skills/pd-mentor/SKILL.md +5 -5
- package/templates/langs/zh/skills/pd-mentor/SKILL.md +5 -5
- package/templates/pain_settings.json +0 -6
- package/dist/commands/trust.d.ts +0 -4
- package/dist/commands/trust.js +0 -78
- package/dist/core/trust-engine.d.ts +0 -96
- package/dist/core/trust-engine.js +0 -286
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import * as fs from 'fs';
|
|
2
2
|
import * as path from 'path';
|
|
3
3
|
import { readPainFlagData } from '../core/pain.js';
|
|
4
|
-
import { resolvePdPath } from '../core/paths.js';
|
|
5
4
|
import { listSessions } from '../core/session-tracker.js';
|
|
6
5
|
import { WorkspaceContext } from '../core/workspace-context.js';
|
|
7
6
|
import { evaluatePhase3Inputs } from './phase3-input-filter.js';
|
|
8
7
|
import { TrajectoryRegistry } from '../core/trajectory.js';
|
|
9
8
|
const MAX_SOURCE_EVENTS = 5;
|
|
10
|
-
const LEGACY_TRUST_REWARD_POLICY = 'frozen_all_positive';
|
|
11
9
|
const GFI_PARTIAL_WARNING = 'GFI source attribution remains partial in Phase 2b because only the empathy slice is source-attributed; most non-empathy friction still lacks full per-source attribution.';
|
|
12
10
|
const DAILY_GFI_WARNING = 'daily-stats.gfi is not authoritative in Phase 1 and is used only as a fallback reference.';
|
|
13
11
|
const EVENT_BUFFER_WARNING = 'Live event buffer is unavailable in this context, so status may lag until events.jsonl flushes.';
|
|
@@ -61,8 +59,7 @@ export class RuntimeSummaryService {
|
|
|
61
59
|
const directiveSummary = this.buildDirectiveSummary(queue, directive, generatedAt, warnings);
|
|
62
60
|
const painFlag = readPainFlagData(workspaceDir);
|
|
63
61
|
const painCandidates = this.readJsonFile(wctx.resolve('PAIN_CANDIDATES'), warnings, false);
|
|
64
|
-
const
|
|
65
|
-
const phase3Inputs = evaluatePhase3Inputs(queue ?? [], legacyTrust.phase3Input);
|
|
62
|
+
const phase3Inputs = evaluatePhase3Inputs(queue ?? []);
|
|
66
63
|
const lastPainSignal = this.findLastPainSignal(events, selectedSessionId);
|
|
67
64
|
const gfiSources = this.buildGfiSources(events, selectedSessionId);
|
|
68
65
|
const gateStats = this.buildGateStats(events, selectedSessionId, warnings);
|
|
@@ -79,12 +76,6 @@ export class RuntimeSummaryService {
|
|
|
79
76
|
lastUpdated: generatedAt,
|
|
80
77
|
},
|
|
81
78
|
activeSessions: activeSessionIds,
|
|
82
|
-
currentTrustScore: legacyTrust.phase3Input.score ?? null,
|
|
83
|
-
workspaceState: {
|
|
84
|
-
frozen: legacyTrust.phase3Input.frozen ?? null,
|
|
85
|
-
lastUpdated: legacyTrust.phase3Input.lastUpdated ?? null,
|
|
86
|
-
trustClassification: phase3Inputs.trust.classification,
|
|
87
|
-
},
|
|
88
79
|
};
|
|
89
80
|
// Build analytics truth section (historical data for insights)
|
|
90
81
|
const analyticsTruth = {
|
|
@@ -96,7 +87,6 @@ export class RuntimeSummaryService {
|
|
|
96
87
|
timeoutRate: trajectoryStats.failures > 0
|
|
97
88
|
? trajectoryStats.failures / (trajectoryStats.assistantTurns + trajectoryStats.userTurns || 1)
|
|
98
89
|
: 0,
|
|
99
|
-
trustChanges: 0, // Not tracked in current trajectory schema
|
|
100
90
|
lastUpdated: trajectoryStats.lastIngestAt ?? generatedAt,
|
|
101
91
|
},
|
|
102
92
|
dailyStats: {
|
|
@@ -119,7 +109,6 @@ export class RuntimeSummaryService {
|
|
|
119
109
|
sources: gfiSources,
|
|
120
110
|
dataQuality: 'partial',
|
|
121
111
|
},
|
|
122
|
-
legacyTrust: legacyTrust.summary,
|
|
123
112
|
evolution: {
|
|
124
113
|
queue: queueStats,
|
|
125
114
|
directive: directiveSummary,
|
|
@@ -127,14 +116,12 @@ export class RuntimeSummaryService {
|
|
|
127
116
|
},
|
|
128
117
|
phase3: {
|
|
129
118
|
queueTruthReady: phase3Inputs.queueTruthReady,
|
|
130
|
-
trustInputReady: phase3Inputs.trustInputReady,
|
|
131
119
|
phase3ShadowEligible: phase3Inputs.phase3ShadowEligible,
|
|
132
120
|
evolutionEligible: phase3Inputs.evolution.eligible.length,
|
|
133
121
|
evolutionReferenceOnly: phase3Inputs.evolution.referenceOnly.length,
|
|
134
122
|
evolutionReferenceOnlyReasons: [...new Set(phase3Inputs.evolution.referenceOnly.map((entry) => entry.classification))],
|
|
135
123
|
evolutionRejected: phase3Inputs.evolution.rejected.length,
|
|
136
124
|
evolutionRejectedReasons: phase3Inputs.evolution.rejected.flatMap((entry) => entry.reasons),
|
|
137
|
-
trustRejectedReasons: phase3Inputs.trust.rejectedReasons,
|
|
138
125
|
legacyDirectiveFilePresent: directive !== null,
|
|
139
126
|
directiveStatus: directive ? 'compatibility-only' : 'missing',
|
|
140
127
|
directiveIgnoredReason: 'queue is only truth source',
|
|
@@ -263,46 +250,6 @@ export class RuntimeSummaryService {
|
|
|
263
250
|
taskPreview: derivedTaskPreview,
|
|
264
251
|
};
|
|
265
252
|
}
|
|
266
|
-
static readLegacyTrust(scorecardPath, wctx, warnings) {
|
|
267
|
-
const scorecard = this.readJsonFile(scorecardPath, warnings, false);
|
|
268
|
-
const score = Number.isFinite(scorecard?.trust_score) ? Number(scorecard?.trust_score) : null;
|
|
269
|
-
const rawFrozen = scorecard?.frozen === true ? true : false;
|
|
270
|
-
const settings = wctx.config.get('trust');
|
|
271
|
-
const stageThresholds = settings?.stages ?? {
|
|
272
|
-
stage_1_observer: 30,
|
|
273
|
-
stage_2_editor: 60,
|
|
274
|
-
stage_3_developer: 80,
|
|
275
|
-
};
|
|
276
|
-
let stage = null;
|
|
277
|
-
if (score !== null) {
|
|
278
|
-
if (score < (stageThresholds.stage_1_observer ?? 30)) {
|
|
279
|
-
stage = 1;
|
|
280
|
-
}
|
|
281
|
-
else if (score < (stageThresholds.stage_2_editor ?? 60)) {
|
|
282
|
-
stage = 2;
|
|
283
|
-
}
|
|
284
|
-
else if (score < (stageThresholds.stage_3_developer ?? 80)) {
|
|
285
|
-
stage = 3;
|
|
286
|
-
}
|
|
287
|
-
else {
|
|
288
|
-
stage = 4;
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
return {
|
|
292
|
-
summary: {
|
|
293
|
-
score,
|
|
294
|
-
stage,
|
|
295
|
-
frozen: true,
|
|
296
|
-
lastUpdated: scorecard?.last_updated ?? null,
|
|
297
|
-
rewardPolicy: LEGACY_TRUST_REWARD_POLICY,
|
|
298
|
-
},
|
|
299
|
-
phase3Input: {
|
|
300
|
-
score,
|
|
301
|
-
frozen: rawFrozen,
|
|
302
|
-
lastUpdated: scorecard?.last_updated ?? null,
|
|
303
|
-
},
|
|
304
|
-
};
|
|
305
|
-
}
|
|
306
253
|
static readEvents(eventsPath, warnings) {
|
|
307
254
|
if (!fs.existsSync(eventsPath)) {
|
|
308
255
|
warnings.push('No events.jsonl file exists yet; recent pain and gate summaries are partial.');
|
|
@@ -12,8 +12,9 @@ import { reflectionLogRetentionDays } from '../types.js';
|
|
|
12
12
|
*/
|
|
13
13
|
function writeToReflectionLog(workspaceDir, context, insights, modelId, depth) {
|
|
14
14
|
const reflectionLogPath = resolvePdPath(workspaceDir, 'REFLECTION_LOG');
|
|
15
|
+
// Ensure memory directory exists (backward-compatible: create if missing)
|
|
16
|
+
// Note: resolvePdPath returns the full path; ensure parent dir exists
|
|
15
17
|
const memoryDir = path.dirname(reflectionLogPath);
|
|
16
|
-
// Ensure memory directory exists
|
|
17
18
|
if (!fs.existsSync(memoryDir)) {
|
|
18
19
|
fs.mkdirSync(memoryDir, { recursive: true });
|
|
19
20
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Event types for structured logging and daily statistics.
|
|
3
3
|
*/
|
|
4
|
-
export type EventType = 'tool_call' | 'pain_signal' | 'rule_match' | 'rule_promotion' | 'hook_execution' | 'gate_block' | 'gate_bypass' | 'plan_approval' | 'evolution_task' | 'deep_reflection' | '
|
|
4
|
+
export type EventType = 'tool_call' | 'pain_signal' | 'rule_match' | 'rule_promotion' | 'hook_execution' | 'gate_block' | 'gate_bypass' | 'plan_approval' | 'evolution_task' | 'deep_reflection' | 'empathy_rollback' | 'error' | 'warn';
|
|
5
5
|
export type EventCategory = 'success' | 'failure' | 'detected' | 'blocked' | 'bypassed' | 'approved' | 'enqueued' | 'completed' | 'promoted' | 'passed' | 'changed' | 'rolled_back';
|
|
6
6
|
/**
|
|
7
7
|
* Base event structure for JSONL logging.
|
|
@@ -22,12 +22,6 @@ export interface EventLogEntry {
|
|
|
22
22
|
/** Event-specific data */
|
|
23
23
|
data: Record<string, unknown>;
|
|
24
24
|
}
|
|
25
|
-
export interface TrustChangeEventData {
|
|
26
|
-
previousScore: number;
|
|
27
|
-
newScore: number;
|
|
28
|
-
delta: number;
|
|
29
|
-
reason: string;
|
|
30
|
-
}
|
|
31
25
|
export interface ToolCallEventData {
|
|
32
26
|
toolName: string;
|
|
33
27
|
filePath?: string;
|
|
@@ -81,9 +75,7 @@ export interface GateBlockEventData {
|
|
|
81
75
|
export interface GateBypassEventData {
|
|
82
76
|
toolName: string;
|
|
83
77
|
filePath: string;
|
|
84
|
-
bypassType: 'stage4_architect' | '
|
|
85
|
-
trustScore: number;
|
|
86
|
-
trustStage: number;
|
|
78
|
+
bypassType: 'stage4_architect' | 'whitelisted';
|
|
87
79
|
}
|
|
88
80
|
export interface PlanApprovalEventData {
|
|
89
81
|
toolName: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Runtime truth represents the current state of the system.
|
|
3
3
|
* Used for control decisions, Phase 3 eligibility, and real-time operations.
|
|
4
|
-
* Sources: queue state,
|
|
4
|
+
* Sources: queue state, active session registry
|
|
5
5
|
*/
|
|
6
6
|
export interface RuntimeTruth {
|
|
7
7
|
queueState: {
|
|
@@ -12,12 +12,6 @@ export interface RuntimeTruth {
|
|
|
12
12
|
lastUpdated: string;
|
|
13
13
|
};
|
|
14
14
|
activeSessions: string[];
|
|
15
|
-
currentTrustScore: number | null;
|
|
16
|
-
workspaceState: {
|
|
17
|
-
frozen: boolean | null;
|
|
18
|
-
lastUpdated: string | null;
|
|
19
|
-
trustClassification: 'authoritative' | 'unknown' | 'rejected';
|
|
20
|
-
};
|
|
21
15
|
}
|
|
22
16
|
/**
|
|
23
17
|
* Analytics truth represents historical data and aggregated metrics.
|
|
@@ -30,7 +24,6 @@ export interface AnalyticsTruth {
|
|
|
30
24
|
totalTasks: number;
|
|
31
25
|
successRate: number;
|
|
32
26
|
timeoutRate: number;
|
|
33
|
-
trustChanges: number;
|
|
34
27
|
lastUpdated: string;
|
|
35
28
|
};
|
|
36
29
|
dailyStats: {
|
package/dist/types.d.ts
CHANGED
|
@@ -22,8 +22,6 @@ export interface ContextInjectionConfig {
|
|
|
22
22
|
projectFocus: ProjectFocusMode;
|
|
23
23
|
/** Reflection log - can be toggled */
|
|
24
24
|
reflectionLog: boolean;
|
|
25
|
-
/** Trust score awareness - can be toggled */
|
|
26
|
-
trustScore: boolean;
|
|
27
25
|
/** Evolution task context injection settings */
|
|
28
26
|
evolutionContext: EvolutionContextConfig;
|
|
29
27
|
}
|
|
@@ -34,7 +32,6 @@ export interface ContextInjectionConfig {
|
|
|
34
32
|
* - thinkingOs: true (can be turned off)
|
|
35
33
|
* - projectFocus: 'off' (default closed, user can enable)
|
|
36
34
|
* - reflectionLog: true (default on)
|
|
37
|
-
* - trustScore: true (can be turned off)
|
|
38
35
|
*/
|
|
39
36
|
export declare const defaultContextConfig: ContextInjectionConfig;
|
|
40
37
|
/**
|
package/dist/types.js
CHANGED
|
@@ -5,13 +5,11 @@
|
|
|
5
5
|
* - thinkingOs: true (can be turned off)
|
|
6
6
|
* - projectFocus: 'off' (default closed, user can enable)
|
|
7
7
|
* - reflectionLog: true (default on)
|
|
8
|
-
* - trustScore: true (can be turned off)
|
|
9
8
|
*/
|
|
10
9
|
export const defaultContextConfig = {
|
|
11
10
|
thinkingOs: true,
|
|
12
11
|
projectFocus: 'off',
|
|
13
12
|
reflectionLog: true,
|
|
14
|
-
trustScore: true,
|
|
15
13
|
evolutionContext: {
|
|
16
14
|
enabled: true,
|
|
17
15
|
maxMessages: 4,
|
package/openclaw.plugin.json
CHANGED
package/package.json
CHANGED
|
@@ -32,7 +32,7 @@ I'm your intelligent mentor, helping you understand and use all features of Prin
|
|
|
32
32
|
| `/pd-thinking` | Manage mental models and candidates | Metacognition |
|
|
33
33
|
| `/pd-evolve` | Execute full evolution loop | Bug fix |
|
|
34
34
|
| `/pd-daily` | Configure and send evolution daily report | Daily review |
|
|
35
|
-
| `/pd-
|
|
35
|
+
| `/pd-evolution-status` | View trust score and security stage | Permission check |
|
|
36
36
|
| `/pd-status` | View system status (GFI and Pain Dictionary) | Health check |
|
|
37
37
|
| `/pd-grooming` | Workspace digital cleanup | Entropy reduction |
|
|
38
38
|
| `/pd-help` | Get interactive command guidance | This skill |
|
|
@@ -72,7 +72,7 @@ I'm your intelligent mentor, helping you understand and use all features of Prin
|
|
|
72
72
|
|
|
73
73
|
**Recommended Flow**:
|
|
74
74
|
1. `/pd-daily` - Send today's evolution report
|
|
75
|
-
2. `/pd-
|
|
75
|
+
2. `/pd-evolution-status` - View current trust score
|
|
76
76
|
3. `/pd-okr` - Check OKR alignment
|
|
77
77
|
|
|
78
78
|
**Script**: "Daily report in hand, evolution I command. Let me help you review today's achievements."
|
|
@@ -95,7 +95,7 @@ I'm your intelligent mentor, helping you understand and use all features of Prin
|
|
|
95
95
|
**Trigger**: User says "not enough permissions", "blocked", "security level"
|
|
96
96
|
|
|
97
97
|
**Recommended Flow**:
|
|
98
|
-
1. `/pd-
|
|
98
|
+
1. `/pd-evolution-status` - View trust score and security stage
|
|
99
99
|
2. Explain current stage's capability boundaries
|
|
100
100
|
|
|
101
101
|
**Script**: "Trust is earned, not given. Let me help you understand your current security level."
|
|
@@ -207,8 +207,8 @@ These skills are usually called automatically by the system, but advanced users
|
|
|
207
207
|
**Q: What is GFI (Friction Index)?**
|
|
208
208
|
A: GFI (Global Friction Index) measures the system's "pain level", range 0-100. Higher values indicate more friction, requiring attention.
|
|
209
209
|
|
|
210
|
-
**Q: How is
|
|
211
|
-
A:
|
|
210
|
+
**Q: How is EP (Evolution Points) calculated?**
|
|
211
|
+
A: EP is earned through successful task completion and problem resolution. Failures may deduct EP but have protection mechanisms. Reaching EP thresholds automatically upgrades your tier, unlocking more permissions (larger code modification limits).
|
|
212
212
|
|
|
213
213
|
**Q: What is Pain Signal?**
|
|
214
214
|
A: Pain Signal is a problem signal detected by the system, stored in `.state/.pain_flag`. When triggered, the system starts the evolution loop.
|
|
@@ -32,7 +32,7 @@ disable-model-invocation: true
|
|
|
32
32
|
| `/pd-thinking` | 管理思维模型与候选方案 | 元认知管理 |
|
|
33
33
|
| `/pd-evolve` | 执行完整进化循环 | 问题修复 |
|
|
34
34
|
| `/pd-daily` | 配置并发送进化日报 | 日常查看 |
|
|
35
|
-
| `/pd-
|
|
35
|
+
| `/pd-evolution-status` | 查看EP等级与安全状态 | 状态查询 |
|
|
36
36
|
| `/pd-status` | 查看系统状态(GFI和痛苦词典) | 健康检查 |
|
|
37
37
|
| `/pd-grooming` | 工作区数字大扫除 | 熵减维护 |
|
|
38
38
|
| `/pd-help` | 获取交互式命令引导 | 本技能 |
|
|
@@ -72,7 +72,7 @@ disable-model-invocation: true
|
|
|
72
72
|
|
|
73
73
|
**推荐流程**:
|
|
74
74
|
1. `/pd-daily` - 发送今日进化日报
|
|
75
|
-
2. `/pd-
|
|
75
|
+
2. `/pd-evolution-status` - 查看当前信任积分
|
|
76
76
|
3. `/pd-okr` - 检查 OKR 对齐情况
|
|
77
77
|
|
|
78
78
|
**话术**: "日报在手,进化我有。让我帮你回顾今天的成果。"
|
|
@@ -95,7 +95,7 @@ disable-model-invocation: true
|
|
|
95
95
|
**触发条件**: 用户说"权限不够"、"被拦截了"、"安全等级"
|
|
96
96
|
|
|
97
97
|
**推荐流程**:
|
|
98
|
-
1. `/pd-
|
|
98
|
+
1. `/pd-evolution-status` - 查看信任积分和安全等级
|
|
99
99
|
2. 解释当前等级的能力边界
|
|
100
100
|
|
|
101
101
|
**话术**: "信任是挣来的,不是给的。让我帮你了解当前的安全等级。"
|
|
@@ -207,8 +207,8 @@ disable-model-invocation: true
|
|
|
207
207
|
**Q: 什么是 GFI(摩擦指数)?**
|
|
208
208
|
A: GFI (Global Friction Index) 衡量系统的"痛苦程度",分值范围 0-100。值越高表示摩擦越大,需要关注。
|
|
209
209
|
|
|
210
|
-
**Q:
|
|
211
|
-
A:
|
|
210
|
+
**Q: EP (进化积分) 如何计算?**
|
|
211
|
+
A: EP (Evolution Points) 通过成功完成任务和问题修复累积。失败会扣除EP但有保护机制。达到阈值后自动升级EP等级,解锁更多权限(更大的代码修改限额)。
|
|
212
212
|
|
|
213
213
|
**Q: Pain Signal 是什么?**
|
|
214
214
|
A: Pain Signal 是系统检测到的问题信号,存储在 `.state/.pain_flag` 中。触发后系统会启动进化循环。
|
|
@@ -103,12 +103,6 @@
|
|
|
103
103
|
"large_change_block": 50
|
|
104
104
|
},
|
|
105
105
|
"large_change_lines": 50,
|
|
106
|
-
"trust_stage_multipliers": {
|
|
107
|
-
"1": 0.5,
|
|
108
|
-
"2": 0.75,
|
|
109
|
-
"3": 1.0,
|
|
110
|
-
"4": 1.5
|
|
111
|
-
},
|
|
112
106
|
"bash_safe_patterns": [
|
|
113
107
|
"^(ls|dir|pwd|which|where|echo|env|cat|type|head|tail|less|more)\\b",
|
|
114
108
|
"^git\\s+(status|log|diff|branch|show|remote)\\b",
|
package/dist/commands/trust.d.ts
DELETED
package/dist/commands/trust.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { WorkspaceContext } from '../core/workspace-context.js';
|
|
2
|
-
function createProgressBar(value, max, length = 12) {
|
|
3
|
-
const safeValue = Math.max(0, Math.min(max, value));
|
|
4
|
-
const filledLength = Math.round((safeValue / max) * length);
|
|
5
|
-
const emptyLength = Math.max(0, length - filledLength);
|
|
6
|
-
return `[${'#'.repeat(filledLength)}${'-'.repeat(emptyLength)}]`;
|
|
7
|
-
}
|
|
8
|
-
function formatStageTitle(stage, isZh) {
|
|
9
|
-
const titles = isZh
|
|
10
|
-
? ['Observer', 'Editor', 'Developer', 'Architect']
|
|
11
|
-
: ['Observer', 'Editor', 'Developer', 'Architect'];
|
|
12
|
-
return titles[Math.max(0, Math.min(3, stage - 1))] ?? 'Unknown';
|
|
13
|
-
}
|
|
14
|
-
export function handleTrustCommand(ctx) {
|
|
15
|
-
const { workspaceDir } = ctx;
|
|
16
|
-
if (!workspaceDir)
|
|
17
|
-
return 'Error: Workspace directory not found.';
|
|
18
|
-
const wctx = WorkspaceContext.fromHookContext(ctx);
|
|
19
|
-
const trustEngine = wctx.trust;
|
|
20
|
-
const trustScore = trustEngine.getScore();
|
|
21
|
-
const stage = trustEngine.getStage();
|
|
22
|
-
const isZh = wctx.config.get('language') === 'zh';
|
|
23
|
-
const scorecard = trustEngine.getScorecard();
|
|
24
|
-
const hygiene = wctx.hygiene.getStats();
|
|
25
|
-
const trustBar = createProgressBar(trustScore, 100);
|
|
26
|
-
const hygieneScore = Math.min(100, hygiene.persistenceCount * 10);
|
|
27
|
-
const hygieneBar = createProgressBar(hygieneScore, 100);
|
|
28
|
-
const rewardPolicy = scorecard.reward_policy ?? 'frozen_all_positive';
|
|
29
|
-
const lastUpdated = scorecard.last_updated ?? '--';
|
|
30
|
-
if (isZh) {
|
|
31
|
-
return [
|
|
32
|
-
'Principles Disciple - Legacy Trust',
|
|
33
|
-
'=================================',
|
|
34
|
-
'',
|
|
35
|
-
`- Legacy Trust: ${trustBar} ${trustScore}/100`,
|
|
36
|
-
`- Stage: ${stage} (${formatStageTitle(stage, true)})`,
|
|
37
|
-
`- Status: legacy/frozen`,
|
|
38
|
-
`- Reward Policy: ${rewardPolicy}`,
|
|
39
|
-
`- Last Updated: ${lastUpdated}`,
|
|
40
|
-
'',
|
|
41
|
-
'说明',
|
|
42
|
-
'- 这是兼容旧控制面的 legacy trust 视图,不再代表新的长期能力模型。',
|
|
43
|
-
'- `tool_success` 与 `subagent_success` 不再自动提升 trust。',
|
|
44
|
-
'- 当前观察窗口内,trust 主要保留为兼容读数与 gate 兼容输入。',
|
|
45
|
-
'',
|
|
46
|
-
'认知卫生',
|
|
47
|
-
`- Persistence: ${hygieneBar} ${hygiene.persistenceCount} actions today`,
|
|
48
|
-
`- Total Chars Persisted: ${hygiene.totalCharsPersisted}`,
|
|
49
|
-
`- Workspace Grooming: ${hygiene.groomingExecutedCount > 0 ? 'done' : 'pending'}`,
|
|
50
|
-
'',
|
|
51
|
-
'下一步',
|
|
52
|
-
'- 在进入 Phase 3 capability shadow 之前,先看 production observation 数据是否稳定。',
|
|
53
|
-
].join('\n');
|
|
54
|
-
}
|
|
55
|
-
return [
|
|
56
|
-
'Principles Disciple - Legacy Trust',
|
|
57
|
-
'=================================',
|
|
58
|
-
'',
|
|
59
|
-
`- Legacy Trust: ${trustBar} ${trustScore}/100`,
|
|
60
|
-
`- Stage: ${stage} (${formatStageTitle(stage, false)})`,
|
|
61
|
-
'- Status: legacy/frozen',
|
|
62
|
-
`- Reward Policy: ${rewardPolicy}`,
|
|
63
|
-
`- Last Updated: ${lastUpdated}`,
|
|
64
|
-
'',
|
|
65
|
-
'Notes',
|
|
66
|
-
'- This is a compatibility view of legacy trust, not the future long-term capability model.',
|
|
67
|
-
'- `tool_success` and `subagent_success` no longer raise trust automatically.',
|
|
68
|
-
'- During the current observation window, trust remains mainly for compatibility reads and gate compatibility.',
|
|
69
|
-
'',
|
|
70
|
-
'Cognitive Hygiene',
|
|
71
|
-
`- Persistence: ${hygieneBar} ${hygiene.persistenceCount} actions today`,
|
|
72
|
-
`- Total Chars Persisted: ${hygiene.totalCharsPersisted}`,
|
|
73
|
-
`- Workspace Grooming: ${hygiene.groomingExecutedCount > 0 ? 'done' : 'pending'}`,
|
|
74
|
-
'',
|
|
75
|
-
'Next',
|
|
76
|
-
'- Do not move into Phase 3 capability shadow until production observation data is stable.',
|
|
77
|
-
].join('\n');
|
|
78
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Trust Engine V2.1 - Recalibrated for Action Classification
|
|
3
|
-
* Differentiates between Exploratory (safe) and Constructive (risky) actions.
|
|
4
|
-
*/
|
|
5
|
-
export interface TrustScorecard {
|
|
6
|
-
trust_score: number;
|
|
7
|
-
success_streak: number;
|
|
8
|
-
failure_streak: number;
|
|
9
|
-
exploratory_failure_streak: number;
|
|
10
|
-
grace_failures_remaining?: number;
|
|
11
|
-
last_updated: string;
|
|
12
|
-
cold_start_end?: string;
|
|
13
|
-
first_activity_at?: string;
|
|
14
|
-
history: Array<{
|
|
15
|
-
type: 'success' | 'failure' | 'penalty' | 'info';
|
|
16
|
-
delta: number;
|
|
17
|
-
reason: string;
|
|
18
|
-
timestamp: string;
|
|
19
|
-
}>;
|
|
20
|
-
frozen?: boolean;
|
|
21
|
-
reward_policy?: 'frozen_all_positive' | 'frozen_atomic_positive_keep_plan_ready';
|
|
22
|
-
}
|
|
23
|
-
export type TrustStage = 1 | 2 | 3 | 4;
|
|
24
|
-
export declare const EXPLORATORY_TOOLS: Set<string>;
|
|
25
|
-
export declare class TrustEngine {
|
|
26
|
-
private scorecard;
|
|
27
|
-
private workspaceDir;
|
|
28
|
-
private stateDir;
|
|
29
|
-
constructor(workspaceDir: string);
|
|
30
|
-
private get config();
|
|
31
|
-
private get trustSettings();
|
|
32
|
-
private loadScorecard;
|
|
33
|
-
private applyLegacyFreezeMetadata;
|
|
34
|
-
private saveScorecard;
|
|
35
|
-
getScore(): number;
|
|
36
|
-
getScorecard(): TrustScorecard;
|
|
37
|
-
getStage(): TrustStage;
|
|
38
|
-
isColdStart(): boolean;
|
|
39
|
-
recordSuccess(reason: string, context?: {
|
|
40
|
-
sessionId?: string;
|
|
41
|
-
api?: any;
|
|
42
|
-
toolName?: string;
|
|
43
|
-
}, isSubagent?: boolean): void;
|
|
44
|
-
recordFailure(type: 'tool' | 'risky' | 'bypass', context: {
|
|
45
|
-
sessionId?: string;
|
|
46
|
-
api?: any;
|
|
47
|
-
toolName?: string;
|
|
48
|
-
error?: string;
|
|
49
|
-
}): void;
|
|
50
|
-
private touchScorecard;
|
|
51
|
-
private updateScore;
|
|
52
|
-
resetTrust(newScore?: number): void;
|
|
53
|
-
getStatusSummary(): {
|
|
54
|
-
stage: TrustStage;
|
|
55
|
-
successRate: number;
|
|
56
|
-
isInColdStart: boolean;
|
|
57
|
-
graceRemaining: number;
|
|
58
|
-
currentStreak: {
|
|
59
|
-
type: string;
|
|
60
|
-
count: number;
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
private calculateSuccessRate;
|
|
64
|
-
}
|
|
65
|
-
export declare function recordSuccess(workspaceDir: string, reason: string, context?: {
|
|
66
|
-
sessionId?: string;
|
|
67
|
-
api?: any;
|
|
68
|
-
toolName?: string;
|
|
69
|
-
}, isSubagent?: boolean): void;
|
|
70
|
-
export declare function recordFailure(type: 'tool' | 'risky' | 'bypass', workspaceDir: string, ctx: {
|
|
71
|
-
sessionId?: string;
|
|
72
|
-
api?: any;
|
|
73
|
-
toolName?: string;
|
|
74
|
-
error?: string;
|
|
75
|
-
}): void;
|
|
76
|
-
export declare function getAgentScorecard(workspaceDir: string): TrustScorecard;
|
|
77
|
-
export declare function getTrustStats(scorecard: TrustScorecard): {
|
|
78
|
-
stage: TrustStage;
|
|
79
|
-
successRate: any;
|
|
80
|
-
isInColdStart: boolean;
|
|
81
|
-
graceRemaining: number;
|
|
82
|
-
currentStreak: {
|
|
83
|
-
type: string;
|
|
84
|
-
count: number;
|
|
85
|
-
};
|
|
86
|
-
};
|
|
87
|
-
export declare function getTrustStatus(workspaceDir: string): {
|
|
88
|
-
stage: TrustStage;
|
|
89
|
-
successRate: number;
|
|
90
|
-
isInColdStart: boolean;
|
|
91
|
-
graceRemaining: number;
|
|
92
|
-
currentStreak: {
|
|
93
|
-
type: string;
|
|
94
|
-
count: number;
|
|
95
|
-
};
|
|
96
|
-
};
|