@wrongstack/core 0.302.2 → 0.305.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/chronicle/index.js +117 -30
- package/dist/chronicle/project-server.js +12 -5
- package/dist/coordination/agents/index.js +4645 -3448
- package/dist/coordination/agents/project-agent-auto-optimize.d.ts +116 -0
- package/dist/coordination/agents/project-agent-capture-window.d.ts +29 -0
- package/dist/coordination/agents/project-agent-config-io.d.ts +11 -0
- package/dist/coordination/agents/project-agent-consolidation.d.ts +34 -2
- package/dist/coordination/agents/project-agent-directive-outcome.d.ts +57 -0
- package/dist/coordination/agents/project-agent-files.d.ts +12 -3
- package/dist/coordination/agents/project-agent-identity-types.d.ts +4 -0
- package/dist/coordination/agents/project-agent-identity.d.ts +38 -11
- package/dist/coordination/agents/project-agent-learning-entries.d.ts +8 -2
- package/dist/coordination/agents/project-agent-learning-policy.d.ts +22 -1
- package/dist/coordination/agents/project-agent-learning-structured.d.ts +72 -1
- package/dist/coordination/agents/project-agent-optimizer.d.ts +49 -0
- package/dist/coordination/agents/project-agent-quarantine.d.ts +63 -0
- package/dist/coordination/agents/project-agent-skill-layer.d.ts +146 -0
- package/dist/coordination/agents/role-skills.d.ts +11 -1
- package/dist/coordination/agents/types.d.ts +10 -2
- package/dist/coordination/director-prompts.d.ts +19 -6
- package/dist/coordination/director-tools.d.ts +2 -2
- package/dist/coordination/fleet.d.ts +0 -6
- package/dist/coordination/index.d.ts +1 -1
- package/dist/coordination/index.js +5746 -4326
- package/dist/coordination/mail-tools.d.ts +1 -1
- package/dist/core/agent-types.d.ts +4 -2
- package/dist/core/agent.d.ts +1 -0
- package/dist/core/context.d.ts +19 -0
- package/dist/core/conversation-state.d.ts +14 -0
- package/dist/core/fallback-profile-manager.d.ts +70 -2
- package/dist/core/index.js +317 -108
- package/dist/core/system-prompt-blocks.d.ts +1 -1
- package/dist/core/system-prompt-builder.d.ts +13 -1
- package/dist/core/system-prompt-glossary.d.ts +73 -0
- package/dist/core/system-prompt-memory-skills.d.ts +2 -2
- package/dist/defaults/index.js +1635 -1120
- package/dist/execution/council-orchestrator.d.ts +3 -13
- package/dist/execution/index.js +3136 -2706
- package/dist/execution/one-shot-llm.d.ts +5 -0
- package/dist/goal/index.js +7 -0
- package/dist/hq/index.js +17 -7
- package/dist/hq/protocol/kanban.d.ts +21 -0
- package/dist/hq/protocol.js +5 -1
- package/dist/hq/redaction.d.ts +14 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +5502 -3483
- package/dist/infrastructure/index.js +247 -122
- package/dist/kernel/events/agent-events.d.ts +28 -0
- package/dist/plugin/index.js +111 -7
- package/dist/registry/index.js +11 -0
- package/dist/registry/tool-registry.d.ts +8 -0
- package/dist/replay/hash.d.ts +9 -0
- package/dist/replay/index.js +14 -4
- package/dist/replay/replay-provider-runner.d.ts +31 -1
- package/dist/security/index.js +92 -21
- package/dist/security/kanban-boundary.d.ts +5 -1
- package/dist/security/secret-vault.d.ts +2 -0
- package/dist/session-catalog/index.js +86 -10
- package/dist/session-catalog/project-server.js +100 -17
- package/dist/session-catalog/protocol.d.ts +20 -4
- package/dist/session-catalog/store.d.ts +19 -3
- package/dist/storage/index.js +305 -69
- package/dist/storage/memory-consolidator.d.ts +4 -2
- package/dist/storage/plan-store.d.ts +1 -1
- package/dist/storage/session-resume-validation.d.ts +24 -0
- package/dist/storage/session-store/directory-scan.d.ts +5 -1
- package/dist/storage/session-store/fork-session.d.ts +13 -1
- package/dist/storage/session-store/load-cache.d.ts +11 -0
- package/dist/storage/session-store/prune-helpers.d.ts +5 -0
- package/dist/storage/session-store.d.ts +18 -0
- package/dist/tasking/index.js +5 -0
- package/dist/tools/index.js +1151 -831
- package/dist/types/config/mcp-features.d.ts +31 -1
- package/dist/types/config/root.d.ts +23 -1
- package/dist/types/config/skills-fleet-brain.d.ts +34 -0
- package/dist/types/config/tools.d.ts +22 -0
- package/dist/types/config/ui.d.ts +14 -0
- package/dist/types/config.d.ts +1 -0
- package/dist/types/default-config.d.ts +1 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.js +23 -0
- package/dist/types/multi-agent.d.ts +7 -0
- package/dist/types/session.d.ts +9 -1
- package/dist/types/task-graph.d.ts +2 -0
- package/dist/types/tool-executor.d.ts +2 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +217 -76
- package/dist/utils/project-state-guard.d.ts +21 -0
- package/dist/utils/session-scoped-path.d.ts +17 -0
- package/dist/utils/todos-format.d.ts +20 -0
- package/instructions/leader-after-task.md +3 -4
- package/instructions/system-lite.md +17 -14
- package/instructions/system-pro.md +29 -30
- package/instructions/system.md +29 -28
- package/package.json +3 -3
- package/skills/wrongstack-kanban/SKILL.md +95 -93
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Automatic learning optimization.
|
|
3
|
+
*
|
|
4
|
+
* Capture is automatic, but distillation used to be a button someone had to
|
|
5
|
+
* press — so a role kept accumulating raw directives and its skills never grew
|
|
6
|
+
* unless a human remembered to run `/agent-improve <role> optimize`. This
|
|
7
|
+
* scheduler closes that gap: it watches captures, decides when a role has
|
|
8
|
+
* earned a pass, and runs `optimizeProjectAgentLearning` in the background.
|
|
9
|
+
*
|
|
10
|
+
* Design constraints, in priority order:
|
|
11
|
+
*
|
|
12
|
+
* 1. **Never block user-facing work.** Every pass is detached and debounced;
|
|
13
|
+
* a capture returns immediately.
|
|
14
|
+
* 2. **Never stampede.** One pass at a time process-wide, one pending pass per
|
|
15
|
+
* role, and a per-role cooldown so a chatty fleet cannot spend the budget
|
|
16
|
+
* on back-to-back optimizations of the same buffer.
|
|
17
|
+
* 3. **Never crash the host.** Failures are swallowed into an exponential
|
|
18
|
+
* backoff; a dead provider degrades to "no optimization" and not to a hot
|
|
19
|
+
* retry loop or a rejected promise nobody awaits.
|
|
20
|
+
* 4. **Do something useful without a model.** With no LLM available the pass
|
|
21
|
+
* still writes the deterministic per-skill addenda, so tagged learning
|
|
22
|
+
* reaches the skill layer on a headless box.
|
|
23
|
+
*/
|
|
24
|
+
import { type LearningOptimizerLlm, type OptimizeLearningResult } from './project-agent-optimizer.js';
|
|
25
|
+
export interface AutoOptimizePolicy {
|
|
26
|
+
/** Master switch. Default true. */
|
|
27
|
+
enabled: boolean;
|
|
28
|
+
/** Raw buffer size that makes a role eligible. Default = the soft limit. */
|
|
29
|
+
thresholdBytes: number;
|
|
30
|
+
/** Never optimize a nearly-empty buffer, whatever its byte size. */
|
|
31
|
+
minEntries: number;
|
|
32
|
+
/**
|
|
33
|
+
* Directives already routed to a skill that has no addendum yet. Reaching
|
|
34
|
+
* this count makes a role eligible even below `thresholdBytes` — getting
|
|
35
|
+
* learning into the skill layer promptly is the point of the loop, and
|
|
36
|
+
* waiting for the buffer to fatten delays it for no reason.
|
|
37
|
+
*/
|
|
38
|
+
minPendingSkillDirectives: number;
|
|
39
|
+
/** Minimum gap between two automatic passes for one role. */
|
|
40
|
+
minIntervalMs: number;
|
|
41
|
+
/** Quiet period after the last capture before a pass may start. */
|
|
42
|
+
debounceMs: number;
|
|
43
|
+
}
|
|
44
|
+
export declare const DEFAULT_AUTO_OPTIMIZE_POLICY: AutoOptimizePolicy;
|
|
45
|
+
/** Shape accepted from config, where every field is independently optional. */
|
|
46
|
+
export type AutoOptimizePolicyOverrides = {
|
|
47
|
+
[K in keyof AutoOptimizePolicy]?: AutoOptimizePolicy[K] | undefined;
|
|
48
|
+
} & {
|
|
49
|
+
sweepOnStart?: boolean | undefined;
|
|
50
|
+
};
|
|
51
|
+
export declare function resolveAutoOptimizePolicy(overrides?: AutoOptimizePolicyOverrides | undefined): AutoOptimizePolicy;
|
|
52
|
+
export type AutoOptimizeSkipReason = 'disabled' | 'learning-paused' | 'too-few-entries' | 'below-threshold' | 'cooling-down';
|
|
53
|
+
export type AutoOptimizeDecision = {
|
|
54
|
+
eligible: true;
|
|
55
|
+
reason: 'size' | 'pending-skills';
|
|
56
|
+
} | {
|
|
57
|
+
eligible: false;
|
|
58
|
+
reason: AutoOptimizeSkipReason;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Pure eligibility check — no timers, no I/O beyond reading the role's files.
|
|
62
|
+
* Exported so the decision can be tested and surfaced in a status view
|
|
63
|
+
* without running a pass.
|
|
64
|
+
*/
|
|
65
|
+
export declare function evaluateAutoOptimize(role: string, projectRoot: string | undefined, policy: AutoOptimizePolicy, now?: number): AutoOptimizeDecision;
|
|
66
|
+
export interface AutoOptimizeEvent {
|
|
67
|
+
role: string;
|
|
68
|
+
trigger: 'size' | 'pending-skills' | 'manual-sweep';
|
|
69
|
+
result?: OptimizeLearningResult | undefined;
|
|
70
|
+
error?: string | undefined;
|
|
71
|
+
}
|
|
72
|
+
export interface LearningOptimizationSchedulerOptions {
|
|
73
|
+
projectRoot: string;
|
|
74
|
+
getPolicy: () => AutoOptimizePolicy;
|
|
75
|
+
/** Resolved lazily so a pass never holds a provider open between runs. */
|
|
76
|
+
getLlm: () => Promise<LearningOptimizerLlm | undefined> | LearningOptimizerLlm | undefined;
|
|
77
|
+
onEvent?: ((event: AutoOptimizeEvent) => void) | undefined;
|
|
78
|
+
/** Injectable clock/timer for deterministic tests. */
|
|
79
|
+
now?: (() => number) | undefined;
|
|
80
|
+
scheduleTimer?: ((fn: () => void, ms: number) => NodeJS.Timeout) | undefined;
|
|
81
|
+
cancelTimer?: ((handle: NodeJS.Timeout) => void) | undefined;
|
|
82
|
+
}
|
|
83
|
+
export declare class LearningOptimizationScheduler {
|
|
84
|
+
private readonly opts;
|
|
85
|
+
private readonly pending;
|
|
86
|
+
private readonly failures;
|
|
87
|
+
private running;
|
|
88
|
+
private inFlight;
|
|
89
|
+
private disposed;
|
|
90
|
+
constructor(opts: LearningOptimizationSchedulerOptions);
|
|
91
|
+
private get now();
|
|
92
|
+
private schedule;
|
|
93
|
+
/**
|
|
94
|
+
* Called after a capture persisted new directives. Debounced per role: a
|
|
95
|
+
* burst of captures collapses into one pass.
|
|
96
|
+
*/
|
|
97
|
+
notifyCaptured(role: string): void;
|
|
98
|
+
/**
|
|
99
|
+
* Evaluate every role that has learning data and queue the eligible ones.
|
|
100
|
+
* Run once at host start so roles that crossed the threshold before the
|
|
101
|
+
* scheduler existed are not stuck waiting for their next capture.
|
|
102
|
+
*/
|
|
103
|
+
sweep(roles: readonly string[]): void;
|
|
104
|
+
private runIfEligible;
|
|
105
|
+
/** Serialize passes: one optimization at a time, process-wide. */
|
|
106
|
+
private enqueue;
|
|
107
|
+
private execute;
|
|
108
|
+
private recordFailure;
|
|
109
|
+
/** Role currently being optimized, for status surfaces. */
|
|
110
|
+
activeRole(): string | null;
|
|
111
|
+
/** Cancel pending debounces. Safe to call more than once. */
|
|
112
|
+
dispose(): void;
|
|
113
|
+
/** Await the queue — tests only; production never blocks on a pass. */
|
|
114
|
+
idle(): Promise<void>;
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=project-agent-auto-optimize.d.ts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capture rate-limiting window.
|
|
3
|
+
*
|
|
4
|
+
* The frequency cap is documented as "per session", but the counters used to
|
|
5
|
+
* live in module-level Maps that were never reset. In a long-lived project
|
|
6
|
+
* daemon that made the cap "3 captures per role per *process lifetime*" — the
|
|
7
|
+
* observable symptom being roles that silently stopped learning days ago.
|
|
8
|
+
*
|
|
9
|
+
* The window is now time-boxed: counters roll over after
|
|
10
|
+
* `CAPTURE_SESSION_WINDOW_MS`, and a host can reset them explicitly when a real
|
|
11
|
+
* session boundary occurs (`/clear`, resume, new REPL turn batch).
|
|
12
|
+
*/
|
|
13
|
+
/** Minimum spacing between two automatic captures for one role. */
|
|
14
|
+
export declare const CAPTURE_COOLDOWN_MS = 120000;
|
|
15
|
+
/** Automatic captures allowed per role within one window. */
|
|
16
|
+
export declare const CAPTURE_MAX_PER_SESSION = 3;
|
|
17
|
+
/** How long a counting window lasts before it rolls over. */
|
|
18
|
+
export declare const CAPTURE_SESSION_WINDOW_MS: number;
|
|
19
|
+
export declare function captureWindowState(key: string, now?: number): {
|
|
20
|
+
count: number;
|
|
21
|
+
lastCaptureAt: number | undefined;
|
|
22
|
+
remaining: number;
|
|
23
|
+
};
|
|
24
|
+
export declare function recordCaptureAttempt(key: string, now?: number): void;
|
|
25
|
+
/** Drop every counter. Called on an explicit session boundary and by tests. */
|
|
26
|
+
export declare function resetCaptureWindows(): void;
|
|
27
|
+
/** Drop the counters for one role/project key. */
|
|
28
|
+
export declare function resetCaptureWindow(key: string): void;
|
|
29
|
+
//# sourceMappingURL=project-agent-capture-window.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ProjectAgentConfig } from './project-agent-identity-types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Load the project-level agent config for a given role.
|
|
4
|
+
* Returns `undefined` when no project override exists.
|
|
5
|
+
*
|
|
6
|
+
* Lives in its own module (rather than in `project-agent-identity.ts`) so the
|
|
7
|
+
* skill layer can read the role's `skillNames` override without importing the
|
|
8
|
+
* identity module, which imports the skill layer.
|
|
9
|
+
*/
|
|
10
|
+
export declare function loadProjectAgentConfig(role: string, projectRoot?: string): ProjectAgentConfig | undefined;
|
|
11
|
+
//# sourceMappingURL=project-agent-config-io.d.ts.map
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
+
import { type StructuredLearnedEntry } from './project-agent-learning-structured.js';
|
|
1
2
|
export interface ConsolidationMetadata {
|
|
2
3
|
/** ISO timestamp of the last consolidation. */
|
|
3
4
|
consolidatedAt: string;
|
|
4
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Number of raw `learned.md` **directives** that were synthesized.
|
|
7
|
+
*
|
|
8
|
+
* Counted with the structured parser. It used to be counted with
|
|
9
|
+
* `splitLearnedEntries`, which returns 2 for any structured buffer, so the
|
|
10
|
+
* freshness comparison in `buildProjectContextualizedPrompt` compared 2
|
|
11
|
+
* against 2 forever and the delta-injection branch was unreachable.
|
|
12
|
+
*/
|
|
5
13
|
sourceEntryCount: number;
|
|
6
14
|
/** Byte size of the raw learned.md at consolidation time. */
|
|
7
15
|
sourceBytes: number;
|
|
@@ -11,11 +19,35 @@ export interface ConsolidationMetadata {
|
|
|
11
19
|
trigger: 'manual' | 'automatic';
|
|
12
20
|
/** Optional model that produced the consolidation. */
|
|
13
21
|
model?: string | undefined;
|
|
22
|
+
/** Whether the raw buffer was archived and reset after synthesis. */
|
|
23
|
+
pruned?: boolean | undefined;
|
|
24
|
+
/** Archive file holding the pre-prune raw buffer, when pruned. */
|
|
25
|
+
archivePath?: string | undefined;
|
|
26
|
+
/** Skill addenda refreshed by this pass. */
|
|
27
|
+
skills?: string[] | undefined;
|
|
14
28
|
}
|
|
29
|
+
/** Structured directives in the raw buffer, with legacy-format fallback. */
|
|
30
|
+
export declare function readRawLearnedEntries(role: string, projectRoot?: string): StructuredLearnedEntry[];
|
|
31
|
+
/**
|
|
32
|
+
* The role document's path, for callers that need to rewrite it in place
|
|
33
|
+
* without going through the full save-and-record-metadata pass.
|
|
34
|
+
*/
|
|
35
|
+
export declare function consolidatedDocumentPath(role: string, projectRoot?: string): string;
|
|
15
36
|
export declare function loadProjectAgentConsolidated(role: string, projectRoot?: string): string;
|
|
16
37
|
export declare function loadConsolidationMetadata(role: string, projectRoot?: string): ConsolidationMetadata | undefined;
|
|
17
38
|
export declare function isConsolidated(role: string, projectRoot?: string): boolean;
|
|
18
|
-
export
|
|
39
|
+
export interface SaveConsolidationOptions extends Partial<ConsolidationMetadata> {
|
|
40
|
+
/**
|
|
41
|
+
* Archive the raw buffer and reset it to an empty structured document.
|
|
42
|
+
*
|
|
43
|
+
* Consolidation used to leave `learned.md` untouched, so a role whose buffer
|
|
44
|
+
* had crossed the soft limit stayed over it forever and never captured
|
|
45
|
+
* again. Pruning is what actually closes the optimize→learn loop; the
|
|
46
|
+
* pre-prune buffer is kept under `archive/` for audit.
|
|
47
|
+
*/
|
|
48
|
+
prune?: boolean | undefined;
|
|
49
|
+
}
|
|
50
|
+
export declare function saveProjectAgentConsolidated(role: string, content: string, projectRoot?: string, options?: SaveConsolidationOptions): string;
|
|
19
51
|
export declare function clearProjectAgentConsolidated(role: string, projectRoot?: string): void;
|
|
20
52
|
export declare function buildConsolidationInstruction(role: string, projectRoot?: string): {
|
|
21
53
|
instruction: string;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Outcome attribution for captured directives.
|
|
3
|
+
*
|
|
4
|
+
* Capture answers "what did the agent conclude?". This module answers the
|
|
5
|
+
* question the loop was missing: **did that conclusion help?** Without it the
|
|
6
|
+
* environment's reward reached `affinity.json` and stopped there, so a directive
|
|
7
|
+
* that made every task worse was injected forever and could only ever leave the
|
|
8
|
+
* buffer by growing old.
|
|
9
|
+
*
|
|
10
|
+
* The attribution is deliberately cheap and model-free. When a task finishes,
|
|
11
|
+
* its final report is scanned for evidence that each already-stored directive
|
|
12
|
+
* was actually exercised — its anchors (commands, paths, package names, which
|
|
13
|
+
* capture already extracts into `entry.how`) appearing verbatim, or enough of
|
|
14
|
+
* its distinctive wording to be unambiguous. Every directive that was exercised
|
|
15
|
+
* takes the task's outcome onto its own record.
|
|
16
|
+
*
|
|
17
|
+
* This is correlation, not proof: a directive can be mentioned and irrelevant,
|
|
18
|
+
* or decisive and unmentioned. It is used accordingly — to order eviction, to
|
|
19
|
+
* protect proven rules from being overwritten, to retire rules that keep losing,
|
|
20
|
+
* and to tell the distillation pass which directives earned their place. None of
|
|
21
|
+
* those decisions is safe to make on age alone, which is what they used before.
|
|
22
|
+
*/
|
|
23
|
+
import { type StructuredLearnedEntry } from './project-agent-learning-structured.js';
|
|
24
|
+
/** Trials a directive must have before a bad record can retire it. */
|
|
25
|
+
export declare const DIRECTIVE_QUARANTINE_MIN_APPLIED = 8;
|
|
26
|
+
/** Utility below which a directive with enough trials is retired. */
|
|
27
|
+
export declare const DIRECTIVE_QUARANTINE_MAX_UTILITY = 0.3;
|
|
28
|
+
/**
|
|
29
|
+
* Whether `report` shows this directive was exercised.
|
|
30
|
+
*
|
|
31
|
+
* One anchor is enough: anchors are exact commands, paths and package names, so
|
|
32
|
+
* their appearance in a report is a direct statement that the thing the
|
|
33
|
+
* directive is about was touched. Directives with no anchors fall back to
|
|
34
|
+
* wording, which needs a high bar because generic prose overlaps easily.
|
|
35
|
+
*/
|
|
36
|
+
export declare function directiveWasApplied(entry: StructuredLearnedEntry, report: string): boolean;
|
|
37
|
+
export interface DirectiveOutcomeResult {
|
|
38
|
+
role: string;
|
|
39
|
+
/** Directives credited with this task's outcome. */
|
|
40
|
+
attributed: number;
|
|
41
|
+
/** Directives retired into `quarantine.md` by this update. */
|
|
42
|
+
quarantined: string[];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Fold one completed task's outcome into the record of every directive it
|
|
46
|
+
* exercised, then retire the ones whose record has become bad enough.
|
|
47
|
+
*
|
|
48
|
+
* Must run **before** the same output is captured: a directive written by this
|
|
49
|
+
* task has not been tested by this task, and crediting it here would let every
|
|
50
|
+
* new directive vouch for itself.
|
|
51
|
+
*
|
|
52
|
+
* Can throw on an invalid role or an unwritable role directory. Callers on the
|
|
53
|
+
* task-completion path must swallow it: a lost outcome costs ranking quality,
|
|
54
|
+
* which is never worth failing a completed task over.
|
|
55
|
+
*/
|
|
56
|
+
export declare function recordDirectiveOutcomes(role: string, report: string, succeeded: boolean, projectRoot?: string): DirectiveOutcomeResult;
|
|
57
|
+
//# sourceMappingURL=project-agent-directive-outcome.d.ts.map
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import type { ProjectAgentConfig, RoleKnowledgeManifest } from './project-agent-identity-types.js';
|
|
2
2
|
/**
|
|
3
|
-
* Write or update the learned
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* Write or update the learned instruction buffer for a given role.
|
|
4
|
+
*
|
|
5
|
+
* `append` (the "teach this agent" flow) merges the text into the **structured**
|
|
6
|
+
* entry list rather than concatenating it after the rendered document. Raw
|
|
7
|
+
* concatenation used to be silently destructive: the structured parser only
|
|
8
|
+
* falls back to the legacy chunk path when it finds no stamped entries, so a
|
|
9
|
+
* taught paragraph appended to a stamped buffer was invisible to the parser and
|
|
10
|
+
* the next capture — which re-renders the whole file from parsed entries —
|
|
11
|
+
* deleted it without a trace.
|
|
12
|
+
*
|
|
13
|
+
* `replace` writes the content verbatim (the review/edit surfaces own the
|
|
14
|
+
* document at that point).
|
|
6
15
|
*/
|
|
7
16
|
export declare function updateProjectAgentLearned(role: string, content: string, projectRoot?: string, mode?: 'append' | 'replace'): string;
|
|
8
17
|
/**
|
|
@@ -70,6 +70,10 @@ export interface LearnedCaptureResult {
|
|
|
70
70
|
skipped: number;
|
|
71
71
|
status: 'captured' | 'disabled' | 'empty_output' | 'no_blocks' | 'guarded' | 'quality_rejected';
|
|
72
72
|
reason?: string | undefined;
|
|
73
|
+
/** Skills the captured directives were routed to, if any. */
|
|
74
|
+
skills?: string[] | undefined;
|
|
75
|
+
/** Older directives evicted to keep the buffer inside its budget. */
|
|
76
|
+
evicted?: number | undefined;
|
|
73
77
|
}
|
|
74
78
|
/**
|
|
75
79
|
* Current-knowledge manifest for a role: what live facts the agent should
|
|
@@ -19,17 +19,27 @@
|
|
|
19
19
|
*/
|
|
20
20
|
import { existsSync } from 'node:fs';
|
|
21
21
|
import type { SubagentConfig } from '../../types/multi-agent.js';
|
|
22
|
+
import { CAPTURE_COOLDOWN_MS, CAPTURE_MAX_PER_SESSION } from './project-agent-capture-window.js';
|
|
22
23
|
import { type ConsolidationMetadata } from './project-agent-consolidation.js';
|
|
23
24
|
import type { LearnedCaptureResult, ProjectAgentConfig, RoleKnowledgeManifest } from './project-agent-identity-types.js';
|
|
24
25
|
import { type ProjectAgentLearningPolicy } from './project-agent-learning-policy.js';
|
|
25
26
|
import { type StructuredLearnedEntry } from './project-agent-learning-structured.js';
|
|
27
|
+
export { type AutoOptimizeDecision, type AutoOptimizeEvent, type AutoOptimizePolicy, type AutoOptimizePolicyOverrides, DEFAULT_AUTO_OPTIMIZE_POLICY, evaluateAutoOptimize, LearningOptimizationScheduler, type LearningOptimizationSchedulerOptions, resolveAutoOptimizePolicy, } from './project-agent-auto-optimize.js';
|
|
28
|
+
export { CAPTURE_SESSION_WINDOW_MS, resetCaptureWindow, resetCaptureWindows, } from './project-agent-capture-window.js';
|
|
29
|
+
export { loadProjectAgentConfig } from './project-agent-config-io.js';
|
|
26
30
|
export { validateProjectAgentConfig } from './project-agent-config-validation.js';
|
|
27
|
-
export { buildConsolidationInstruction, type ConsolidationMetadata, clearProjectAgentConsolidated, isConsolidated, loadConsolidationMetadata, loadProjectAgentConsolidated, saveProjectAgentConsolidated, } from './project-agent-consolidation.js';
|
|
31
|
+
export { buildConsolidationInstruction, type ConsolidationMetadata, clearProjectAgentConsolidated, consolidatedDocumentPath, isConsolidated, loadConsolidationMetadata, loadProjectAgentConsolidated, readRawLearnedEntries, type SaveConsolidationOptions, saveProjectAgentConsolidated, } from './project-agent-consolidation.js';
|
|
32
|
+
export { DIRECTIVE_QUARANTINE_MAX_UTILITY, DIRECTIVE_QUARANTINE_MIN_APPLIED, type DirectiveOutcomeResult, directiveWasApplied, recordDirectiveOutcomes, } from './project-agent-directive-outcome.js';
|
|
28
33
|
export type { CreateProjectAgentInput, LearnedCaptureResult, ProjectAgentConfig, ProjectAgentProfile, RoleKnowledgeManifest, } from './project-agent-identity-types.js';
|
|
34
|
+
export { splitLearnedEntries, tokenOverlap } from './project-agent-learning-entries.js';
|
|
29
35
|
export { classifyLearnedEntry, LEARNED_ENTRY_MAX_CHARS, LEARNED_HARD_LIMIT, LEARNED_SOFT_LIMIT, type LearnedEntryCategory, normalizeLearnedEntry, } from './project-agent-learning-normalize.js';
|
|
30
|
-
export { loadProjectAgentLearningPolicy, type ProjectAgentLearningPolicy, updateProjectAgentLearningPolicy, } from './project-agent-learning-policy.js';
|
|
31
|
-
export { decomposeLearnedEntry, mergeStructuredEntries, parseLearnedEntryStamp, renderLearnedInstructions, type StructuredLearnedEntry, } from './project-agent-learning-structured.js';
|
|
36
|
+
export { loadProjectAgentLearningPolicy, type ProjectAgentLearningPolicy, recordProjectAgentOptimizePass, updateProjectAgentLearningPolicy, } from './project-agent-learning-policy.js';
|
|
37
|
+
export { DIRECTIVE_PROVEN_MIN_APPLIED, DIRECTIVE_PROVEN_MIN_UTILITY, decomposeLearnedEntry, directiveTrials, directiveUtility, enforceLearnedBudget, isProvenDirective, mergeStructuredEntries, parseLearnedEntryStamp, parseStructuredLearnedEntriesFromContent, renderLearnedInstructions, type StructuredLearnedEntry, } from './project-agent-learning-structured.js';
|
|
38
|
+
export { type LearningOptimizerLlm, type OptimizeLearningOptions, type OptimizeLearningResult, optimizeProjectAgentLearning, unwrapWholeDocumentFence, } from './project-agent-optimizer.js';
|
|
32
39
|
export { assertProjectAgentRole } from './project-agent-paths.js';
|
|
40
|
+
export { type QuarantinedDirective, quarantinePath, readQuarantinedDirectives, retiredDirectivesToWarnAbout, scrubRetiredLines, } from './project-agent-quarantine.js';
|
|
41
|
+
export { buildSkillDistillInstruction, clearProjectSkillAugmentation, DEFAULT_EAGER_SKILL_LIMIT, listProjectSkillAugmentations, loadProjectSkillAugmentation, loadSkillAffinity, rankRoleSkills, recordSkillLoad, recordSkillOutcome, renderSkillAugmentation, resolveRoleSkillCandidates, routeDirectiveToSkill, SKILL_AUGMENTATION_MAX_BYTES, SKILL_EVIDENCE_HALF_LIFE_DAYS, type SkillAffinity, type SkillAffinityEntry, saveProjectSkillAugmentation, scoreSkillAffinity, setSkillPinned, } from './project-agent-skill-layer.js';
|
|
42
|
+
export { CAPTURE_COOLDOWN_MS, CAPTURE_MAX_PER_SESSION };
|
|
33
43
|
export { listProjectAgentRoles, refreshProjectAgentIdentity, resetProjectAgentIdentity, updateProjectAgentConfig, updateProjectAgentIdentity, updateProjectAgentKnowledge, updateProjectAgentLearned, } from './project-agent-files.js';
|
|
34
44
|
export { createProjectAgent, loadProjectAgentProfile, slugifyProjectAgentRole, } from './project-agent-profile.js';
|
|
35
45
|
/**
|
|
@@ -39,11 +49,6 @@ export { createProjectAgent, loadProjectAgentProfile, slugifyProjectAgentRole, }
|
|
|
39
49
|
* roles may opt into a deliberately narrow runtime.
|
|
40
50
|
*/
|
|
41
51
|
export declare function createProjectAgentRoster(baseRoster: Record<string, SubagentConfig>, projectRoot?: string): Record<string, SubagentConfig>;
|
|
42
|
-
/**
|
|
43
|
-
* Load the project-level agent config for a given role.
|
|
44
|
-
* Returns `undefined` when no project override exists.
|
|
45
|
-
*/
|
|
46
|
-
export declare function loadProjectAgentConfig(role: string, projectRoot?: string): ProjectAgentConfig | undefined;
|
|
47
52
|
/**
|
|
48
53
|
* Load the project-level identity appendix for a given role.
|
|
49
54
|
* Appended to the subagent prompt after the base role prompt and policy.
|
|
@@ -84,13 +89,17 @@ export declare function applyProjectAgentConfig(base: SubagentConfig, projectCon
|
|
|
84
89
|
export declare function buildProjectContextualizedPrompt(basePrompt: string, role: string, projectRoot?: string, options?: {
|
|
85
90
|
identityOverride?: string | undefined;
|
|
86
91
|
}): string;
|
|
87
|
-
export declare const CAPTURE_COOLDOWN_MS = 120000;
|
|
88
|
-
export declare const CAPTURE_MAX_PER_SESSION = 3;
|
|
89
92
|
/**
|
|
90
93
|
* Check whether a new capture is allowed for this role. Returns a rejection
|
|
91
94
|
* reason string when blocked, or undefined when capture may proceed.
|
|
95
|
+
*
|
|
96
|
+
* `existingSize` is accepted for call-site compatibility but no longer gates
|
|
97
|
+
* anything: an over-budget buffer is now trimmed at write time
|
|
98
|
+
* (`enforceLearnedBudget`) instead of blocking every future capture. The old
|
|
99
|
+
* size gate had no self-clearing path, so the roles with the most learning
|
|
100
|
+
* were the ones that had silently stopped learning.
|
|
92
101
|
*/
|
|
93
|
-
export declare function canCaptureNewLearned(role: string,
|
|
102
|
+
export declare function canCaptureNewLearned(role: string, _existingSize: number, isManual: boolean, projectRoot?: string): string | undefined;
|
|
94
103
|
/**
|
|
95
104
|
* Per-role learning stats for monitoring UIs.
|
|
96
105
|
*/
|
|
@@ -116,6 +125,24 @@ export interface ProjectAgentLearnStats {
|
|
|
116
125
|
isConsolidated: boolean;
|
|
117
126
|
/** Consolidation metadata, if a consolidation has been performed. */
|
|
118
127
|
consolidation?: ConsolidationMetadata | undefined;
|
|
128
|
+
/** Skills this project has developed a dedicated addendum for. */
|
|
129
|
+
skills: string[];
|
|
130
|
+
/** Directives already routed to a skill and awaiting distillation. */
|
|
131
|
+
skilledEntryCount: number;
|
|
132
|
+
/**
|
|
133
|
+
* How the buffer is actually performing, not just how big it is.
|
|
134
|
+
*
|
|
135
|
+
* `lifetimeCaptureCount` measures volume, which says nothing about whether
|
|
136
|
+
* the role is learning the right things. These three do:
|
|
137
|
+
* `provenEntryCount` is directives with a real track record, `deadEntryCount`
|
|
138
|
+
* is directives that have never been exercised at all (a high share means the
|
|
139
|
+
* agent is writing things nobody uses), and `directiveHitRate` is the share
|
|
140
|
+
* of applications that ended in a successful task.
|
|
141
|
+
*/
|
|
142
|
+
appliedEntryCount: number;
|
|
143
|
+
deadEntryCount: number;
|
|
144
|
+
/** `null` until at least one directive has been exercised. */
|
|
145
|
+
directiveHitRate: number | null;
|
|
119
146
|
}
|
|
120
147
|
export declare function getProjectAgentLearnStats(role: string, projectRoot?: string): ProjectAgentLearnStats;
|
|
121
148
|
/**
|
|
@@ -3,8 +3,14 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export declare function tokenOverlap(a: string, b: string): number;
|
|
5
5
|
/**
|
|
6
|
-
* Split
|
|
7
|
-
*
|
|
6
|
+
* Split a **legacy** learned.md body into individual entries.
|
|
7
|
+
*
|
|
8
|
+
* Entries are delimited by `---` runs, which is only meaningful for the old
|
|
9
|
+
* append-only journal format. The structured document uses `---` exactly once
|
|
10
|
+
* (before its footer), so this function returns 2 chunks for any structured
|
|
11
|
+
* buffer regardless of how many directives it holds. Callers that need a real
|
|
12
|
+
* entry count must use `parseStructuredLearnedEntries` — this one exists only
|
|
13
|
+
* to migrate pre-structured files.
|
|
8
14
|
*/
|
|
9
15
|
export declare function splitLearnedEntries(body: string): string[];
|
|
10
16
|
//# sourceMappingURL=project-agent-learning-entries.d.ts.map
|
|
@@ -5,7 +5,28 @@ export interface ProjectAgentLearningPolicy {
|
|
|
5
5
|
lifetimeCaptureCount: number;
|
|
6
6
|
lastCaptureAt?: string | undefined;
|
|
7
7
|
lastCaptureSource?: 'automatic' | 'manual' | 'taught' | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* When an optimization pass last ran to completion for this role, whatever it
|
|
10
|
+
* managed to do.
|
|
11
|
+
*
|
|
12
|
+
* The auto-optimize cooldown used to read `consolidation.json` alone, which is
|
|
13
|
+
* only written when a model produced a role document. A pass that ran without
|
|
14
|
+
* a model still rewrote every skill addendum and still left no trace, so on a
|
|
15
|
+
* headless box `minIntervalMs` never applied and a full pass re-ran after
|
|
16
|
+
* every capture.
|
|
17
|
+
*/
|
|
18
|
+
lastOptimizeAt?: string | undefined;
|
|
8
19
|
}
|
|
9
20
|
export declare function loadProjectAgentLearningPolicy(role: string, projectRoot?: string): ProjectAgentLearningPolicy;
|
|
10
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Merge a patch into the persisted policy.
|
|
23
|
+
*
|
|
24
|
+
* Always re-reads immediately before writing. Capture and the optimization pass
|
|
25
|
+
* both own fields in this file and run on independent schedules, so writing a
|
|
26
|
+
* whole object built from a value read earlier in the call silently reverts
|
|
27
|
+
* whatever the other one recorded in between.
|
|
28
|
+
*/
|
|
29
|
+
export declare function updateProjectAgentLearningPolicy(role: string, patch: Partial<ProjectAgentLearningPolicy>, projectRoot?: string): ProjectAgentLearningPolicy;
|
|
30
|
+
/** Stamp the completion of an optimization pass so the cooldown can see it. */
|
|
31
|
+
export declare function recordProjectAgentOptimizePass(role: string, projectRoot?: string, at?: string): void;
|
|
11
32
|
//# sourceMappingURL=project-agent-learning-policy.d.ts.map
|
|
@@ -12,11 +12,58 @@ export interface StructuredLearnedEntry {
|
|
|
12
12
|
what: string;
|
|
13
13
|
/** Why this directive exists — derived from category and directive signals. */
|
|
14
14
|
why: string;
|
|
15
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* Concrete, runnable anchors — commands, file paths, package names.
|
|
17
|
+
* One anchor per line, WITHOUT any list marker: the renderer owns the
|
|
18
|
+
* markup. Storing markup here is what produced the `- *How:* - *How:*`
|
|
19
|
+
* nesting that compounded on every capture.
|
|
20
|
+
*/
|
|
16
21
|
how: string;
|
|
17
22
|
/** ISO timestamp of when this entry was originally captured. */
|
|
18
23
|
capturedAt: string;
|
|
24
|
+
/**
|
|
25
|
+
* Skill this directive develops, when capture could route it. Entries with a
|
|
26
|
+
* skill are distilled into `.wrongstack/agents/<role>/skills/<skill>.md` by
|
|
27
|
+
* the optimization pass; unrouted entries stay role-level.
|
|
28
|
+
*/
|
|
29
|
+
skill?: string | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Completed tasks where this directive was injected **and** the agent's
|
|
32
|
+
* report showed it was actually exercised (its anchors or distinctive
|
|
33
|
+
* wording appeared in the output).
|
|
34
|
+
*
|
|
35
|
+
* Optional so an entry can be constructed without a track record; treat a
|
|
36
|
+
* missing value as 0 by reading it through {@link directiveTrials}.
|
|
37
|
+
*/
|
|
38
|
+
applied?: number | undefined;
|
|
39
|
+
/** Of those, the ones that ended in a successful task. */
|
|
40
|
+
wins?: number | undefined;
|
|
19
41
|
}
|
|
42
|
+
/** Normalized track record. A missing counter reads as 0, never as NaN. */
|
|
43
|
+
export declare function directiveTrials(entry: Pick<StructuredLearnedEntry, 'applied' | 'wins'>): {
|
|
44
|
+
applied: number;
|
|
45
|
+
wins: number;
|
|
46
|
+
losses: number;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Laplace-smoothed success rate of a directive: the fraction of tasks that
|
|
50
|
+
* succeeded among those where the directive was actually exercised.
|
|
51
|
+
*
|
|
52
|
+
* An unproven directive scores exactly 0.5 — a neutral prior, not a penalty.
|
|
53
|
+
* That matters everywhere this is used as a ranking key: "no evidence" must
|
|
54
|
+
* never sort below "evidence of harm", which is the inversion the skill-level
|
|
55
|
+
* score used to have.
|
|
56
|
+
*/
|
|
57
|
+
export declare function directiveUtility(entry: Pick<StructuredLearnedEntry, 'applied' | 'wins'>): number;
|
|
58
|
+
/** Trials before a directive's record is trusted enough to protect or retire it. */
|
|
59
|
+
export declare const DIRECTIVE_PROVEN_MIN_APPLIED = 5;
|
|
60
|
+
/** Utility at or above which a directive is treated as proven. */
|
|
61
|
+
export declare const DIRECTIVE_PROVEN_MIN_UTILITY = 0.7;
|
|
62
|
+
/**
|
|
63
|
+
* A directive that has earned the right not to be overwritten by a near
|
|
64
|
+
* duplicate: exercised enough times, and correlated with success when it was.
|
|
65
|
+
*/
|
|
66
|
+
export declare function isProvenDirective(entry: StructuredLearnedEntry): boolean;
|
|
20
67
|
export declare function parseLearnedEntryStamp(entry: string): {
|
|
21
68
|
capturedAt: string;
|
|
22
69
|
category: LearnedEntryCategory | null;
|
|
@@ -31,6 +78,30 @@ export declare function mergeStructuredEntries(existing: StructuredLearnedEntry[
|
|
|
31
78
|
text: string;
|
|
32
79
|
category: LearnedEntryCategory;
|
|
33
80
|
capturedAt: string;
|
|
81
|
+
skill?: string | undefined;
|
|
34
82
|
}): StructuredLearnedEntry[];
|
|
35
83
|
export declare function renderLearnedInstructions(role: string, entries: StructuredLearnedEntry[], capturedAt: string): string;
|
|
84
|
+
/**
|
|
85
|
+
* Keep the rendered buffer within `maxBytes` by evicting the least valuable
|
|
86
|
+
* entries: plain facts before hard-won warnings, then the worst track record,
|
|
87
|
+
* then the oldest.
|
|
88
|
+
*
|
|
89
|
+
* Track record before age is the point of the ordering. Age says when a
|
|
90
|
+
* directive arrived; utility says whether it has ever helped. A directive that
|
|
91
|
+
* has been exercised eight times and correlated with failure every time is the
|
|
92
|
+
* cheapest thing in the buffer no matter how recently it was written, and a
|
|
93
|
+
* directive that keeps working should outlive newer arrivals. Entries with no
|
|
94
|
+
* record sit at the neutral 0.5 prior, so this reduces to the previous
|
|
95
|
+
* age-ordered behaviour for any buffer that predates outcome tracking.
|
|
96
|
+
*
|
|
97
|
+
* This replaces the old "block every automatic capture once the file passes
|
|
98
|
+
* 8 KB" gate. That gate had no way to ever clear itself (consolidation wrote a
|
|
99
|
+
* separate file and never touched the raw buffer), so the roles that had
|
|
100
|
+
* learned the most were exactly the roles that had permanently stopped
|
|
101
|
+
* learning. Bounding the buffer is the same protection without the deadlock.
|
|
102
|
+
*/
|
|
103
|
+
export declare function enforceLearnedBudget(entries: readonly StructuredLearnedEntry[], capturedAt: string, maxBytes: number, role?: string): {
|
|
104
|
+
kept: StructuredLearnedEntry[];
|
|
105
|
+
dropped: StructuredLearnedEntry[];
|
|
106
|
+
};
|
|
36
107
|
//# sourceMappingURL=project-agent-learning-structured.d.ts.map
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Learning optimization pass: raw captures → consolidated role document +
|
|
3
|
+
* per-skill project addenda → pruned capture buffer.
|
|
4
|
+
*
|
|
5
|
+
* One implementation, shared by every surface. The CLI used to build the
|
|
6
|
+
* instruction and hand it to the chat loop with nothing on the other end to
|
|
7
|
+
* persist the result, so `/agent-improve <role> consolidate` produced a wall of
|
|
8
|
+
* markdown and no state change; the WebUI had the only working pipeline.
|
|
9
|
+
*/
|
|
10
|
+
import type { Provider } from '../../types/index.js';
|
|
11
|
+
/** Resolved model handle used for headless synthesis. */
|
|
12
|
+
export interface LearningOptimizerLlm {
|
|
13
|
+
provider: Provider;
|
|
14
|
+
model: string;
|
|
15
|
+
}
|
|
16
|
+
export interface OptimizeLearningOptions {
|
|
17
|
+
llm?: LearningOptimizerLlm | undefined;
|
|
18
|
+
trigger?: 'manual' | 'automatic' | undefined;
|
|
19
|
+
/** Archive + reset the raw buffer after a successful pass. Default true. */
|
|
20
|
+
prune?: boolean | undefined;
|
|
21
|
+
maxTokens?: number | undefined;
|
|
22
|
+
timeoutMs?: number | undefined;
|
|
23
|
+
signal?: AbortSignal | undefined;
|
|
24
|
+
}
|
|
25
|
+
export interface OptimizeLearningResult {
|
|
26
|
+
role: string;
|
|
27
|
+
status: 'optimized' | 'no-entries' | 'no-llm' | 'empty-synthesis' | 'failed';
|
|
28
|
+
rawEntryCount: number;
|
|
29
|
+
/** Skills whose project addendum was refreshed by this pass. */
|
|
30
|
+
skills: string[];
|
|
31
|
+
content?: string | undefined;
|
|
32
|
+
model?: string | undefined;
|
|
33
|
+
pruned?: boolean | undefined;
|
|
34
|
+
/** Present on `no-llm`: the caller may drive the pass through a chat agent. */
|
|
35
|
+
instruction?: string | undefined;
|
|
36
|
+
error?: string | undefined;
|
|
37
|
+
}
|
|
38
|
+
/** Strip a whole-document code fence a model sometimes wraps output in. */
|
|
39
|
+
export declare function unwrapWholeDocumentFence(text: string): string;
|
|
40
|
+
/**
|
|
41
|
+
* Run the full optimization pass for one role.
|
|
42
|
+
*
|
|
43
|
+
* Without an LLM the pass degrades rather than failing: the role-level
|
|
44
|
+
* instruction is returned for a caller-driven consolidation, and each skill
|
|
45
|
+
* still gets a deterministically rendered addendum from its routed directives,
|
|
46
|
+
* so tagged learning reaches the skill layer even on a headless box.
|
|
47
|
+
*/
|
|
48
|
+
export declare function optimizeProjectAgentLearning(role: string, projectRoot?: string, options?: OptimizeLearningOptions): Promise<OptimizeLearningResult>;
|
|
49
|
+
//# sourceMappingURL=project-agent-optimizer.d.ts.map
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The retired-directive log, and the surgery that keeps a retired directive
|
|
3
|
+
* from surviving inside a document that was distilled while it was still
|
|
4
|
+
* believed.
|
|
5
|
+
*
|
|
6
|
+
* Retirement removes a directive from the capture buffer, but by then it may
|
|
7
|
+
* already have been folded into `skills/<skill>.md` and `consolidated.md` —
|
|
8
|
+
* both of which are injected into every spawn and neither of which is rebuilt
|
|
9
|
+
* until the next optimization pass, up to six hours later. Without the scrub
|
|
10
|
+
* below, "stops being injected" was only true of the buffer, which is the one
|
|
11
|
+
* copy the agent was least likely to be reading.
|
|
12
|
+
*
|
|
13
|
+
* Its own module so both the writer (`project-agent-directive-outcome`) and the
|
|
14
|
+
* reader (`project-agent-consolidation`, building the distillation prompt) can
|
|
15
|
+
* depend on it without depending on each other.
|
|
16
|
+
*/
|
|
17
|
+
import { type StructuredLearnedEntry } from './project-agent-learning-structured.js';
|
|
18
|
+
/** Ceiling on the retired-directive log. Local audit only; never injected. */
|
|
19
|
+
export declare const QUARANTINE_MAX_BYTES: number;
|
|
20
|
+
export interface QuarantinedDirective {
|
|
21
|
+
what: string;
|
|
22
|
+
skill?: string | undefined;
|
|
23
|
+
}
|
|
24
|
+
export declare function quarantinePath(role: string, projectRoot?: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Append retired directives to the role's log.
|
|
27
|
+
*
|
|
28
|
+
* They are kept rather than deleted: a directive can be right about a project
|
|
29
|
+
* that has since changed, and the log is the only place to see what the loop
|
|
30
|
+
* decided to stop believing.
|
|
31
|
+
*/
|
|
32
|
+
export declare function appendQuarantine(role: string, retired: readonly StructuredLearnedEntry[], at: string, projectRoot?: string): void;
|
|
33
|
+
/** Every directive this role has retired, newest last. */
|
|
34
|
+
export declare function readQuarantinedDirectives(role: string, projectRoot?: string): QuarantinedDirective[];
|
|
35
|
+
/**
|
|
36
|
+
* Remove any line that states one of the retired directives, together with the
|
|
37
|
+
* indented lines that hang off it.
|
|
38
|
+
*
|
|
39
|
+
* Line-oriented rather than model-driven on purpose: this runs on the task
|
|
40
|
+
* completion path, where a provider call is not affordable and a failure to
|
|
41
|
+
* scrub means the agent keeps being told to do the thing that kept failing.
|
|
42
|
+
*/
|
|
43
|
+
export declare function scrubRetiredLines(text: string, retired: readonly string[]): string;
|
|
44
|
+
/**
|
|
45
|
+
* Whether a scrubbed document still says anything actionable.
|
|
46
|
+
*
|
|
47
|
+
* Chrome does not count. A skill addendum keeps its title and its standing
|
|
48
|
+
* "read these as refinements of the bundled skill" blockquote no matter how
|
|
49
|
+
* many rules are removed, so testing for "any long line" would report an
|
|
50
|
+
* addendum with nothing left in it as still having content.
|
|
51
|
+
*/
|
|
52
|
+
export declare function hasDirectiveContent(text: string): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Retired directives worth warning the distiller about: the ones it could only
|
|
55
|
+
* resurrect from an existing document.
|
|
56
|
+
*
|
|
57
|
+
* A directive the agent has since written again is deliberately excluded. The
|
|
58
|
+
* whole reason retirement archives rather than deletes is that a rule can be
|
|
59
|
+
* right about a project that has since changed; if the role re-learned it, it
|
|
60
|
+
* is back in the buffer with a fresh record and has earned its second chance.
|
|
61
|
+
*/
|
|
62
|
+
export declare function retiredDirectivesToWarnAbout(role: string, currentDirectives: readonly string[], projectRoot?: string, skill?: string): string[];
|
|
63
|
+
//# sourceMappingURL=project-agent-quarantine.d.ts.map
|