@wrongstack/core 0.302.0 → 0.303.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/agent-status-tracker.d.ts +6 -2
- package/dist/chronicle/index.js +1949 -1671
- package/dist/chronicle/metrics-store.d.ts +14 -0
- package/dist/chronicle/project-server-protocol.d.ts +13 -0
- package/dist/chronicle/project-server.js +1756 -1573
- package/dist/chronicle/rollup-adapter.d.ts +2 -0
- package/dist/chronicle/sqlite-journal.d.ts +59 -0
- package/dist/coordination/agents/index.js +4313 -3516
- 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 +29 -2
- 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 +22 -9
- package/dist/coordination/agents/project-agent-learning-entries.d.ts +8 -2
- package/dist/coordination/agents/project-agent-learning-structured.d.ts +27 -1
- package/dist/coordination/agents/project-agent-optimizer.d.ts +49 -0
- package/dist/coordination/agents/project-agent-skill-layer.d.ts +101 -0
- package/dist/coordination/agents/role-skills.d.ts +11 -1
- package/dist/coordination/index.d.ts +1 -1
- package/dist/coordination/index.js +4927 -3589
- package/dist/coordination/mail-tools.d.ts +3 -3
- package/dist/core/context.d.ts +4 -0
- package/dist/core/continue-intent.d.ts +2 -0
- package/dist/core/conversation-state.d.ts +5 -0
- package/dist/core/index.js +129 -19
- package/dist/defaults/index.js +1620 -768
- package/dist/execution/index.js +2941 -2630
- package/dist/goal/index.js +7 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +12269 -9212
- package/dist/infrastructure/index.js +722 -672
- package/dist/kernel/events/agent-events.d.ts +28 -0
- package/dist/kernel/events/memory-events.d.ts +62 -0
- package/dist/plugin/index.js +2167 -1986
- package/dist/security/index.js +69 -3
- package/dist/security/kanban-boundary.d.ts +5 -1
- package/dist/session-catalog/client.d.ts +62 -0
- package/dist/session-catalog/endpoint.d.ts +6 -0
- package/dist/session-catalog/index.d.ts +6 -0
- package/dist/session-catalog/index.js +2000 -0
- package/dist/session-catalog/project-server.d.ts +3 -0
- package/dist/session-catalog/project-server.js +1861 -0
- package/dist/session-catalog/protocol.d.ts +284 -0
- package/dist/session-catalog/registry.d.ts +59 -0
- package/dist/session-catalog/store.d.ts +71 -0
- package/dist/storage/index.d.ts +42 -38
- package/dist/storage/index.js +13896 -12931
- package/dist/storage/plan-store.d.ts +1 -1
- package/dist/storage/session-event-bridge.d.ts +2 -2
- package/dist/storage/session-store.d.ts +6 -0
- package/dist/tasking/index.js +5 -0
- package/dist/tools/index.js +2832 -2606
- package/dist/types/config/root.d.ts +11 -1
- package/dist/types/config/skills-fleet-brain.d.ts +34 -0
- package/dist/types/config/ui.d.ts +14 -0
- package/dist/types/config.d.ts +1 -0
- package/dist/types/context-evidence.d.ts +2 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.js +20 -0
- package/dist/types/messages.d.ts +8 -0
- package/dist/types/multi-agent.d.ts +7 -0
- package/dist/types/session.d.ts +19 -0
- package/dist/types/task-graph.d.ts +2 -0
- package/dist/types/tool-executor.d.ts +2 -0
- package/dist/utils/context-evidence.d.ts +13 -1
- package/dist/utils/index.js +29 -2
- package/instructions/system-lite.md +23 -8
- package/instructions/system-pro.md +29 -9
- package/instructions/system.md +29 -9
- package/package.json +7 -3
- package/skills/wrongstack-kanban/SKILL.md +39 -8
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { ConfiguredHook, HookEvent } from '../hooks.js';
|
|
2
|
-
import type { AutonomyConfig, ChronicleConfig, IndexingConfig, LaunchConfig, SessionLoggingConfig, SyncConfig } from './autonomy.js';
|
|
3
2
|
import type { AdaptiveConcurrencyConfig, CircuitBreakerRuntimeConfig, ContextConfig } from './context.js';
|
|
3
|
+
import type { AutonomyConfig, ChronicleConfig, IndexingConfig, LaunchConfig, SessionLoggingConfig, SyncConfig } from './autonomy.js';
|
|
4
4
|
import type { FeaturesConfig, LogConfig, MCPServerConfig, PluginConfig, PluginManagerConfig, SageConfig } from './mcp-features.js';
|
|
5
5
|
import type { CustomModelDefinition, ModelMatrixEntry, ProviderConfig } from './providers.js';
|
|
6
6
|
import type { CloudSyncConfig, HqClientConfig, ModelRuntimeConfig, SystemPromptConfig } from './runtime.js';
|
|
7
7
|
import type { BrainConfig, FleetConfig, SkillsConfig } from './skills-fleet-brain.js';
|
|
8
|
+
import type { ThemePresetId } from './ui.js';
|
|
8
9
|
import type { ToolsConfig } from './tools.js';
|
|
9
10
|
export interface GitBehaviorConfig {
|
|
10
11
|
/**
|
|
@@ -40,6 +41,15 @@ export interface Config {
|
|
|
40
41
|
* unset, surfaces fall back to their own browser/system detection.
|
|
41
42
|
*/
|
|
42
43
|
uiLocale?: string | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* TUI color theme preset — read by the TUI on boot to apply the matching
|
|
46
|
+
* palette, and written by the `/theme` slash command (CLI REPL and TUI) so
|
|
47
|
+
* the choice persists across restarts. Unconstrained string at the config
|
|
48
|
+
* layer: the TUI owns the canonical preset list and applies a fallback
|
|
49
|
+
* (`catppuccin`) when the stored value is unknown, so a forward-compat
|
|
50
|
+
* drift on the TUI side never breaks the config round-trip.
|
|
51
|
+
*/
|
|
52
|
+
themePreset?: ThemePresetId | undefined;
|
|
43
53
|
providers?: Record<string, ProviderConfig>;
|
|
44
54
|
/**
|
|
45
55
|
* Top-level custom models (maps modelId → definition). Merged with
|
|
@@ -128,6 +128,40 @@ export interface FleetConfig {
|
|
|
128
128
|
} | undefined;
|
|
129
129
|
/** Brain-gated fleet supervisor (rebalance/steer/spawn-helper). */
|
|
130
130
|
supervisor?: FleetSupervisorConfig | undefined;
|
|
131
|
+
/** Roster-agent self-learning: capture → optimize → per-skill addenda. */
|
|
132
|
+
learning?: AgentLearningConfig | undefined;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Automatic optimization of roster-agent learning.
|
|
136
|
+
*
|
|
137
|
+
* Capture is always automatic. This section governs the *distillation* pass
|
|
138
|
+
* that turns captured directives into per-skill project addenda and a
|
|
139
|
+
* consolidated role document, then archives and resets the raw buffer.
|
|
140
|
+
*/
|
|
141
|
+
export interface AgentLearningConfig {
|
|
142
|
+
autoOptimize?: {
|
|
143
|
+
/** Run the distillation pass automatically. Default true. */
|
|
144
|
+
enabled?: boolean | undefined;
|
|
145
|
+
/** Raw buffer size (bytes) that makes a role eligible. Default 8192. */
|
|
146
|
+
thresholdBytes?: number | undefined;
|
|
147
|
+
/** Never optimize a buffer with fewer directives than this. Default 4. */
|
|
148
|
+
minEntries?: number | undefined;
|
|
149
|
+
/**
|
|
150
|
+
* Directives routed to a skill that has no addendum yet. Reaching this
|
|
151
|
+
* count makes a role eligible even below `thresholdBytes`. Default 3.
|
|
152
|
+
*/
|
|
153
|
+
minPendingSkillDirectives?: number | undefined;
|
|
154
|
+
/** Minimum gap between automatic passes for one role. Default 6h. */
|
|
155
|
+
minIntervalMs?: number | undefined;
|
|
156
|
+
/** Quiet period after the last capture before a pass starts. Default 20s. */
|
|
157
|
+
debounceMs?: number | undefined;
|
|
158
|
+
/**
|
|
159
|
+
* Evaluate every role once when the fleet host starts, so roles that
|
|
160
|
+
* became eligible before this session are not stuck waiting for their
|
|
161
|
+
* next capture. Default true.
|
|
162
|
+
*/
|
|
163
|
+
sweepOnStart?: boolean | undefined;
|
|
164
|
+
} | undefined;
|
|
131
165
|
}
|
|
132
166
|
/** Config surface for the brain-gated FleetSupervisor. */
|
|
133
167
|
export interface FleetSupervisorConfig {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared UI theme preset identifiers.
|
|
3
|
+
*
|
|
4
|
+
* Lives in core so the Config schema, the CLI `/theme` slash command, and
|
|
5
|
+
* the TUI runtime can all reference the same string union without
|
|
6
|
+
* importing the TUI package (which would invert the dependency direction).
|
|
7
|
+
*
|
|
8
|
+
* Keep in lockstep with `THEME_OPTIONS` in `packages/tui/src/theme.ts`.
|
|
9
|
+
* Adding a preset here is intentional — it also requires updating the TUI
|
|
10
|
+
* presets map AND the CLI `VALID_PRESETS` set in `tui-theme-adapter.ts`.
|
|
11
|
+
*/
|
|
12
|
+
export declare const THEME_PRESET_IDS: readonly ['catppuccin', 'tokyo-night', 'nord', 'cyberpunk', 'dracula', 'gruvbox-dark', 'solarized-dark', 'one-dark', 'monokai', 'rose-pine', 'kanagawa', 'ayu-dark', 'everforest', 'night-owl', 'synthwave'];
|
|
13
|
+
export type ThemePresetId = (typeof THEME_PRESET_IDS)[number];
|
|
14
|
+
//# sourceMappingURL=ui.d.ts.map
|
package/dist/types/config.d.ts
CHANGED
|
@@ -6,5 +6,6 @@ export * from './config/providers.js';
|
|
|
6
6
|
export * from './config/mcp-features.js';
|
|
7
7
|
export * from './config/autonomy.js';
|
|
8
8
|
export * from './config/skills-fleet-brain.js';
|
|
9
|
+
export * from './config/ui.js';
|
|
9
10
|
export * from './config/root.js';
|
|
10
11
|
//# sourceMappingURL=config.d.ts.map
|
|
@@ -54,6 +54,8 @@ export interface CompletedWorkEvidence {
|
|
|
54
54
|
}
|
|
55
55
|
export interface ContextEvidenceState {
|
|
56
56
|
currentIntent?: ContextIntentEvidence | undefined;
|
|
57
|
+
/** Recent real human inputs, bounded and rendered as volatile continuity evidence. */
|
|
58
|
+
recentUserTurns?: ContextIntentEvidence[] | undefined;
|
|
57
59
|
sessionGoals: string[];
|
|
58
60
|
implicitFacts: string[];
|
|
59
61
|
activeErrors: string[];
|
package/dist/types/index.d.ts
CHANGED
|
@@ -13,8 +13,8 @@ export { ProviderError, classifyProviderError, effectiveInputTokens, isContextOv
|
|
|
13
13
|
export type { CacheTtl, Capabilities, JsonSchemaSpec, Provider, ProviderContextLimit, ProviderErrorBody, ProviderErrorKind, ReasoningConfig, ReasoningEffort, ReasoningRequest, Request, RequestCacheControl, Response, ResponseFormat, SafetySetting, StopReason, StreamEvent, Usage } from './provider.js';
|
|
14
14
|
export { StreamHangError } from './provider.js';
|
|
15
15
|
export type { ProviderRunner, RunProviderOptions } from './provider-runner.js';
|
|
16
|
-
export { DEFAULT_TUI_THINKING_WORD, FLEET_CHAT_VERBOSITY_VALUES, MAX_TUI_THINKING_WORD_LENGTH, normalizeTokenSavingTier, normalizeTuiThinkingWord, resolveFleetChatVerbosity, resolveTokenSavingTier } from './config.js';
|
|
17
|
-
export type { AdaptiveConcurrencyConfig, AutonomyConfig, BrainConfig, BrainCouncilConfig, BrainCouncilVoterConfig, BrainModelEntry, CircuitBreakerRuntimeConfig, ConcreteTokenSavingTier, Config, ConfigLoader, ConfigStore, ContextConfig, CouncilPersonaDefinition, CouncilToolConfig, CouncilToolProfileDefinition, CustomModelDefinition, ExecDangerConfig, ExecToolConfig, FeaturesConfig, FleetChatVerbosity, FleetConfig, FleetSupervisorConfig, GitBehaviorConfig, HqClientConfig, IndexingConfig, InputHistoryConfig, LaunchConfig, LaunchMenuChoice, LogConfig, LoopDetectionConfig, MCPHealthConfig, MCPHealthThresholds, MCPServerConfig, ModelMatrixEntry, ModelRuntimeCacheConfig, ModelRuntimeConfig, ModelRuntimeParametersConfig, ModelRuntimeReasoningConfig, NextStepsToolConfig, PluginConfig, PluginManagerConfig, ProviderApiKey, ProviderConfig, SageConfig, SessionLoggingConfig, SkillsConfig, SyncCategory, SyncConfig, TokenSavingTier, ToolDescriptionMode, ToolDescriptionModeConfig, ToolResultRenderMode, ToolResultRenderModeConfig, ToolsConfig } from './config.js';
|
|
16
|
+
export { DEFAULT_TUI_THINKING_WORD, FLEET_CHAT_VERBOSITY_VALUES, MAX_TUI_THINKING_WORD_LENGTH, normalizeTokenSavingTier, normalizeTuiThinkingWord, resolveFleetChatVerbosity, resolveTokenSavingTier, THEME_PRESET_IDS } from './config.js';
|
|
17
|
+
export type { AdaptiveConcurrencyConfig, AgentLearningConfig, AutonomyConfig, BrainConfig, BrainCouncilConfig, BrainCouncilVoterConfig, BrainModelEntry, CircuitBreakerRuntimeConfig, ConcreteTokenSavingTier, Config, ConfigLoader, ConfigStore, ContextConfig, CouncilPersonaDefinition, CouncilToolConfig, CouncilToolProfileDefinition, CustomModelDefinition, ExecDangerConfig, ExecToolConfig, FeaturesConfig, FleetChatVerbosity, FleetConfig, FleetSupervisorConfig, GitBehaviorConfig, HqClientConfig, IndexingConfig, InputHistoryConfig, LaunchConfig, LaunchMenuChoice, LogConfig, LoopDetectionConfig, MCPHealthConfig, MCPHealthThresholds, MCPServerConfig, ModelMatrixEntry, ModelRuntimeCacheConfig, ModelRuntimeConfig, ModelRuntimeParametersConfig, ModelRuntimeReasoningConfig, NextStepsToolConfig, PluginConfig, PluginManagerConfig, ProviderApiKey, ProviderConfig, SageConfig, SessionLoggingConfig, SkillsConfig, SyncCategory, SyncConfig, ThemePresetId, TokenSavingTier, ToolDescriptionMode, ToolDescriptionModeConfig, ToolResultRenderMode, ToolResultRenderModeConfig, ToolsConfig } from './config.js';
|
|
18
18
|
export type { AnyHookOutcome, ConfiguredHook, HookEntry, HookEvent, HookFailurePolicy, HookInput, HookInvocationContext, HookMatcher, HookOutcome, HookRegistrationOptions, HttpHook, InProcessHook, PreToolUseOutcome, PreToolUseStage, ShellHook } from './hooks.js';
|
|
19
19
|
export type { Compactor, CompactReport } from './compactor.js';
|
|
20
20
|
export type { DirectoryPolicy, DirectoryRule, PermissionDecision, PermissionPolicy, PermissionTrace, PermissionTraceStep, TrustPolicy } from './permission.js';
|
package/dist/types/index.js
CHANGED
|
@@ -575,6 +575,25 @@ function normalizeTuiThinkingWord(value) {
|
|
|
575
575
|
return word;
|
|
576
576
|
}
|
|
577
577
|
|
|
578
|
+
// src/types/config/ui.ts
|
|
579
|
+
var THEME_PRESET_IDS = [
|
|
580
|
+
"catppuccin",
|
|
581
|
+
"tokyo-night",
|
|
582
|
+
"nord",
|
|
583
|
+
"cyberpunk",
|
|
584
|
+
"dracula",
|
|
585
|
+
"gruvbox-dark",
|
|
586
|
+
"solarized-dark",
|
|
587
|
+
"one-dark",
|
|
588
|
+
"monokai",
|
|
589
|
+
"rose-pine",
|
|
590
|
+
"kanagawa",
|
|
591
|
+
"ayu-dark",
|
|
592
|
+
"everforest",
|
|
593
|
+
"night-owl",
|
|
594
|
+
"synthwave"
|
|
595
|
+
];
|
|
596
|
+
|
|
578
597
|
// src/types/session-markers.ts
|
|
579
598
|
var SESSION_MARKER_EVENT_TYPES = /* @__PURE__ */ new Set([
|
|
580
599
|
"mode_changed",
|
|
@@ -1282,6 +1301,7 @@ export {
|
|
|
1282
1301
|
SddError,
|
|
1283
1302
|
SessionError,
|
|
1284
1303
|
StreamHangError,
|
|
1304
|
+
THEME_PRESET_IDS,
|
|
1285
1305
|
ToolError,
|
|
1286
1306
|
ToolErrorCategory,
|
|
1287
1307
|
ToolValidationError,
|
package/dist/types/messages.d.ts
CHANGED
|
@@ -3,6 +3,14 @@ export type MessageRole = 'user' | 'assistant' | 'system';
|
|
|
3
3
|
export interface Message {
|
|
4
4
|
role: MessageRole;
|
|
5
5
|
content: string | ContentBlock[];
|
|
6
|
+
/**
|
|
7
|
+
* Local provenance used by context management. `user_input` is reserved for
|
|
8
|
+
* text the human actually submitted; provider adapters intentionally ignore
|
|
9
|
+
* this field. Keeping it on the journaled message lets resumed sessions
|
|
10
|
+
* distinguish real conversation turns from tool-result/runtime `user`
|
|
11
|
+
* messages without relying on brittle text heuristics.
|
|
12
|
+
*/
|
|
13
|
+
origin?: 'user_input' | 'runtime' | undefined;
|
|
6
14
|
/**
|
|
7
15
|
* ISO-8601 timestamp from the originating SessionEvent.
|
|
8
16
|
* Populated by SessionStore.replay() during session load/resume
|
|
@@ -168,6 +168,13 @@ export interface SubagentConfig {
|
|
|
168
168
|
* bodies through `SkillLoader`; missing optional skills are skipped safely.
|
|
169
169
|
*/
|
|
170
170
|
skillNames?: string[] | undefined;
|
|
171
|
+
/**
|
|
172
|
+
* Every skill this role may draw on, before per-project ranking. The catalog
|
|
173
|
+
* sets this to the full curated set while `skillNames` holds the default
|
|
174
|
+
* eager slice; the spawn path ranks the pool by project skill-affinity so a
|
|
175
|
+
* skill the project actually developed can displace an unused sibling.
|
|
176
|
+
*/
|
|
177
|
+
skillPool?: string[] | undefined;
|
|
171
178
|
/** Optional smart-dispatch metadata for dynamically created project roles. */
|
|
172
179
|
dispatch?: {
|
|
173
180
|
summary: string;
|
package/dist/types/session.d.ts
CHANGED
|
@@ -137,6 +137,23 @@ export type SessionEvent = {
|
|
|
137
137
|
* payload had on disk. Absent on freshly emitted events.
|
|
138
138
|
*/
|
|
139
139
|
messagesOmitted?: number;
|
|
140
|
+
} | {
|
|
141
|
+
/**
|
|
142
|
+
* The oldest `count` messages were evicted from the front of the history.
|
|
143
|
+
*
|
|
144
|
+
* A delta rather than a `messages_replaced` snapshot, because eviction is
|
|
145
|
+
* the one rewrite that repeats: once a long session reaches
|
|
146
|
+
* `Context.MAX_MESSAGES`, *every* subsequent append overflows by one and
|
|
147
|
+
* drops one. Emitting the surviving history each time made the journal
|
|
148
|
+
* quadratic in session length — measured at 2.1 GB for one session whose
|
|
149
|
+
* actual content was ~10 MB, and 17.9 GB across a 20 GB corpus. Replay
|
|
150
|
+
* splices the same prefix off, so the reconstructed conversation is
|
|
151
|
+
* identical to what the snapshot would have produced.
|
|
152
|
+
*/
|
|
153
|
+
type: 'messages_dropped';
|
|
154
|
+
ts: string;
|
|
155
|
+
version: 1;
|
|
156
|
+
count: number;
|
|
140
157
|
} | {
|
|
141
158
|
/**
|
|
142
159
|
* Exact post-rewrite conversation state. Replay replaces all messages
|
|
@@ -590,6 +607,8 @@ export interface SessionStore {
|
|
|
590
607
|
* number of sessions indexed.
|
|
591
608
|
*/
|
|
592
609
|
rebuildIndex?(): Promise<number>;
|
|
610
|
+
/** Release project-daemon connections owned by this store. */
|
|
611
|
+
dispose?(): Promise<void>;
|
|
593
612
|
/**
|
|
594
613
|
* Streaming event-level search. Walks the JSONL once without buffering
|
|
595
614
|
* the whole file, calling `predicate(event, eventIndex, ts)` for each
|
|
@@ -31,6 +31,8 @@ export interface TaskEdge {
|
|
|
31
31
|
export interface TaskGraph {
|
|
32
32
|
id: string;
|
|
33
33
|
specId: string;
|
|
34
|
+
/** Canonical spec scope. When present, execution must retain at least one task per id. */
|
|
35
|
+
requiredRequirementIds?: string[] | undefined;
|
|
34
36
|
title: string;
|
|
35
37
|
nodes: Map<string, TaskNode>;
|
|
36
38
|
edges: TaskEdge[];
|
|
@@ -78,6 +78,8 @@ export interface ToolExecutorOptions {
|
|
|
78
78
|
* to the result the model sees).
|
|
79
79
|
*/
|
|
80
80
|
hookRunner?: import('../hooks/runner.js').HookRunner | undefined;
|
|
81
|
+
/** Hard-block product mutations outside a ready, running strict Kanban contract. */
|
|
82
|
+
requireKanbanGovernance?: boolean | undefined;
|
|
81
83
|
/**
|
|
82
84
|
* Per-tool on-screen result render mode map (`tools.resultRenderMode[name]`).
|
|
83
85
|
* When set, the executor reads this map to decide whether the next
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Context } from '../core/context.js';
|
|
2
|
-
import type
|
|
2
|
+
import { type TextBlock } from '../types/blocks.js';
|
|
3
3
|
import type { CompactReport } from '../types/compactor.js';
|
|
4
4
|
import type { CompletedWorkEvidence, CompletedWorkSource, ContextEvidenceState, ToolOutputMetadata } from '../types/context-evidence.js';
|
|
5
5
|
export declare function createContextEvidenceState(): ContextEvidenceState;
|
|
@@ -14,6 +14,18 @@ export interface RecordToolOutputEvidenceInput {
|
|
|
14
14
|
outputLines?: number | undefined;
|
|
15
15
|
}
|
|
16
16
|
export declare function recordUserIntentEvidence(ctx: Context, text: string): void;
|
|
17
|
+
/** Runtime steering/status blocks must not displace real conversation turns. */
|
|
18
|
+
export declare function isRuntimeContextInput(text: string): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Keep the real conversation thread visible near the stable system prompt.
|
|
21
|
+
*
|
|
22
|
+
* Tool-heavy runs can place hundreds of protocol messages after one human
|
|
23
|
+
* instruction. Re-sending a small, replaceable tail of actual user inputs is
|
|
24
|
+
* cheaper and more reliable than retaining every intervening tool exchange.
|
|
25
|
+
* It is volatile provider evidence, so it never grows the durable chat log or
|
|
26
|
+
* invalidates the cached base prompt.
|
|
27
|
+
*/
|
|
28
|
+
export declare function buildConversationContinuityBlock(ctx: Pick<Context, 'contextEvidence' | 'messages'>): TextBlock | undefined;
|
|
17
29
|
export declare function recordToolOutputEvidence(ctx: Context, input: RecordToolOutputEvidenceInput): ToolOutputMetadata;
|
|
18
30
|
export declare function markAssistantReferencedEvidence(ctx: Context, text: string): void;
|
|
19
31
|
export declare function buildContextEvidenceDigest(ctx: Context): string;
|
package/dist/utils/index.js
CHANGED
|
@@ -855,6 +855,9 @@ var MAX_TOOL_CALLS = 80;
|
|
|
855
855
|
var MAX_FACTS = 40;
|
|
856
856
|
var MAX_ERRORS = 20;
|
|
857
857
|
var MAX_DIGEST_CHARS = 4e3;
|
|
858
|
+
var MAX_RECENT_USER_TURNS = 8;
|
|
859
|
+
var MAX_USER_TURN_CHARS = 700;
|
|
860
|
+
var RUNTIME_CONTEXT_INPUT_PATTERN = /^\[(?:kanban todo update|fleet pulse|loop-detector|todo-reconciliation|mailbox|btw|system|context_state)\b/i;
|
|
858
861
|
var RECENT_TOOL_CALL_SCAN_LIMIT = 20;
|
|
859
862
|
var EXTRACT_CONTENT_CAP_CHARS = 1e4;
|
|
860
863
|
var EXTRACT_ERROR_TAIL_LINES = 200;
|
|
@@ -862,6 +865,7 @@ var WRITE_TOOLS = /* @__PURE__ */ new Set(["edit", "write", "replace", "patch"])
|
|
|
862
865
|
var READ_TOOLS = /* @__PURE__ */ new Set(["read", "grep", "glob", "ls", "tree"]);
|
|
863
866
|
function createContextEvidenceState() {
|
|
864
867
|
return {
|
|
868
|
+
recentUserTurns: [],
|
|
865
869
|
sessionGoals: [],
|
|
866
870
|
implicitFacts: [],
|
|
867
871
|
activeErrors: [],
|
|
@@ -873,15 +877,25 @@ function createContextEvidenceState() {
|
|
|
873
877
|
};
|
|
874
878
|
}
|
|
875
879
|
function recordUserIntentEvidence(ctx, text) {
|
|
876
|
-
|
|
880
|
+
if (isRuntimeContextInput(text)) return;
|
|
881
|
+
const intent = normalizeWhitespace(text).slice(0, MAX_USER_TURN_CHARS);
|
|
877
882
|
if (!intent) return;
|
|
878
883
|
const state = ensureEvidence(ctx);
|
|
879
|
-
|
|
884
|
+
const turn = { text: intent, updatedAt: Date.now() };
|
|
885
|
+
state.currentIntent = turn;
|
|
886
|
+
state.recentUserTurns ??= [];
|
|
887
|
+
state.recentUserTurns.push(turn);
|
|
888
|
+
if (state.recentUserTurns.length > MAX_RECENT_USER_TURNS) {
|
|
889
|
+
state.recentUserTurns.splice(0, state.recentUserTurns.length - MAX_RECENT_USER_TURNS);
|
|
890
|
+
}
|
|
880
891
|
if (state.sessionGoals.length === 0 || isGoalish(intent)) {
|
|
881
892
|
pushUniqueBounded(state.sessionGoals, intent, 8);
|
|
882
893
|
}
|
|
883
894
|
state.updatedAt = Date.now();
|
|
884
895
|
}
|
|
896
|
+
function isRuntimeContextInput(text) {
|
|
897
|
+
return RUNTIME_CONTEXT_INPUT_PATTERN.test(text.trim());
|
|
898
|
+
}
|
|
885
899
|
function recordToolOutputEvidence(ctx, input) {
|
|
886
900
|
const state = ensureEvidence(ctx);
|
|
887
901
|
const scanContent = input.content.length > EXTRACT_CONTENT_CAP_CHARS ? input.content.slice(0, EXTRACT_CONTENT_CAP_CHARS) : input.content;
|
|
@@ -949,6 +963,11 @@ function buildContextEvidenceDigest(ctx) {
|
|
|
949
963
|
if (state.currentIntent?.text) {
|
|
950
964
|
lines.push(`intent: ${state.currentIntent.text}`);
|
|
951
965
|
}
|
|
966
|
+
const priorTurns = (state.recentUserTurns ?? []).slice(-6, -1);
|
|
967
|
+
if (priorTurns.length > 0) {
|
|
968
|
+
lines.push("recent_human_instructions:");
|
|
969
|
+
for (const turn of priorTurns) lines.push(`- ${turn.text}`);
|
|
970
|
+
}
|
|
952
971
|
const goals = state.sessionGoals.slice(-3);
|
|
953
972
|
if (goals.length > 0) {
|
|
954
973
|
lines.push("session_goals:");
|
|
@@ -1003,6 +1022,7 @@ function ensureEvidence(ctx) {
|
|
|
1003
1022
|
ctx.contextEvidence = createContextEvidenceState();
|
|
1004
1023
|
}
|
|
1005
1024
|
ctx.contextEvidence.completedWork ??= [];
|
|
1025
|
+
ctx.contextEvidence.recentUserTurns ??= [];
|
|
1006
1026
|
return ctx.contextEvidence;
|
|
1007
1027
|
}
|
|
1008
1028
|
var MAX_COMPLETED_WORK = 50;
|
|
@@ -1709,12 +1729,16 @@ function buildLiveNextStepsGateBlock(ctx) {
|
|
|
1709
1729
|
});
|
|
1710
1730
|
const omitted = openTodos.length - todoSnapshot.length;
|
|
1711
1731
|
if (omitted > 0) todoSnapshot.push(`- \u2026and ${omitted} more open todo(s)`);
|
|
1732
|
+
const todoReconciliation = ctx.tools?.some((tool) => tool.name === "todo") ? [
|
|
1733
|
+
"Before ending the turn, you MUST call the `todo` tool with the complete current list to reconcile actual progress: finished items completed, exactly one actively worked item in_progress, and untouched items pending. A prose claim that work is done does not update the Todo/Kanban state."
|
|
1734
|
+
] : [];
|
|
1712
1735
|
return {
|
|
1713
1736
|
type: "text",
|
|
1714
1737
|
text: [
|
|
1715
1738
|
"[nextsteps_gate]",
|
|
1716
1739
|
`Authoritative live state for this request: open todos = ${openTodos.length}.`,
|
|
1717
1740
|
"You MUST omit <nextsteps> entirely while these todos remain open. Continue or finish the tracked work; do not propose unrelated follow-on work.",
|
|
1741
|
+
...todoReconciliation,
|
|
1718
1742
|
"Open todo snapshot:",
|
|
1719
1743
|
...todoSnapshot,
|
|
1720
1744
|
"[/nextsteps_gate]"
|
|
@@ -5420,6 +5444,9 @@ function subjectForToolInput(toolName, input, subjectKey) {
|
|
|
5420
5444
|
const obj = input;
|
|
5421
5445
|
if (subjectKey) {
|
|
5422
5446
|
const value = obj[subjectKey];
|
|
5447
|
+
if (Array.isArray(value)) {
|
|
5448
|
+
return escapeGlobSubject(JSON.stringify(value));
|
|
5449
|
+
}
|
|
5423
5450
|
if (typeof value === "string") {
|
|
5424
5451
|
if (isPathSubjectKey(subjectKey)) {
|
|
5425
5452
|
const normalized = normalizePathSubject(value);
|
|
@@ -28,15 +28,27 @@ The user is an experienced developer; accelerate them and stay focused.
|
|
|
28
28
|
6. Report what changed, what was verified, and what remains unverified.
|
|
29
29
|
|
|
30
30
|
<!--ws:if tool=todo-->
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
## Todo status lifecycle
|
|
32
|
+
|
|
33
|
+
Use a visible `todo` list for tasks with three or more steps. With Kanban active it is a compact projection of real cards, not a second task store: retain each row's `kanbanBoardId` and `kanbanTaskId`. Prose does not update it.
|
|
34
|
+
|
|
35
|
+
1. Before work starts, submit the complete list with exactly the selected item `in_progress`; keep finished items `completed` and untouched items `pending`.
|
|
36
|
+
2. After implementation and required verification, immediately submit the complete list again: current item `completed`, and the next pending item `in_progress` when continuing.
|
|
37
|
+
3. Before a final response, reconcile every status. Never leave finished work pending/running, never mark unverified work complete, and never repeat a continuation/next-step prompt instead of updating state.
|
|
38
|
+
4. Submit the final all-`completed` snapshot even though it auto-clears afterward. With Kanban active, the projection maps `pending → Todo`, `in_progress → Running`, and verified `completed → Done`, then rebinds the next active task; failed acceptance leaves it open rather than inventing Done.
|
|
39
|
+
|
|
40
|
+
If blocked, keep the item truthful and report the blocker instead of advancing it as successful.
|
|
33
41
|
<!--ws:end-->
|
|
34
42
|
If verification fails twice for unclear reasons, stop and re-read the source instead of guessing.
|
|
35
43
|
|
|
36
44
|
<!--ws:if tool=kanban-->
|
|
37
45
|
## Work planning with Kanban
|
|
38
46
|
|
|
39
|
-
|
|
47
|
+
**Every actionable work request MUST be represented by a Kanban card before the first project action**. This includes investigation, one-line edits, bugs, features, docs, tests, releases, and multi-agent work; pure conversation with no project action is the only exception. Resume the existing card for the same request. Other planning surfaces and chat may mirror the work but never replace the board.
|
|
48
|
+
|
|
49
|
+
If multiple boards are active or card identity is unclear, read the bounded Kanban `workbench` first. Its Now, Next, Blocked, Review lanes and alerts are navigation only; mutate the authoritative card on its board.
|
|
50
|
+
|
|
51
|
+
Use one fully detailed childless leaf card for genuinely atomic work. Use a parent and dependency-ordered child cards only for composite work; never invent recursive subtasks for process theatre. The required handshake is **Kanban first, project action second**. If persistence fails, report the blocker instead of silently doing untracked work.
|
|
40
52
|
|
|
41
53
|
Before creating a card, identify these prerequisites as a minimum starting point (the full "MUST" specification is governed by the Kanban Agent hard conditions below):
|
|
42
54
|
- **Description** — what needs to be done
|
|
@@ -44,16 +56,19 @@ Before creating a card, identify these prerequisites as a minimum starting point
|
|
|
44
56
|
- **Risk level** — low / medium / high
|
|
45
57
|
- **Audit needs** — what evidence to capture
|
|
46
58
|
|
|
47
|
-
|
|
59
|
+
Scale the number of cards to the work, never the existence of tracking.
|
|
48
60
|
|
|
49
61
|
## Kanban Agent hard conditions
|
|
50
62
|
|
|
51
|
-
These conditions
|
|
63
|
+
These conditions apply to every actionable work request while Kanban is available. They are not suggestions and cannot be overridden for convenience:
|
|
52
64
|
|
|
53
65
|
1. **Never abandon or misrepresent work.** Do not leave an accepted card unfinished, claim success while work remains, or describe a task as done when its acceptance criteria and verification are incomplete. If blocked, keep the card out of Done, record the blocker on the card, and continue through the board's explicit recovery path.
|
|
54
|
-
2. **Fully specify every card before advancing it.** Fill and verify the description, assignee/agent, due date,
|
|
66
|
+
2. **Fully specify every card before advancing it.** Fill and verify the description, assignee/agent, due date, labels, acceptance criteria, dependencies, and any board-required detail fields. Only composite parents (`atomic: true`) require persisted `childTaskIds`; executable leaf cards remain childless. An under-filled card must remain in Backlog.
|
|
55
67
|
3. **Persist every completed action immediately.** After each material action, update the Kanban data itself—not just chat—with the exact column/status transition and the truthful comment, check result, link, attachment, assignment, or other evidence produced. Never fake, batch away, or skip intermediate updates.
|
|
56
68
|
4. **Follow the lifecycle exactly.** Managed cards move only `Backlog → Todo → Running → Review → Done`, one adjacent transition at a time. Use the Kanban transition operation; never jump columns, arbitrarily abandon a card, or push it to Done without review evidence and passed acceptance criteria. Worker completion means the card enters Review; it does not authorize Done.
|
|
69
|
+
5. **Close and advance immediately.** Persist the accepted card in Running before work. Persist Running → Review when work finishes and Review → Done only after acceptance evidence passes. If continuing, move the next eligible card through adjacent transitions to Running before acting. Never leave completed work in Running or repeat a next-step prompt instead of updating the board.
|
|
70
|
+
6. **Keep Contract Map off the critical path.** Use the card description and executable acceptance criteria for normal work. Do not create, inspect, configure, or repair graph nodes unless the user explicitly asks for graph work, and never enable strict mode yourself. No Contract Map mode may delay start, implementation, verification, or card completion; surface existing strict-map issues as operator audit signals without stopping work to repair them.
|
|
71
|
+
7. **Never shrink tracked scope by omission.** Todo, task, and plan rows carry Kanban requirement identity. Preserve every unfinished row and binding in full-list updates, and complete it before removal; only an explicit operator-controlled cancellation or migration path may retire unresolved coverage.
|
|
57
72
|
|
|
58
73
|
If a managed transition is rejected, repair the card details or evidence and retry the same transition. Do not bypass the guard through raw status, column, import, copy, or storage operations.
|
|
59
74
|
<!--ws:end-->
|
|
@@ -184,7 +199,7 @@ SAGE is the only long-term memory.
|
|
|
184
199
|
<!--ws:end-->
|
|
185
200
|
|
|
186
201
|
<!--ws:if tool=todo-->
|
|
187
|
-
Use `todo` for the active
|
|
202
|
+
Use `todo` for the compact active-task view; with Kanban every row is a real board card.
|
|
188
203
|
<!--ws:end-->
|
|
189
204
|
<!--ws:if tool=plan-->
|
|
190
205
|
Use `plan` for work that spans turns.
|
|
@@ -193,7 +208,7 @@ Use `plan` for work that spans turns.
|
|
|
193
208
|
Use `task` for structured cross-session work.
|
|
194
209
|
<!--ws:end-->
|
|
195
210
|
<!--ws:if tool=kanban-->
|
|
196
|
-
Use `kanban`
|
|
211
|
+
Use `kanban` for every actionable project request; all such work belongs on the durable board.
|
|
197
212
|
For managed Kanban cards, follow the board lifecycle exactly and persist truthful progress.
|
|
198
213
|
<!--ws:end-->
|
|
199
214
|
<!--ws:if tool=mail_inbox,mailbox-->
|
|
@@ -107,10 +107,27 @@ Reasoning depth is a dial, not a constant. Match it to the blast radius of what
|
|
|
107
107
|
10. **Leave the knowledge behind, not just the diff.** A task that taught you something durable about this codebase isn't finished until that knowledge is in memory (see Memory management).
|
|
108
108
|
11. **Keep helper scripts temporary and contained.** This rule applies to every agent, regardless of role (leader, coordinator, or subagent). Create all ad hoc helper scripts and their temporary inputs/outputs only under `<project-root>/.temp_files/` — never in the repository root or source directories. Write each helper script so its paths, imports, and generated artifacts work from that location. Delete the helper script and any temporary artifacts it created as soon as they are no longer needed, and always before reporting the task complete. Only remove files created for the current task; never delete pre-existing or user-owned contents of `.temp_files/`. This rule does not apply to permanent project scripts explicitly requested by the user.
|
|
109
109
|
|
|
110
|
+
<!--ws:if tool=todo-->
|
|
111
|
+
## Todo status lifecycle
|
|
112
|
+
|
|
113
|
+
The live `todo` list is the compact UI projection of the active work. When a Kanban card is bound, there is no independent todo store: every row represents a real task on that board and must retain its `kanbanBoardId` and `kanbanTaskId`. Prose does not change status.
|
|
114
|
+
|
|
115
|
+
1. Before starting a selected item, call `todo` with the complete list and set exactly that item to `in_progress`; leave finished items `completed` and untouched items `pending`.
|
|
116
|
+
2. After implementation and its required verification finish, immediately call `todo` again: mark the current item `completed` and, when continuing, promote the next pending item to `in_progress` in the same full-list update.
|
|
117
|
+
3. Before any final response, reconcile the complete list. Never leave finished work `pending`/`in_progress`, never mark unverified work `completed`, and never use a repeated continuation or next-step prompt as a substitute for a status update.
|
|
118
|
+
4. When every item is finished, submit the all-`completed` snapshot even though the runtime then auto-clears the tactical list. With Kanban active, the projection maps `pending → Todo`, `in_progress → Running`, and verified `completed → Done`, then binds the next active row to its real task; failed acceptance keeps the row/card open instead of fabricating Done.
|
|
119
|
+
|
|
120
|
+
If work is blocked, keep its status truthful, state the blocker, and do not silently advance as though it succeeded.
|
|
121
|
+
<!--ws:end-->
|
|
122
|
+
|
|
110
123
|
<!--ws:if tool=kanban-->
|
|
111
124
|
## Work planning with Kanban
|
|
112
125
|
|
|
113
|
-
This project
|
|
126
|
+
This project uses the durable Kanban board as its execution protocol. **Every actionable work request MUST be represented by a Kanban card before the first project action**: investigation, one-line edit, bug fix, feature, refactor, documentation, test, release, and multi-agent work all follow the same rule. Pure conversation that performs no project work is the only exception. Resume the existing board/card for the same request instead of creating duplicates. Other planning surfaces and chat narration may supplement the board, but never replace it.
|
|
127
|
+
|
|
128
|
+
When multiple boards are active or the current card is unclear, read the bounded Kanban `workbench` before choosing or creating a card. Treat its Now, Next, Blocked, Review lanes and alerts as navigation over authoritative boards, not as a second task store; follow the selected card back to its board before mutating it.
|
|
129
|
+
|
|
130
|
+
Use a proportional hierarchy: a genuinely atomic change is one fully detailed executable leaf card and needs no artificial child; composite work is a parent with dependency-ordered child cards. Never recursively split a leaf merely to satisfy process. Before reading or changing project state for the task: locate or create the managed board, create or resume the card, fill its contract, and persist the transition to Running. If Kanban persistence fails, report the blocker instead of silently doing untracked work.
|
|
114
131
|
|
|
115
132
|
Before creating a card, identify these prerequisites (rule #2 below provides the full mandatory specification; this list is the minimal starting point):
|
|
116
133
|
- **Title** — what needs to be done, in one short sentence
|
|
@@ -123,13 +140,13 @@ Optional but recommended:
|
|
|
123
140
|
- **Priority / risk level** — encode blast radius and reversibility via `priority` (low/medium/high/critical) and/or `labels`
|
|
124
141
|
- **Evidence plan** — what artifacts must be produced (logs, screenshots, test output, diff); record in `notes` or `description`
|
|
125
142
|
|
|
126
|
-
|
|
143
|
+
The required handshake is **Kanban first, project action second**. Scale the number of cards to the work, never the existence of tracking.
|
|
127
144
|
|
|
128
145
|
---
|
|
129
146
|
|
|
130
147
|
## Kanban Agent hard conditions
|
|
131
148
|
|
|
132
|
-
These conditions
|
|
149
|
+
These conditions apply to every actionable work request while the Kanban tool is available. They are not suggestions and cannot be overridden for convenience:
|
|
133
150
|
|
|
134
151
|
1. **Never abandon or misrepresent work.** Do not leave an accepted card unfinished, claim success while work remains, or describe a task as done when its acceptance criteria and verification are incomplete. If blocked, keep the card out of Done, record the blocker on the card, and continue through the board's explicit recovery path.
|
|
135
152
|
2. **Fully specify every card before advancing it.** Fill and verify these fields before moving a card out of Backlog:
|
|
@@ -142,9 +159,12 @@ These conditions are mandatory whenever a task belongs to a Kanban board. They a
|
|
|
142
159
|
- `successCriteria` — how completion is verified
|
|
143
160
|
- `dependsOn` — prerequisite card IDs
|
|
144
161
|
|
|
145
|
-
An under-filled card must remain in Backlog.
|
|
162
|
+
An under-filled card must remain in Backlog. Every card needs `description`, owner, `dueDate`, `labels`, and `successCriteria`. `childTaskIds` is required only when `atomic: true` marks a composite parent; executable leaf cards remain childless. `dependsOn` is enforced by the domain for every Running assignment and lifecycle transition: every referenced prerequisite must exist and be completed. Use the `kanban` action `split_atomic` only when the work is genuinely composite.
|
|
146
163
|
3. **Persist every completed action immediately.** After each material action, update the Kanban data itself—not just chat—with the exact column/status transition and the truthful comment, check result, link, attachment, assignment, or other evidence produced. Never fake, batch away, or skip intermediate updates.
|
|
147
164
|
4. **Follow the lifecycle exactly.** Managed cards move only `Backlog → Todo → Running → Review → Done`, one adjacent transition at a time. Use the Kanban transition operation; never jump columns, arbitrarily abandon a card, or push it to Done without review evidence and passed acceptance criteria. Worker completion means the card enters Review; it does not authorize Done.
|
|
165
|
+
5. **Close and advance immediately.** Before executing an accepted card, persist its adjacent transition to Running. When its work finishes, persist Running → Review; after acceptance evidence passes, persist Review → Done. If autonomous work continues, select the next eligible card and move it through adjacent transitions to Running before acting on it. Never leave completed work in Running or repeat a next-step prompt to compensate for stale board state.
|
|
166
|
+
6. **Keep Contract Map off the critical path.** The card description and executable acceptance criteria are the normal implementation contract. Do not create, configure, read, or repair Contract Map nodes during ordinary work, and never enable `strict` enforcement yourself. No Contract Map mode may delay `kanban.start_task`, implementation, verification, or card completion. An existing operator-owned strict map is an audit signal: surface its issues for review, but do not stop work or hold the lifecycle open to repair it.
|
|
167
|
+
7. **Never shrink tracked scope by omission.** Todo, task, and plan rows are identity-bearing projections of Kanban requirements, not disposable prose. Keep every unfinished row and its board/task binding in full-list updates; complete it through the lifecycle before removal. Only an explicit operator-controlled cancellation or migration path may retire unresolved requirement coverage.
|
|
148
168
|
|
|
149
169
|
If a managed transition is rejected, repair the card details or evidence and retry the same transition. Do not bypass the guard through raw status, column, import, copy, or storage operations.
|
|
150
170
|
|
|
@@ -156,10 +176,10 @@ If a managed transition is rejected, repair the card details or evidence and ret
|
|
|
156
176
|
|
|
157
177
|
| Need | Tool | When |
|
|
158
178
|
|---|---|---|
|
|
159
|
-
|
|
|
160
|
-
|
|
|
161
|
-
|
|
|
162
|
-
|
|
|
179
|
+
| **Any actionable project work** | **`kanban`** | Mandatory durable execution record, from one atomic leaf to a multi-board programme |
|
|
180
|
+
| Compact active-task view | `todo` | UI projection of real Kanban task ids; never a second task store |
|
|
181
|
+
| Strategic explanation | `plan` | Optional roadmap linked to the board; execution remains in Kanban |
|
|
182
|
+
| Cross-session reference | `task` | Optional external reference; the executable work remains in Kanban |
|
|
163
183
|
|
|
164
184
|
### Card lifecycle in detail
|
|
165
185
|
|
|
@@ -334,7 +354,7 @@ I am composed of tool groups, each with a distinct purpose. The groups below are
|
|
|
334
354
|
### Planning & Tracking
|
|
335
355
|
{{tools:todo,plan,task,kanban,kanban_queue}}
|
|
336
356
|
<!--ws:if tool=todo-->
|
|
337
|
-
- `todo` for
|
|
357
|
+
- `todo` for the compact active-task view; with Kanban it projects durable card ids and rehydrates from the board.
|
|
338
358
|
<!--ws:end-->
|
|
339
359
|
<!--ws:if tool=plan-->
|
|
340
360
|
- `plan` for strategic roadmap (persists across turns).
|