principles-disciple 1.201.0 → 1.202.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/dist/bundle.js +166 -166
- package/dist/commands/archive-impl.d.ts +18 -0
- package/dist/commands/capabilities.d.ts +3 -0
- package/dist/commands/context.d.ts +5 -0
- package/dist/commands/disable-impl.d.ts +22 -0
- package/dist/commands/evolution-status.d.ts +4 -0
- package/dist/commands/export.d.ts +2 -0
- package/dist/commands/focus.d.ts +14 -0
- package/dist/commands/pain.d.ts +6 -0
- package/dist/commands/principle-rollback.d.ts +4 -0
- package/dist/commands/promote-impl.d.ts +22 -0
- package/dist/commands/rollback-impl.d.ts +32 -0
- package/dist/commands/rollback.d.ts +19 -0
- package/dist/commands/samples.d.ts +2 -0
- package/dist/commands/strategy.d.ts +2 -0
- package/dist/commands/thinking-os.d.ts +2 -0
- package/dist/commands/workflow-debug.d.ts +4 -0
- package/dist/config/defaults/runtime.d.ts +58 -0
- package/dist/config/errors.d.ts +86 -0
- package/dist/config/index.d.ts +7 -0
- package/dist/constants/tools.d.ts +17 -0
- package/dist/core/__tests__/focus-history.test.d.ts +1 -0
- package/dist/core/behavior-example-pack-assembler.d.ts +38 -0
- package/dist/core/bootstrap-rules.d.ts +50 -0
- package/dist/core/code-implementation-storage.d.ts +71 -0
- package/dist/core/config-health.d.ts +17 -0
- package/dist/core/config-service.d.ts +15 -0
- package/dist/core/config.d.ts +111 -0
- package/dist/core/control-ui-db.d.ts +117 -0
- package/dist/core/correction-cue-learner.d.ts +33 -0
- package/dist/core/correction-types.d.ts +3 -0
- package/dist/core/detection-funnel.d.ts +47 -0
- package/dist/core/detection-service.d.ts +15 -0
- package/dist/core/dictionary-service.d.ts +15 -0
- package/dist/core/dictionary.d.ts +38 -0
- package/dist/core/empathy-keyword-matcher.d.ts +5 -0
- package/dist/core/empathy-types.d.ts +2 -0
- package/dist/core/event-log.d.ts +98 -0
- package/dist/core/evolution-engine.d.ts +119 -0
- package/dist/core/evolution-logger.d.ts +137 -0
- package/dist/core/evolution-reducer.d.ts +116 -0
- package/dist/core/evolution-types.d.ts +50 -0
- package/dist/core/file-store.d.ts +41 -0
- package/dist/core/focus-history.d.ts +50 -0
- package/dist/core/hygiene/tracker.d.ts +22 -0
- package/dist/core/init.d.ts +30 -0
- package/dist/core/intent-doc-reader-adapter.d.ts +36 -0
- package/dist/core/intent-doc-reader.d.ts +89 -0
- package/dist/core/migration.d.ts +6 -0
- package/dist/core/pain-diagnostic-gate.d.ts +45 -0
- package/dist/core/pain.d.ts +24 -0
- package/dist/core/path-resolver.d.ts +60 -0
- package/dist/core/paths.d.ts +59 -0
- package/dist/core/pd-config-loader.d.ts +96 -0
- package/dist/core/pd-task-reconciler.d.ts +89 -0
- package/dist/core/pd-task-service.d.ts +2 -0
- package/dist/core/pd-task-store.d.ts +5 -0
- package/dist/core/pd-task-types.d.ts +8 -0
- package/dist/core/principle-compiler/__tests__/compiler-replay-gate.test.d.ts +1 -0
- package/dist/core/principle-compiler/code-validator.d.ts +14 -0
- package/dist/core/principle-compiler/compiler.d.ts +45 -0
- package/dist/core/principle-compiler/index.d.ts +12 -0
- package/dist/core/principle-compiler/ledger-registrar.d.ts +28 -0
- package/dist/core/principle-compiler/template-generator.d.ts +7 -0
- package/dist/core/principle-injection.d.ts +10 -0
- package/dist/core/principle-internalization/filesystem-lifecycle-datasource.d.ts +15 -0
- package/dist/core/principle-internalization/lifecycle-read-model.d.ts +17 -0
- package/dist/core/principle-internalization/lifecycle-refresh.d.ts +2 -0
- package/dist/core/principle-internalization/principle-lifecycle-service.d.ts +28 -0
- package/dist/core/principle-training-state.d.ts +47 -0
- package/dist/core/principle-tree-ledger.d.ts +30 -0
- package/dist/core/profile.d.ts +62 -0
- package/dist/core/reflection/reflection-context.d.ts +31 -0
- package/dist/core/replay-engine.d.ts +12 -0
- package/dist/core/rule-context-assembler.d.ts +45 -0
- package/dist/core/rule-host.d.ts +178 -0
- package/dist/core/rule-implementation-runtime.d.ts +18 -0
- package/dist/core/runtime-v2-prompt-activation-reader.d.ts +22 -0
- package/dist/core/session-tracker.d.ts +119 -0
- package/dist/core/signal-collector-host.d.ts +113 -0
- package/dist/core/system-logger.d.ts +24 -0
- package/dist/core/thinking-models.d.ts +25 -0
- package/dist/core/thinking-os-parser.d.ts +35 -0
- package/dist/core/trajectory-types.d.ts +247 -0
- package/dist/core/trajectory.d.ts +279 -0
- package/dist/core/workflow-funnel-loader.d.ts +72 -0
- package/dist/core/workspace-context.d.ts +114 -0
- package/dist/core/workspace-dir-validation.d.ts +11 -0
- package/dist/core/workspace-guidance-migrator.d.ts +12 -0
- package/dist/hooks/after-tool-call-helpers.d.ts +97 -0
- package/dist/hooks/after-tool-call-types.d.ts +86 -0
- package/dist/hooks/gate-block-helper.d.ts +44 -0
- package/dist/hooks/gate.d.ts +16 -0
- package/dist/hooks/lifecycle.d.ts +5 -0
- package/dist/hooks/llm.d.ts +21 -0
- package/dist/hooks/message-sanitize.d.ts +24 -0
- package/dist/hooks/pain.d.ts +35 -0
- package/dist/hooks/prompt-helpers.d.ts +105 -0
- package/dist/hooks/prompt-types.d.ts +74 -0
- package/dist/hooks/prompt.d.ts +22 -0
- package/dist/hooks/raw-observation-adapter.d.ts +16 -0
- package/dist/hooks/raw-observation-types.d.ts +11 -0
- package/dist/hooks/trajectory-collector.d.ts +41 -0
- package/dist/hooks/trajectory-evidence.d.ts +11 -0
- package/dist/hooks/triage-adapter.d.ts +58 -0
- package/dist/hooks/trigger-cooldown-tracker.d.ts +42 -0
- package/dist/i18n/commands.d.ts +26 -0
- package/dist/index.d.ts +52 -0
- package/dist/openclaw-sdk.d.ts +338 -0
- package/dist/openclaw.plugin.json +1 -1
- package/dist/rulehost-evidence.d.ts +4 -0
- package/dist/service/correction-observer-service.d.ts +19 -0
- package/dist/service/evolution-dedup.d.ts +27 -0
- package/dist/service/evolution-worker.d.ts +105 -0
- package/dist/service/internalization-auto-consumer-service.d.ts +8 -0
- package/dist/service/keyword-optimization-service.d.ts +44 -0
- package/dist/service/phase3-input-filter.d.ts +73 -0
- package/dist/service/queue-io.d.ts +30 -0
- package/dist/service/queue-migration.d.ts +84 -0
- package/dist/service/runtime-summary-service.d.ts +156 -0
- package/dist/service/subagent-workflow/subagent-error-utils.d.ts +8 -0
- package/dist/service/subagent-workflow/types.d.ts +264 -0
- package/dist/service/subagent-workflow/workflow-store.d.ts +44 -0
- package/dist/service/trajectory-service.d.ts +2 -0
- package/dist/service/workflow-watchdog.d.ts +23 -0
- package/dist/types/event-types.d.ts +2 -0
- package/dist/types/hygiene-types.d.ts +2 -0
- package/dist/types/principle-tree-schema.d.ts +29 -0
- package/dist/types/queue.d.ts +2 -0
- package/dist/types/runtime-summary.d.ts +1 -0
- package/dist/types.d.ts +13 -0
- package/dist/utils/file-lock.d.ts +68 -0
- package/dist/utils/hashing.d.ts +9 -0
- package/dist/utils/io.d.ts +11 -0
- package/dist/utils/node-vm-polyfill.d.ts +9 -0
- package/dist/utils/retry.d.ts +210 -0
- package/dist/utils/session-key.d.ts +10 -0
- package/dist/utils/workspace-resolver.d.ts +82 -0
- package/openclaw.plugin.json +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type LedgerPrinciple } from '../principle-tree-ledger.js';
|
|
2
|
+
import type { TrajectoryDatabase } from '../trajectory.js';
|
|
3
|
+
export interface ReflectionContext {
|
|
4
|
+
principle: LedgerPrinciple;
|
|
5
|
+
painEvents: Array<{
|
|
6
|
+
source: string;
|
|
7
|
+
score: number;
|
|
8
|
+
severity: string | null;
|
|
9
|
+
reason: string | null;
|
|
10
|
+
createdAt: string;
|
|
11
|
+
}>;
|
|
12
|
+
sessionSnapshot: {
|
|
13
|
+
toolCalls: Array<{
|
|
14
|
+
toolName: string;
|
|
15
|
+
outcome: string;
|
|
16
|
+
filePath: string | null;
|
|
17
|
+
errorType: string | null;
|
|
18
|
+
}>;
|
|
19
|
+
} | null;
|
|
20
|
+
}
|
|
21
|
+
export declare class ReflectionContextCollector {
|
|
22
|
+
private readonly stateDir;
|
|
23
|
+
private readonly trajectory;
|
|
24
|
+
constructor(stateDir: string, trajectory: TrajectoryDatabase);
|
|
25
|
+
collect(principleId: string): ReflectionContext | null;
|
|
26
|
+
collectBatch(filter?: {
|
|
27
|
+
status?: string;
|
|
28
|
+
}): ReflectionContext[];
|
|
29
|
+
private buildContext;
|
|
30
|
+
private resolvePainEvents;
|
|
31
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ReplayReport, ClassificationSummary, ReplayResult } from '@principles/core/runtime-v2';
|
|
2
|
+
export type { ReplayReport, ClassificationSummary, ReplayResult };
|
|
3
|
+
export declare class ReplayEngine {
|
|
4
|
+
private readonly workspaceDir;
|
|
5
|
+
private readonly stateDir;
|
|
6
|
+
constructor(workspaceDir: string, stateDir: string);
|
|
7
|
+
listReports(implementationId: string): ReplayReport[];
|
|
8
|
+
getLatestReport(implementationId: string): ReplayReport | null;
|
|
9
|
+
hasPassingReport(implementationId: string): boolean;
|
|
10
|
+
private _getImplementationById;
|
|
11
|
+
}
|
|
12
|
+
export declare function formatReplayReport(report: ReplayReport): string;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PRI-482 Phase 3 — Production RuleContext v2 assembler
|
|
3
|
+
*
|
|
4
|
+
* Converts raw TrajectoryDatabase rows into a validated RuleHistoryWindow,
|
|
5
|
+
* and provides buildProductionRuleContext for gate integration.
|
|
6
|
+
*
|
|
7
|
+
* ERR prevention:
|
|
8
|
+
* - ERR-001: every row field is validated as unknown. No `as` bypass on
|
|
9
|
+
* parsed params_json or outcome.
|
|
10
|
+
* - ERR-024: buildProductionRuleContext fail-soft — query failure returns
|
|
11
|
+
* unavailable, never throws.
|
|
12
|
+
* - ERR-025: callers use recordToolCall → getRuleHostContextRows → this
|
|
13
|
+
* assembler, covering the full production chain.
|
|
14
|
+
*
|
|
15
|
+
* Spec: docs/superpowers/specs/2026-06-27-rulecode-context-vision-design.md §5.
|
|
16
|
+
*/
|
|
17
|
+
import type { RuleContextV2, RuleHistoryWindow } from '@principles/core/runtime-v2';
|
|
18
|
+
import type { RuleHostContextResult, RuleHostContextRow } from './trajectory-types.js';
|
|
19
|
+
/**
|
|
20
|
+
* Minimal interface for the data source that TrajectoryDatabase satisfies.
|
|
21
|
+
* Allows testing buildProductionRuleContext without a real DB.
|
|
22
|
+
*/
|
|
23
|
+
export interface RuleContextDataSource {
|
|
24
|
+
getRuleHostContextRows(sessionId: string, limit: number): RuleHostContextResult;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Convert raw DB rows into a validated RuleHistoryWindow.
|
|
28
|
+
*
|
|
29
|
+
* If ANY row is malformed (bad params_json, invalid outcome, empty tool_name),
|
|
30
|
+
* the entire window is marked unavailable (fail loud, spec §5.2).
|
|
31
|
+
*
|
|
32
|
+
* ERR-001: row fields are validated as unknown. params_json is JSON.parsed
|
|
33
|
+
* then structurally checked (must be a non-array object). No `as` bypass.
|
|
34
|
+
*/
|
|
35
|
+
export declare function assembleHistoryFromRows(rows: readonly RuleHostContextRow[], truncated: boolean, projectDir: string): RuleHistoryWindow;
|
|
36
|
+
/**
|
|
37
|
+
* Build a RuleContextV2 from the production data source (TrajectoryDatabase).
|
|
38
|
+
*
|
|
39
|
+
* ERR-024: if the query or assembly fails, returns an unavailable context
|
|
40
|
+
* (fail-soft). Never throws.
|
|
41
|
+
*
|
|
42
|
+
* sameActionBlockCount is always null in this version (spec §5.4:
|
|
43
|
+
* session-tracker.blockedAttempts is a session total, not per-action).
|
|
44
|
+
*/
|
|
45
|
+
export declare function buildProductionRuleContext(sessionId: string | null | undefined, targetPath: string | null, source: RuleContextDataSource, projectDir: string, limit?: number): RuleContextV2;
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rule Host — Constrained execution layer for active code implementations
|
|
3
|
+
*
|
|
4
|
+
* PURPOSE: Load active code implementations from the SQLite activations table
|
|
5
|
+
* (code_tool_hook channel), execute them in a constrained node:vm context,
|
|
6
|
+
* and merge their decisions.
|
|
7
|
+
*
|
|
8
|
+
* ARCHITECTURE (PRI-436):
|
|
9
|
+
* - SQLite is the SOLE production source of active RuleCode
|
|
10
|
+
* - No filesystem ledger or implementation asset reads occur during evaluation
|
|
11
|
+
* - Constructor takes stateDir for API compatibility (no longer used for impl loading)
|
|
12
|
+
* - workspaceDir enables reading code_tool_hook activations from SQLite
|
|
13
|
+
* - evaluate(input) loads active code implementations and runs them
|
|
14
|
+
* - Each implementation executes in an isolated vm context with minimal helpers
|
|
15
|
+
* - Decision merge: block short-circuits, requireApproval collects, allow is implicit
|
|
16
|
+
*
|
|
17
|
+
* SECURITY CONSTRAINTS (T-12-01, T-12-04):
|
|
18
|
+
* - Candidate code loads through a dedicated vm context, not the host realm
|
|
19
|
+
* - No importModuleDynamically callback
|
|
20
|
+
* - Helpers are a frozen object — implementations cannot modify the helper surface
|
|
21
|
+
*
|
|
22
|
+
* CONSERVATIVE DEGRADATION (T-12-02, D-08):
|
|
23
|
+
* - On ANY host error (load failure, eval error, vm error): return undefined
|
|
24
|
+
* - Never throw, never bypass downstream gates (Progressive Gate, Edit Verification)
|
|
25
|
+
*/
|
|
26
|
+
import type { RuleHostInput, RuleHostResult } from '@principles/core/runtime-v2';
|
|
27
|
+
import type { RuleHostLogger } from '@principles/core/runtime-v2';
|
|
28
|
+
export type { RuleHostLogger } from '@principles/core/runtime-v2';
|
|
29
|
+
export interface RuleHostOptions {
|
|
30
|
+
/** Workspace directory for SQLite access. Required for RuleHost to load active code_tool_hook activations. */
|
|
31
|
+
workspaceDir?: string;
|
|
32
|
+
}
|
|
33
|
+
type RuleHostActivationMode = 'shadow' | 'live';
|
|
34
|
+
export interface RuleHostObservedDecision extends RuleHostResult {
|
|
35
|
+
readonly activationId: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* PRI-491 — A structured record of an activation that was skipped at load
|
|
39
|
+
* time (flag-off v2, unsupported action, unsupported context version,
|
|
40
|
+
* missing target_ref, content_json not an object, no implementationCode,
|
|
41
|
+
* or duplicate active activation for target_ref).
|
|
42
|
+
*
|
|
43
|
+
* Unlike compile/load failures (which emit rulehost_unhealthy), skipped
|
|
44
|
+
* activations have a configuration/flag reason — the RuleCode itself may be
|
|
45
|
+
* valid, but the runtime chose not to execute it. Duplicate activations are
|
|
46
|
+
* a special case: they ALSO emit rulehost_unhealthy (for telemetry), but are
|
|
47
|
+
* surfaced in skippedActivations so the owner can observe and act (rc-9).
|
|
48
|
+
*
|
|
49
|
+
* ERR-002 (rc-9): every skip carries a reason + nextAction, never silent.
|
|
50
|
+
*/
|
|
51
|
+
export interface SkippedActivation {
|
|
52
|
+
readonly activationId: string;
|
|
53
|
+
readonly ruleId: string;
|
|
54
|
+
/**
|
|
55
|
+
* The mode the activation WOULD have had if loaded. Optional for cases
|
|
56
|
+
* where the action itself is unrecognized (neither shadow nor live).
|
|
57
|
+
*/
|
|
58
|
+
readonly mode?: RuleHostActivationMode;
|
|
59
|
+
readonly reason: string;
|
|
60
|
+
readonly nextAction: string;
|
|
61
|
+
}
|
|
62
|
+
export interface RuleHostEvaluationReport {
|
|
63
|
+
readonly liveDecision: RuleHostResult | undefined;
|
|
64
|
+
readonly shadowDecisions: readonly RuleHostObservedDecision[];
|
|
65
|
+
/**
|
|
66
|
+
* PRI-491 — Activations that were skipped at load time. Empty when all
|
|
67
|
+
* active activations loaded successfully. Each entry carries a structured
|
|
68
|
+
* reason + nextAction so the owner can act without reading SQLite rows.
|
|
69
|
+
*/
|
|
70
|
+
readonly skippedActivations: readonly SkippedActivation[];
|
|
71
|
+
}
|
|
72
|
+
export declare class RuleHost {
|
|
73
|
+
private readonly stateDir;
|
|
74
|
+
private logger;
|
|
75
|
+
private readonly workspaceDir;
|
|
76
|
+
private readonly implementationSources;
|
|
77
|
+
private activationFingerprint;
|
|
78
|
+
private cachedImplementations;
|
|
79
|
+
/**
|
|
80
|
+
* PRI-491: Cached skipped activations from the last load. Returned alongside
|
|
81
|
+
* cachedImplementations on fingerprint hit so evaluateDetailed can surface
|
|
82
|
+
* them without re-scanning SQLite.
|
|
83
|
+
*/
|
|
84
|
+
private cachedSkipped;
|
|
85
|
+
private sqliteConnection;
|
|
86
|
+
/**
|
|
87
|
+
* R2-RH-002: Guards the "armed but empty" warn so it fires at most once per
|
|
88
|
+
* RuleHost instance. Without this, the 0-rules path (workspaceDir missing OR
|
|
89
|
+
* zero active code_tool_hook activations) returns [] silently on every
|
|
90
|
+
* evaluation — an observability gap (rc-9-no-silent-fallback). The warn is
|
|
91
|
+
* NOT a degradation fallback (RuleHost correctly has no opinion when empty);
|
|
92
|
+
* it makes the empty-armed state visible so operators can investigate why
|
|
93
|
+
* no live rules are loaded.
|
|
94
|
+
*/
|
|
95
|
+
private emptyLoadWarnEmitted;
|
|
96
|
+
constructor(stateDir: string, logger?: RuleHostLogger, options?: RuleHostOptions);
|
|
97
|
+
/**
|
|
98
|
+
* Update the logger sink on a cached RuleHost instance.
|
|
99
|
+
*
|
|
100
|
+
* WorkspaceContext caches the RuleHost singleton, but each gate call may
|
|
101
|
+
* pass a request-level logger. Without this update, warn/unhealthy logs
|
|
102
|
+
* would forever go to the first logger sink, making the new path hard to
|
|
103
|
+
* debug.
|
|
104
|
+
*/
|
|
105
|
+
updateLogger(logger: RuleHostLogger): void;
|
|
106
|
+
/**
|
|
107
|
+
* Evaluate the input against all active code implementations.
|
|
108
|
+
*
|
|
109
|
+
* Returns:
|
|
110
|
+
* - undefined when no active code implementations exist (no opinion)
|
|
111
|
+
* - undefined when all implementations return allow or matched=false
|
|
112
|
+
* - { decision: 'block', ... } when any implementation returns block (short-circuits)
|
|
113
|
+
* - { decision: 'requireApproval', ... } when any implementation returns requireApproval
|
|
114
|
+
*/
|
|
115
|
+
evaluate(input: RuleHostInput): RuleHostResult | undefined;
|
|
116
|
+
dispose(): void;
|
|
117
|
+
evaluateDetailed(input: RuleHostInput): RuleHostEvaluationReport;
|
|
118
|
+
/**
|
|
119
|
+
* Load active code implementations from the SQLite activations table.
|
|
120
|
+
*
|
|
121
|
+
* PRI-436: SQLite is the SOLE production source. The filesystem ledger
|
|
122
|
+
* (principle-tree-ledger) and implementation asset paths have been deleted.
|
|
123
|
+
* No fallback, no dual-source, no deprecated adapter.
|
|
124
|
+
*
|
|
125
|
+
* Source: activations table (code_tool_hook channel, deactivated_at IS NULL)
|
|
126
|
+
* → JOIN pi_artifacts for content_json → extract implementationCode → compile
|
|
127
|
+
*/
|
|
128
|
+
private _loadActiveCodeImplementations;
|
|
129
|
+
/**
|
|
130
|
+
* R2-RH-002: Emit the "armed but empty" warn at most once per RuleHost
|
|
131
|
+
* instance. The warn is cached via `emptyLoadWarnEmitted` so repeated
|
|
132
|
+
* evaluations (which all hit the empty path) do not spam the log.
|
|
133
|
+
*
|
|
134
|
+
* This is an observability signal, NOT a degradation fallback — RuleHost
|
|
135
|
+
* correctly returns "no opinion" when there are no active rules. The warn
|
|
136
|
+
* makes the empty state visible so operators can distinguish "RuleHost is
|
|
137
|
+
* working but has no rules" from "RuleHost is broken" (rc-9-no-silent-fallback).
|
|
138
|
+
*/
|
|
139
|
+
private _emitEmptyLoadWarn;
|
|
140
|
+
/**
|
|
141
|
+
* Load active code implementations from the activations table (code_tool_hook channel).
|
|
142
|
+
*
|
|
143
|
+
* For each activation record:
|
|
144
|
+
* 1. Query the pi_artifacts table for the artifact content
|
|
145
|
+
* 2. Parse content_json to extract implementationCode (treated as unknown, EP-01)
|
|
146
|
+
* 3. Compile via loadRuleImplementationModule (isolated vm context)
|
|
147
|
+
*
|
|
148
|
+
* PRI-436 invariant: at most one active activation per rule (target_ref).
|
|
149
|
+
* Duplicate active activations for the same target_ref are ALL skipped
|
|
150
|
+
* (zero executions) and emit structured unhealthy evidence via logger.warn
|
|
151
|
+
* (Runtime Contract Rule 9: graceful degradation includes a reason).
|
|
152
|
+
*
|
|
153
|
+
* All data from SQLite is treated as unknown and validated before use.
|
|
154
|
+
*/
|
|
155
|
+
private _loadFromActivationsTable;
|
|
156
|
+
/**
|
|
157
|
+
* PRI-437: Record an unhealthy activation state to EventLog.
|
|
158
|
+
*
|
|
159
|
+
* This makes compile/load failures visible to CLI (pd runtime health) and
|
|
160
|
+
* Console API — NOT just a logger.warn that's silently skipped.
|
|
161
|
+
*
|
|
162
|
+
* ERR-002: degradation includes a reason and nextAction (not silent).
|
|
163
|
+
* Failures in EventLog recording are caught and logged (never throw).
|
|
164
|
+
*/
|
|
165
|
+
private _recordUnhealthy;
|
|
166
|
+
/**
|
|
167
|
+
* PRI-491: Record a skipped activation to EventLog.
|
|
168
|
+
*
|
|
169
|
+
* Unlike _recordUnhealthy (compile/load failures), skipped activations have
|
|
170
|
+
* a configuration/flag reason — the RuleCode itself may be valid, but the
|
|
171
|
+
* runtime chose not to execute it (flag-off v2, unsupported context version,
|
|
172
|
+
* unsupported action, content_json not object, no implementationCode).
|
|
173
|
+
*
|
|
174
|
+
* ERR-002: degradation includes a reason and nextAction (rc-9-no-silent-fallback).
|
|
175
|
+
* Failures in EventLog recording are caught and logged (never throw).
|
|
176
|
+
*/
|
|
177
|
+
private _recordSkipped;
|
|
178
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface RuleImplementationModuleExports {
|
|
2
|
+
meta?: unknown;
|
|
3
|
+
evaluate?: unknown;
|
|
4
|
+
/**
|
|
5
|
+
* Call evaluate(input, helpers) INSIDE the vm context with a time boundary.
|
|
6
|
+
*
|
|
7
|
+
* PRI-437: The evaluate() function extracted from a vm context executes in
|
|
8
|
+
* the vm realm, but a direct host-realm call has NO timeout protection —
|
|
9
|
+
* an infinite loop in RuleCode would hang the host process forever.
|
|
10
|
+
*
|
|
11
|
+
* callEvaluate runs the invocation inside the vm context via
|
|
12
|
+
* Script.runInContext({ timeout }), which terminates infinite loops.
|
|
13
|
+
*
|
|
14
|
+
* Throws on timeout, compilation error, or if evaluate is missing.
|
|
15
|
+
*/
|
|
16
|
+
callEvaluate?: (input: unknown, helpers: unknown) => unknown;
|
|
17
|
+
}
|
|
18
|
+
export declare function loadRuleImplementationModule(sourceCode: string, filename: string): RuleImplementationModuleExports;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ActivatedPrinciple, PromptActivationReaderResult } from '@principles/core/runtime-v2';
|
|
2
|
+
export { RUNTIME_V2_PRINCIPLE_BUDGET } from '@principles/core/runtime-v2';
|
|
3
|
+
export type { ActivatedPrinciple, PromptActivationReaderResult };
|
|
4
|
+
export interface PromptActivationReaderDeps {
|
|
5
|
+
logger?: {
|
|
6
|
+
warn?: (msg: string) => void;
|
|
7
|
+
info?: (msg: string) => void;
|
|
8
|
+
error?: (msg: string) => void;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export declare class PromptActivationReader {
|
|
12
|
+
private readonly workspaceDir;
|
|
13
|
+
private readonly deps;
|
|
14
|
+
constructor(workspaceDir: string, deps?: PromptActivationReaderDeps);
|
|
15
|
+
readActivatedPrinciples(): Promise<PromptActivationReaderResult>;
|
|
16
|
+
private queryArtifactRow;
|
|
17
|
+
/**
|
|
18
|
+
* PRI-305/PRI-307: Load feature flags from .pd/config.yaml instead of .pd/feature-flags.yaml.
|
|
19
|
+
* Uses the shared plugin config loader for consistency.
|
|
20
|
+
*/
|
|
21
|
+
private loadFeatureFlags;
|
|
22
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type { PainConfig } from './config.js';
|
|
2
|
+
export interface TokenUsage {
|
|
3
|
+
input?: number;
|
|
4
|
+
output?: number;
|
|
5
|
+
cacheRead?: number;
|
|
6
|
+
cacheWrite?: number;
|
|
7
|
+
total?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface SessionState {
|
|
10
|
+
sessionId: string;
|
|
11
|
+
sessionKey?: string;
|
|
12
|
+
trigger?: string;
|
|
13
|
+
workspaceDir?: string;
|
|
14
|
+
toolReadsByFile: Record<string, number>;
|
|
15
|
+
llmTurns: number;
|
|
16
|
+
blockedAttempts: number;
|
|
17
|
+
lastActivityAt: number;
|
|
18
|
+
lastControlActivityAt: number;
|
|
19
|
+
totalInputTokens: number;
|
|
20
|
+
totalOutputTokens: number;
|
|
21
|
+
cacheHits: number;
|
|
22
|
+
stuckLoops: number;
|
|
23
|
+
currentGfi: number;
|
|
24
|
+
gfiBySource?: Record<string, number>;
|
|
25
|
+
lastErrorSource?: string;
|
|
26
|
+
lastErrorHash: string;
|
|
27
|
+
consecutiveErrors: number;
|
|
28
|
+
lastGfiDecayAt?: number;
|
|
29
|
+
dailyToolCalls: number;
|
|
30
|
+
dailyToolFailures: number;
|
|
31
|
+
dailyPainSignals: number;
|
|
32
|
+
dailyGfiPeak: number;
|
|
33
|
+
lastThinkingTimestamp: number;
|
|
34
|
+
injectedProbationIds?: string[];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Initialize persistence for session state.
|
|
38
|
+
* Call this once during plugin startup.
|
|
39
|
+
*/
|
|
40
|
+
export declare function initPersistence(stateDir: string): void;
|
|
41
|
+
/**
|
|
42
|
+
* Force persist all sessions immediately.
|
|
43
|
+
*/
|
|
44
|
+
export declare function flushAllSessions(): void;
|
|
45
|
+
export declare function trackToolRead(sessionId: string, filePath: string, workspaceDir?: string): SessionState;
|
|
46
|
+
export declare function trackLlmOutput(sessionId: string, usage: TokenUsage | undefined, config?: PainConfig, workspaceDir?: string, sessionKey?: string, trigger?: string): SessionState;
|
|
47
|
+
/**
|
|
48
|
+
* Tracks physical friction based on tool execution failures.
|
|
49
|
+
* Delegates to core GFI kernel for scoring.
|
|
50
|
+
*/
|
|
51
|
+
export declare function trackFriction(sessionId: string, deltaF: number, hash: string, workspaceDir?: string, options?: {
|
|
52
|
+
source?: string;
|
|
53
|
+
}): SessionState;
|
|
54
|
+
/**
|
|
55
|
+
* Resets the friction index upon successful action.
|
|
56
|
+
* Delegates to core GFI kernel for relief computation.
|
|
57
|
+
*/
|
|
58
|
+
export declare function resetFriction(sessionId: string, workspaceDir?: string, options?: {
|
|
59
|
+
source?: string;
|
|
60
|
+
amount?: number;
|
|
61
|
+
}): SessionState;
|
|
62
|
+
/**
|
|
63
|
+
* Records that deep thinking (Thinking OS) was performed in this session.
|
|
64
|
+
* Used by the Thinking OS checkpoint to allow high-risk operations.
|
|
65
|
+
*/
|
|
66
|
+
export declare function recordThinkingCheckpoint(sessionId: string, workspaceDir?: string): SessionState;
|
|
67
|
+
/**
|
|
68
|
+
* Checks if deep thinking was performed recently (within the given window).
|
|
69
|
+
* @param sessionId - The session to check
|
|
70
|
+
* @param windowMs - How recent the thinking must be (default: 5 minutes)
|
|
71
|
+
* @returns true if thinking was recorded within the window
|
|
72
|
+
*/
|
|
73
|
+
export declare function hasRecentThinking(sessionId: string, windowMs?: number): boolean;
|
|
74
|
+
export declare function trackBlock(sessionId: string): SessionState;
|
|
75
|
+
export declare function setInjectedProbationIds(sessionId: string, ids: string[], workspaceDir?: string): SessionState;
|
|
76
|
+
export declare function getInjectedProbationIds(sessionId: string, workspaceDir?: string): string[];
|
|
77
|
+
export declare function clearInjectedProbationIds(sessionId: string, workspaceDir?: string): SessionState;
|
|
78
|
+
export declare function getSession(sessionId: string): SessionState | undefined;
|
|
79
|
+
export declare function listSessions(workspaceDir?: string): SessionState[];
|
|
80
|
+
export declare function clearSession(sessionId: string): void;
|
|
81
|
+
/**
|
|
82
|
+
* Seed a session directly into SessionTracker.sessions for testing.
|
|
83
|
+
* This bypasses the normal tool-call flow to set up test data for
|
|
84
|
+
* checkWorkspaceIdle without requiring full integration test setup.
|
|
85
|
+
*
|
|
86
|
+
* @param sessionId - Session ID
|
|
87
|
+
* @param workspaceDir - Workspace directory (optional, for filtering)
|
|
88
|
+
* @param lastActivityAt - Unix timestamp in ms (default: now)
|
|
89
|
+
*/
|
|
90
|
+
export declare function seedSessionForTest(sessionId: string, workspaceDir?: string, lastActivityAt?: number): void;
|
|
91
|
+
export declare function garbageCollectSessions(): void;
|
|
92
|
+
/**
|
|
93
|
+
* Get daily statistics summary for a session.
|
|
94
|
+
*/
|
|
95
|
+
export declare function getDailySummary(sessionId: string): {
|
|
96
|
+
toolCalls: number;
|
|
97
|
+
toolFailures: number;
|
|
98
|
+
painSignals: number;
|
|
99
|
+
gfiPeak: number;
|
|
100
|
+
} | null;
|
|
101
|
+
/**
|
|
102
|
+
* Reset daily statistics (call at midnight or on new day).
|
|
103
|
+
*/
|
|
104
|
+
export declare function resetDailyStats(sessionId: string): void;
|
|
105
|
+
/**
|
|
106
|
+
* Apply time-based decay to GFI using stage-aware linear decay.
|
|
107
|
+
* Delegates to core GFI kernel.
|
|
108
|
+
*
|
|
109
|
+
* @param sessionId - The session to decay
|
|
110
|
+
* @param elapsedMinutes - Minutes since last decay
|
|
111
|
+
* @returns Updated session state, or undefined if session not found or GFI is 0
|
|
112
|
+
*/
|
|
113
|
+
export declare function decayGfi(sessionId: string, elapsedMinutes: number): SessionState | undefined;
|
|
114
|
+
/**
|
|
115
|
+
* Check if GFI decay should be applied and return elapsed minutes since last decay.
|
|
116
|
+
* @param sessionId - The session to check
|
|
117
|
+
* @returns Elapsed minutes since last decay, or 0 if no decay needed
|
|
118
|
+
*/
|
|
119
|
+
export declare function getGfiDecayElapsed(sessionId: string): number;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SignalCollectorHost — plugin I/O 外壳 (design spec §4.2)
|
|
3
|
+
*
|
|
4
|
+
* 把 core 的纯逻辑 (collectSync / mapLlmResultToOutput) 接进 openclaw 运行时。
|
|
5
|
+
*
|
|
6
|
+
* 同步路径 (prompt.ts before_prompt_build 钩子调用,绝不阻塞):
|
|
7
|
+
* - trigger 门控 (user/api/undefined 视为用户交互,其余跳过)
|
|
8
|
+
* - Stage1 关键词快扫 (零成本)
|
|
9
|
+
* - 写 user_turns (复用 recordUserTurn)
|
|
10
|
+
* - 高精度短语命中 (high) → 直接走 STRONG 分流 (同步,纯内存)
|
|
11
|
+
* - 普通歧义词 / 未命中 → 入队异步 LLM 确认 (不阻塞)
|
|
12
|
+
*
|
|
13
|
+
* 异步路径 (fire-and-forget):
|
|
14
|
+
* - Stage2 LLM 确认 (后台,不阻塞 prompt hook)
|
|
15
|
+
* - LLM 不可用 → 降级:丢弃 ambiguous 候选 (不触发 STRONG,避免误判泛滥)
|
|
16
|
+
* - 按 strength 分流:STRONG → emitPainDetectedEvent (修断裂 ③);WEAK → trackFriction 累积 GFI
|
|
17
|
+
*
|
|
18
|
+
* 降级不静默 (rc-9):所有降级路径走 SystemLogger。
|
|
19
|
+
*/
|
|
20
|
+
import { type UnifiedKeywordStore, type SignalCollectorConfig } from '@principles/core/runtime-v2';
|
|
21
|
+
import type { PluginLogger } from '../openclaw-sdk.js';
|
|
22
|
+
import type { WorkspaceContext } from './workspace-context.js';
|
|
23
|
+
export declare const DEFAULT_SIGNAL_CONFIG: SignalCollectorConfig;
|
|
24
|
+
/**
|
|
25
|
+
* 判定 trigger 是否代表真实用户交互。
|
|
26
|
+
*
|
|
27
|
+
* `user` / `api` / `undefined` 均视为用户交互(prompt.ts 与 detectSync 共享同一判定,
|
|
28
|
+
* 避免两处门控不一致导致 api/undefined 触发的纠正信号丢失)。
|
|
29
|
+
* `heartbeat` / `cron` / `subagent` 等系统触发不视为用户交互。
|
|
30
|
+
*/
|
|
31
|
+
export declare function isUserInteractionTrigger(trigger: string | undefined): boolean;
|
|
32
|
+
export declare function buildDefaultKeywordStore(): UnifiedKeywordStore;
|
|
33
|
+
/**
|
|
34
|
+
* adapter 抽象 (Stage2 LLM 调用)。plugin 层可注入真实 adapter (LMStudio);
|
|
35
|
+
* 为 null / 不可用时 host 走纯关键词降级。
|
|
36
|
+
*
|
|
37
|
+
* 本文件不依赖具体的 PDRuntimeAdapter 实现,只依赖一个最小的分类函数,
|
|
38
|
+
* 以保持 host 可单测 (测试可注入 mock classifier)。
|
|
39
|
+
*/
|
|
40
|
+
export type SignalLlmClassifier = (text: string, promptTemplate: string) => Promise<{
|
|
41
|
+
is_feedback: boolean;
|
|
42
|
+
type: 'correction' | 'empathy' | 'none';
|
|
43
|
+
confidence: number;
|
|
44
|
+
reason: string;
|
|
45
|
+
} | null>;
|
|
46
|
+
export interface SignalCollectorHostOptions {
|
|
47
|
+
keywordStore?: UnifiedKeywordStore;
|
|
48
|
+
config?: SignalCollectorConfig;
|
|
49
|
+
/** Stage2 LLM 分类器。null/undefined → 降级纯关键词。 */
|
|
50
|
+
llmClassifier?: SignalLlmClassifier | null;
|
|
51
|
+
}
|
|
52
|
+
export declare class SignalCollectorHost {
|
|
53
|
+
private readonly wctx;
|
|
54
|
+
private readonly store;
|
|
55
|
+
private readonly config;
|
|
56
|
+
private readonly llmClassifier;
|
|
57
|
+
/** rate limit 状态:sessionId → STRONG 计数桶 */
|
|
58
|
+
private readonly rateLimit;
|
|
59
|
+
constructor(wctx: WorkspaceContext, options?: SignalCollectorHostOptions);
|
|
60
|
+
/**
|
|
61
|
+
* ★ 同步路径 (prompt.ts before_prompt_build 钩子里调用,绝不能阻塞)。
|
|
62
|
+
*
|
|
63
|
+
* 只做:trigger 门控 + Stage1 关键词快扫 + 写 user_turns。
|
|
64
|
+
* 高精度短语命中 (high) → 直接走 STRONG 分流 (同步,纯内存)。
|
|
65
|
+
* 普通歧义词 / 未命中 → 入队异步 LLM 确认 (不阻塞)。
|
|
66
|
+
*/
|
|
67
|
+
/**
|
|
68
|
+
* 可选入参:lineage 字段(由调用方算好传入,host 不感知 trajectory 结构)。
|
|
69
|
+
* referencesAssistantTurnId 让诊断 evidence 能 JOIN 到前置 assistant turn。
|
|
70
|
+
*/
|
|
71
|
+
detectSync(userMessage: string, sessionId: string, trigger: string, options?: {
|
|
72
|
+
referencesAssistantTurnId?: number | null;
|
|
73
|
+
turnIndex?: number;
|
|
74
|
+
}): void;
|
|
75
|
+
/**
|
|
76
|
+
* ★ 异步路径 (fire-and-forget)。
|
|
77
|
+
*
|
|
78
|
+
* 1. Stage2 LLM 确认 (后台,不阻塞用户)
|
|
79
|
+
* 2. LLM 不可用 → 降级:empathy ambiguous 候选作为 WEAK 信号路由(保留旧版 GFI 累积);
|
|
80
|
+
* correction ambiguous / 未命中候选丢弃(不触发 STRONG,避免误判泛滥)
|
|
81
|
+
* 3. 按 strength 分流:STRONG → emitPainDetectedEvent;WEAK → trackFriction 累积 GFI;none → 仅记录
|
|
82
|
+
*/
|
|
83
|
+
private detectAsyncAndRoute;
|
|
84
|
+
/**
|
|
85
|
+
* STRONG 分流 → emitPainDetectedEvent (修断裂 ③)。
|
|
86
|
+
* 带 STRONG rate limit 门控 (spec §7.2):单 session 每小时上限 strongRateLimitPerHour。
|
|
87
|
+
*/
|
|
88
|
+
private routeStrong;
|
|
89
|
+
/**
|
|
90
|
+
* WEAK 分流 → trackFriction 累积 GFI + 写 evidence (维持现状,spec §3.2)。
|
|
91
|
+
*
|
|
92
|
+
* WEAK 是 Layer 3 弱信号,用较小的摩擦分(20)累积,过 highGfi 阈值(70)才触发诊断。
|
|
93
|
+
* 不用 strongPainScore(70),因为 WEAK 单条不该直接顶满 GFI。
|
|
94
|
+
*/
|
|
95
|
+
private routeWeak;
|
|
96
|
+
/**
|
|
97
|
+
* STRONG rate limit 门控:成功消耗一个名额返回 true;超限返回 false。
|
|
98
|
+
* 窗口满一小时自动重置。
|
|
99
|
+
*/
|
|
100
|
+
private tryConsumeRateLimit;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* 从 .pd/config.yaml 的 signalCollector runtimeProfile 构造 SignalLlmClassifier。
|
|
104
|
+
* 完成配置单轨化(spec §3.3 决策3):统一走 .pd/config.yaml,移除 empathy 的 workflows.yaml 双轨。
|
|
105
|
+
*
|
|
106
|
+
* 返回 null 的情况(走纯关键词降级,rc-9 不静默):
|
|
107
|
+
* - feature flag signal_collector 关闭
|
|
108
|
+
* - runtimeProfile 未配置 / apiKeyEnv 缺失
|
|
109
|
+
* - profile 是 openclaw 类型(observer 不支持)
|
|
110
|
+
*
|
|
111
|
+
* 这是 Task 11 的最后一块:让本地 LLM(LMStudio)真正参与检测。
|
|
112
|
+
*/
|
|
113
|
+
export declare function createSignalLlmClassifierFromConfig(wctx: WorkspaceContext, logger?: Pick<PluginLogger, 'info' | 'warn' | 'error' | 'debug'>): SignalLlmClassifier | null;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const SystemLogger: {
|
|
2
|
+
log(workspaceDir: string | undefined, eventType: string, message: string): void;
|
|
3
|
+
/**
|
|
4
|
+
* Force refresh of the cached log file path.
|
|
5
|
+
* Call this at midnight or when the date changes to ensure proper rotation.
|
|
6
|
+
*
|
|
7
|
+
* PRI-504: clears log-file and log-date caches for ALL workspaces (preserves
|
|
8
|
+
* the original "force refresh" semantics). Does NOT clear lastCleanupDates
|
|
9
|
+
* to avoid re-triggering cleanup for every workspace on the same day.
|
|
10
|
+
*/
|
|
11
|
+
refreshCache(): void;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* PRI-504: dispose the SystemLogger cache for a single workspace.
|
|
15
|
+
* Useful for tests and for workspace teardown in multi-workspace processes.
|
|
16
|
+
* Pattern follows evolution-engine.ts:564-570 (disposeEvolutionEngine).
|
|
17
|
+
*/
|
|
18
|
+
export declare function disposeSystemLogger(workspaceDir: string): void;
|
|
19
|
+
/**
|
|
20
|
+
* PRI-504: dispose ALL SystemLogger caches. Call this in test afterEach
|
|
21
|
+
* hooks to prevent state leakage between tests. Pattern follows
|
|
22
|
+
* evolution-engine.ts:572-577 (disposeAllEvolutionEngines).
|
|
23
|
+
*/
|
|
24
|
+
export declare function disposeAllSystemLoggers(): void;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thinking Models — Plugin I/O Adapter (Stage 3 slim)
|
|
3
|
+
*
|
|
4
|
+
* Pure logic (BUILTIN_PATTERNS, BUILTIN_PATTERN_MAP, getFallbackName,
|
|
5
|
+
* getFallbackDescription, deriveThinkingScenarios, types) lives in
|
|
6
|
+
* @principles/core/runtime-v2/thinking-models.
|
|
7
|
+
*
|
|
8
|
+
* This file owns only the I/O boundary: reading THINKING_OS.md from a
|
|
9
|
+
* workspace dir and merging it with the builtin patterns. It re-exports
|
|
10
|
+
* the pure functions and types so existing relative imports
|
|
11
|
+
* (../core/thinking-models.js) continue to resolve.
|
|
12
|
+
*/
|
|
13
|
+
import { type ThinkingModelDefinition, type ThinkingModelMatch } from '@principles/core/runtime-v2';
|
|
14
|
+
export { BUILTIN_PATTERN_MAP, getFallbackName, getFallbackDescription, } from '@principles/core/runtime-v2';
|
|
15
|
+
export { deriveThinkingScenarios } from '@principles/core/runtime-v2';
|
|
16
|
+
export type { ThinkingModelDefinition, ThinkingModelMatch, ThinkingScenarioContext, } from '@principles/core/runtime-v2';
|
|
17
|
+
/**
|
|
18
|
+
* Load thinking model definitions dynamically from THINKING_OS.md.
|
|
19
|
+
* Falls back to built-in definitions if parsing fails.
|
|
20
|
+
*
|
|
21
|
+
* @param workspaceDir Optional. If provided, loads from that workspace's THINKING_OS.md.
|
|
22
|
+
*/
|
|
23
|
+
export declare function listThinkingModels(workspaceDir?: string): ThinkingModelDefinition[];
|
|
24
|
+
export declare function getThinkingModel(modelId: string, workspaceDir?: string): ThinkingModelDefinition | undefined;
|
|
25
|
+
export declare function detectThinkingModelMatches(text: string, workspaceDir?: string): ThinkingModelMatch[];
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thinking OS XML Parser
|
|
3
|
+
*
|
|
4
|
+
* Parses THINKING_OS.md to extract directive definitions.
|
|
5
|
+
* THINKING_OS.md is the single source of truth for thinking models.
|
|
6
|
+
*
|
|
7
|
+
* XML structure:
|
|
8
|
+
* <directive id="T-01" name="MAP_BEFORE_TERRITORY">
|
|
9
|
+
* <trigger>...</trigger>
|
|
10
|
+
* <must>...</must>
|
|
11
|
+
* <forbidden>...</forbidden>
|
|
12
|
+
* </directive>
|
|
13
|
+
*/
|
|
14
|
+
export interface ThinkingOsDirective {
|
|
15
|
+
id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
trigger: string;
|
|
18
|
+
must: string;
|
|
19
|
+
forbidden: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Parse THINKING_OS.md content and extract all <directive> blocks.
|
|
23
|
+
* Returns empty array if no directives found.
|
|
24
|
+
*/
|
|
25
|
+
export declare function parseThinkingOsMd(content: string): ThinkingOsDirective[];
|
|
26
|
+
/**
|
|
27
|
+
* Load THINKING_OS.md from the plugin templates for a given language.
|
|
28
|
+
* Falls back to the workspace THINKING_OS.md if it exists.
|
|
29
|
+
*/
|
|
30
|
+
export declare function loadThinkingOsFromWorkspace(workspaceDir: string, language?: string): ThinkingOsDirective[];
|
|
31
|
+
/**
|
|
32
|
+
* Extract meaningful detection keywords from a trigger string.
|
|
33
|
+
* Returns an array of regex patterns.
|
|
34
|
+
*/
|
|
35
|
+
export declare function generateDetectionPatterns(trigger: string): RegExp[];
|