@opencode_weave/weave 0.7.1 → 0.7.4-preview.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -196
- package/dist/agents/tapestry/prompt-composer.d.ts +3 -1
- package/dist/config/schema.d.ts +3 -0
- package/dist/features/analytics/generate-metrics-report.d.ts +4 -4
- package/dist/features/analytics/index.d.ts +4 -3
- package/dist/features/analytics/plan-token-aggregator.d.ts +24 -1
- package/dist/features/analytics/quality-score.d.ts +30 -0
- package/dist/features/analytics/session-tracker.d.ts +5 -0
- package/dist/features/analytics/types.d.ts +51 -14
- package/dist/features/evals/evaluators/trajectory-assertion.d.ts +2 -0
- package/dist/features/evals/executors/github-models-api.d.ts +13 -0
- package/dist/features/evals/executors/model-response.d.ts +6 -1
- package/dist/features/evals/executors/prompt-renderer.d.ts +1 -1
- package/dist/features/evals/executors/trajectory-run.d.ts +3 -0
- package/dist/features/evals/index.d.ts +8 -5
- package/dist/features/evals/loader.d.ts +2 -1
- package/dist/features/evals/reporter.d.ts +1 -0
- package/dist/features/evals/runner.d.ts +1 -1
- package/dist/features/evals/schema.d.ts +65 -16
- package/dist/features/evals/storage.d.ts +2 -0
- package/dist/features/evals/types.d.ts +43 -2
- package/dist/features/skill-loader/loader.d.ts +2 -0
- package/dist/features/workflow/context.d.ts +2 -1
- package/dist/features/workflow/discovery.d.ts +6 -3
- package/dist/features/workflow/hook.d.ts +2 -0
- package/dist/hooks/compaction-todo-preserver.d.ts +20 -0
- package/dist/hooks/create-hooks.d.ts +4 -0
- package/dist/hooks/index.d.ts +6 -0
- package/dist/hooks/todo-continuation-enforcer.d.ts +25 -0
- package/dist/hooks/todo-description-override.d.ts +18 -0
- package/dist/hooks/todo-writer.d.ts +17 -0
- package/dist/index.js +755 -254
- package/dist/plugin/types.d.ts +1 -1
- package/dist/shared/resolve-safe-path.d.ts +14 -0
- package/package.json +10 -8
- package/dist/features/analytics/suggestions.d.ts +0 -10
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export declare const EvalPhaseSchema: z.ZodEnum<{
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
prompt: "prompt";
|
|
4
|
+
experimental: "experimental";
|
|
5
|
+
routing: "routing";
|
|
6
|
+
trajectory: "trajectory";
|
|
7
7
|
}>;
|
|
8
8
|
export declare const BuiltinAgentPromptVariantSchema: z.ZodObject<{
|
|
9
9
|
disabledAgents: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
@@ -14,6 +14,7 @@ export declare const BuiltinAgentPromptTargetSchema: z.ZodObject<{
|
|
|
14
14
|
pattern: "pattern";
|
|
15
15
|
loom: "loom";
|
|
16
16
|
tapestry: "tapestry";
|
|
17
|
+
shuttle: "shuttle";
|
|
17
18
|
thread: "thread";
|
|
18
19
|
spindle: "spindle";
|
|
19
20
|
weft: "weft";
|
|
@@ -43,6 +44,7 @@ export declare const EvalTargetSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
43
44
|
pattern: "pattern";
|
|
44
45
|
loom: "loom";
|
|
45
46
|
tapestry: "tapestry";
|
|
47
|
+
shuttle: "shuttle";
|
|
46
48
|
thread: "thread";
|
|
47
49
|
spindle: "spindle";
|
|
48
50
|
weft: "weft";
|
|
@@ -144,6 +146,39 @@ export declare const TrajectoryAssertionEvaluatorSchema: z.ZodObject<{
|
|
|
144
146
|
weight: z.ZodOptional<z.ZodNumber>;
|
|
145
147
|
kind: z.ZodLiteral<"trajectory-assertion">;
|
|
146
148
|
assertionRef: z.ZodOptional<z.ZodString>;
|
|
149
|
+
expectedSequence: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
150
|
+
requiredAgents: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
151
|
+
forbiddenAgents: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
152
|
+
minTurns: z.ZodOptional<z.ZodNumber>;
|
|
153
|
+
maxTurns: z.ZodOptional<z.ZodNumber>;
|
|
154
|
+
}, z.core.$strip>;
|
|
155
|
+
export declare const TrajectoryTurnSchema: z.ZodObject<{
|
|
156
|
+
turn: z.ZodNumber;
|
|
157
|
+
role: z.ZodEnum<{
|
|
158
|
+
user: "user";
|
|
159
|
+
assistant: "assistant";
|
|
160
|
+
}>;
|
|
161
|
+
agent: z.ZodOptional<z.ZodString>;
|
|
162
|
+
content: z.ZodString;
|
|
163
|
+
mockResponse: z.ZodOptional<z.ZodString>;
|
|
164
|
+
expectedDelegation: z.ZodOptional<z.ZodString>;
|
|
165
|
+
}, z.core.$strip>;
|
|
166
|
+
export declare const TrajectoryScenarioSchema: z.ZodObject<{
|
|
167
|
+
id: z.ZodString;
|
|
168
|
+
title: z.ZodString;
|
|
169
|
+
description: z.ZodOptional<z.ZodString>;
|
|
170
|
+
agents: z.ZodArray<z.ZodString>;
|
|
171
|
+
turns: z.ZodArray<z.ZodObject<{
|
|
172
|
+
turn: z.ZodNumber;
|
|
173
|
+
role: z.ZodEnum<{
|
|
174
|
+
user: "user";
|
|
175
|
+
assistant: "assistant";
|
|
176
|
+
}>;
|
|
177
|
+
agent: z.ZodOptional<z.ZodString>;
|
|
178
|
+
content: z.ZodString;
|
|
179
|
+
mockResponse: z.ZodOptional<z.ZodString>;
|
|
180
|
+
expectedDelegation: z.ZodOptional<z.ZodString>;
|
|
181
|
+
}, z.core.$strip>>;
|
|
147
182
|
}, z.core.$strip>;
|
|
148
183
|
export declare const EvaluatorSpecSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
149
184
|
weight: z.ZodOptional<z.ZodNumber>;
|
|
@@ -192,15 +227,21 @@ export declare const EvaluatorSpecSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
192
227
|
weight: z.ZodOptional<z.ZodNumber>;
|
|
193
228
|
kind: z.ZodLiteral<"trajectory-assertion">;
|
|
194
229
|
assertionRef: z.ZodOptional<z.ZodString>;
|
|
230
|
+
expectedSequence: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
231
|
+
requiredAgents: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
232
|
+
forbiddenAgents: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
233
|
+
minTurns: z.ZodOptional<z.ZodNumber>;
|
|
234
|
+
maxTurns: z.ZodOptional<z.ZodNumber>;
|
|
195
235
|
}, z.core.$strip>], "kind">;
|
|
196
236
|
export declare const EvalCaseSchema: z.ZodObject<{
|
|
197
237
|
id: z.ZodString;
|
|
198
238
|
title: z.ZodString;
|
|
239
|
+
description: z.ZodOptional<z.ZodString>;
|
|
199
240
|
phase: z.ZodEnum<{
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
241
|
+
prompt: "prompt";
|
|
242
|
+
experimental: "experimental";
|
|
243
|
+
routing: "routing";
|
|
244
|
+
trajectory: "trajectory";
|
|
204
245
|
}>;
|
|
205
246
|
target: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
206
247
|
kind: z.ZodLiteral<"builtin-agent-prompt">;
|
|
@@ -208,6 +249,7 @@ export declare const EvalCaseSchema: z.ZodObject<{
|
|
|
208
249
|
pattern: "pattern";
|
|
209
250
|
loom: "loom";
|
|
210
251
|
tapestry: "tapestry";
|
|
252
|
+
shuttle: "shuttle";
|
|
211
253
|
thread: "thread";
|
|
212
254
|
spindle: "spindle";
|
|
213
255
|
weft: "weft";
|
|
@@ -286,6 +328,11 @@ export declare const EvalCaseSchema: z.ZodObject<{
|
|
|
286
328
|
weight: z.ZodOptional<z.ZodNumber>;
|
|
287
329
|
kind: z.ZodLiteral<"trajectory-assertion">;
|
|
288
330
|
assertionRef: z.ZodOptional<z.ZodString>;
|
|
331
|
+
expectedSequence: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
332
|
+
requiredAgents: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
333
|
+
forbiddenAgents: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
334
|
+
minTurns: z.ZodOptional<z.ZodNumber>;
|
|
335
|
+
maxTurns: z.ZodOptional<z.ZodNumber>;
|
|
289
336
|
}, z.core.$strip>], "kind">>;
|
|
290
337
|
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
291
338
|
notes: z.ZodOptional<z.ZodString>;
|
|
@@ -294,10 +341,10 @@ export declare const EvalSuiteManifestSchema: z.ZodObject<{
|
|
|
294
341
|
id: z.ZodString;
|
|
295
342
|
title: z.ZodString;
|
|
296
343
|
phase: z.ZodEnum<{
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
344
|
+
prompt: "prompt";
|
|
345
|
+
experimental: "experimental";
|
|
346
|
+
routing: "routing";
|
|
347
|
+
trajectory: "trajectory";
|
|
301
348
|
}>;
|
|
302
349
|
caseFiles: z.ZodArray<z.ZodString>;
|
|
303
350
|
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
@@ -342,6 +389,7 @@ export declare const EvalArtifactsSchema: z.ZodObject<{
|
|
|
342
389
|
}, z.core.$strip>;
|
|
343
390
|
export declare const EvalCaseResultSchema: z.ZodObject<{
|
|
344
391
|
caseId: z.ZodString;
|
|
392
|
+
description: z.ZodOptional<z.ZodString>;
|
|
345
393
|
status: z.ZodEnum<{
|
|
346
394
|
error: "error";
|
|
347
395
|
failed: "failed";
|
|
@@ -406,10 +454,10 @@ export declare const EvalRunResultSchema: z.ZodObject<{
|
|
|
406
454
|
finishedAt: z.ZodString;
|
|
407
455
|
suiteId: z.ZodString;
|
|
408
456
|
phase: z.ZodEnum<{
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
457
|
+
prompt: "prompt";
|
|
458
|
+
experimental: "experimental";
|
|
459
|
+
routing: "routing";
|
|
460
|
+
trajectory: "trajectory";
|
|
413
461
|
}>;
|
|
414
462
|
summary: z.ZodObject<{
|
|
415
463
|
totalCases: z.ZodNumber;
|
|
@@ -422,6 +470,7 @@ export declare const EvalRunResultSchema: z.ZodObject<{
|
|
|
422
470
|
}, z.core.$strip>;
|
|
423
471
|
caseResults: z.ZodArray<z.ZodObject<{
|
|
424
472
|
caseId: z.ZodString;
|
|
473
|
+
description: z.ZodOptional<z.ZodString>;
|
|
425
474
|
status: z.ZodEnum<{
|
|
426
475
|
error: "error";
|
|
427
476
|
failed: "failed";
|
|
@@ -5,3 +5,5 @@ export declare const EVAL_LATEST_FILE = ".weave/evals/latest.json";
|
|
|
5
5
|
export declare function ensureEvalStorageDir(directory: string): string;
|
|
6
6
|
export declare function getDefaultEvalRunPath(directory: string, runId: string): string;
|
|
7
7
|
export declare function writeEvalRunResult(directory: string, result: EvalRunResult, outputPath?: string): string;
|
|
8
|
+
export declare function getDefaultJsonlPath(directory: string, suiteId: string): string;
|
|
9
|
+
export declare function appendEvalRunJsonl(directory: string, result: EvalRunResult, jsonlPath?: string): string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { WeaveAgentName } from "../../agents/types";
|
|
2
|
-
export declare const EVAL_PHASES: readonly ["
|
|
2
|
+
export declare const EVAL_PHASES: readonly ["prompt", "routing", "trajectory", "experimental"];
|
|
3
3
|
export type EvalPhase = (typeof EVAL_PHASES)[number];
|
|
4
4
|
export declare const EVAL_TARGET_KINDS: readonly ["builtin-agent-prompt", "custom-agent-prompt", "single-turn-agent", "trajectory-agent"];
|
|
5
5
|
export type EvalTargetKind = (typeof EVAL_TARGET_KINDS)[number];
|
|
@@ -7,7 +7,7 @@ export declare const EXECUTOR_KINDS: readonly ["prompt-render", "model-response"
|
|
|
7
7
|
export type ExecutorKind = (typeof EXECUTOR_KINDS)[number];
|
|
8
8
|
export declare const EVALUATOR_KINDS: readonly ["contains-all", "contains-any", "excludes-all", "section-contains-all", "ordered-contains", "xml-sections-present", "tool-policy", "min-length", "llm-judge", "baseline-diff", "trajectory-assertion"];
|
|
9
9
|
export type EvaluatorKind = (typeof EVALUATOR_KINDS)[number];
|
|
10
|
-
export type BuiltinEvalAgentName =
|
|
10
|
+
export type BuiltinEvalAgentName = WeaveAgentName;
|
|
11
11
|
export interface BuiltinAgentPromptVariant {
|
|
12
12
|
disabledAgents?: string[];
|
|
13
13
|
}
|
|
@@ -94,6 +94,11 @@ export interface BaselineDiffEvaluator extends WeightedEvaluatorSpec {
|
|
|
94
94
|
export interface TrajectoryAssertionEvaluator extends WeightedEvaluatorSpec {
|
|
95
95
|
kind: "trajectory-assertion";
|
|
96
96
|
assertionRef?: string;
|
|
97
|
+
expectedSequence?: string[];
|
|
98
|
+
requiredAgents?: string[];
|
|
99
|
+
forbiddenAgents?: string[];
|
|
100
|
+
minTurns?: number;
|
|
101
|
+
maxTurns?: number;
|
|
97
102
|
}
|
|
98
103
|
export type EvaluatorSpec = ContainsAllEvaluator | ContainsAnyEvaluator | ExcludesAllEvaluator | SectionContainsAllEvaluator | OrderedContainsEvaluator | XmlSectionsPresentEvaluator | ToolPolicyEvaluator | MinLengthEvaluator | LlmJudgeEvaluator | BaselineDiffEvaluator | TrajectoryAssertionEvaluator;
|
|
99
104
|
export interface EvalSuiteManifest {
|
|
@@ -106,6 +111,7 @@ export interface EvalSuiteManifest {
|
|
|
106
111
|
export interface EvalCase {
|
|
107
112
|
id: string;
|
|
108
113
|
title: string;
|
|
114
|
+
description?: string;
|
|
109
115
|
phase: EvalPhase;
|
|
110
116
|
target: EvalTarget;
|
|
111
117
|
executor: ExecutorSpec;
|
|
@@ -145,6 +151,7 @@ export interface AssertionResult {
|
|
|
145
151
|
}
|
|
146
152
|
export interface EvalCaseResult {
|
|
147
153
|
caseId: string;
|
|
154
|
+
description?: string;
|
|
148
155
|
status: "passed" | "failed" | "error";
|
|
149
156
|
score: number;
|
|
150
157
|
normalizedScore: number;
|
|
@@ -180,6 +187,7 @@ export interface ExecutionContext {
|
|
|
180
187
|
mode: "local" | "ci" | "hosted";
|
|
181
188
|
directory: string;
|
|
182
189
|
outputPath?: string;
|
|
190
|
+
modelOverride?: string;
|
|
183
191
|
}
|
|
184
192
|
export interface RunnerFilters {
|
|
185
193
|
caseIds?: string[];
|
|
@@ -192,6 +200,7 @@ export interface RunEvalSuiteOptions {
|
|
|
192
200
|
filters?: RunnerFilters;
|
|
193
201
|
outputPath?: string;
|
|
194
202
|
mode?: ExecutionContext["mode"];
|
|
203
|
+
modelOverride?: string;
|
|
195
204
|
}
|
|
196
205
|
export interface EvalLoadErrorContext {
|
|
197
206
|
filePath: string;
|
|
@@ -221,3 +230,35 @@ export interface BaselineComparison {
|
|
|
221
230
|
regressions: string[];
|
|
222
231
|
informational: string[];
|
|
223
232
|
}
|
|
233
|
+
export interface TrajectoryTurn {
|
|
234
|
+
turn: number;
|
|
235
|
+
role: "user" | "assistant";
|
|
236
|
+
agent?: string;
|
|
237
|
+
content: string;
|
|
238
|
+
mockResponse?: string;
|
|
239
|
+
expectedDelegation?: string;
|
|
240
|
+
}
|
|
241
|
+
export interface TrajectoryScenario {
|
|
242
|
+
id: string;
|
|
243
|
+
title: string;
|
|
244
|
+
description?: string;
|
|
245
|
+
agents: string[];
|
|
246
|
+
turns: TrajectoryTurn[];
|
|
247
|
+
}
|
|
248
|
+
export interface TrajectoryTurnResult {
|
|
249
|
+
turn: number;
|
|
250
|
+
agent: string;
|
|
251
|
+
role: "user" | "assistant";
|
|
252
|
+
response: string;
|
|
253
|
+
expectedDelegation?: string;
|
|
254
|
+
observedDelegation?: string | null;
|
|
255
|
+
durationMs: number;
|
|
256
|
+
}
|
|
257
|
+
export interface TrajectoryTrace {
|
|
258
|
+
scenarioId: string;
|
|
259
|
+
turns: TrajectoryTurnResult[];
|
|
260
|
+
delegationSequence: string[];
|
|
261
|
+
totalTurns: number;
|
|
262
|
+
completedTurns: number;
|
|
263
|
+
}
|
|
264
|
+
export declare function isTrajectoryTrace(trace: unknown): trace is TrajectoryTrace;
|
|
@@ -3,5 +3,7 @@ export interface LoadSkillsOptions {
|
|
|
3
3
|
serverUrl: string | URL;
|
|
4
4
|
directory?: string;
|
|
5
5
|
disabledSkills?: string[];
|
|
6
|
+
/** Additional directories to scan for skills (from config `skill_directories`) */
|
|
7
|
+
customDirs?: string[];
|
|
6
8
|
}
|
|
7
9
|
export declare function loadSkills(options: LoadSkillsOptions): Promise<SkillDiscoveryResult>;
|
|
@@ -11,6 +11,7 @@ export declare function resolveTemplate(template: string, instance: WorkflowInst
|
|
|
11
11
|
export declare function buildContextHeader(instance: WorkflowInstance, definition: WorkflowDefinition): string;
|
|
12
12
|
/**
|
|
13
13
|
* Build the full context-threaded prompt for a step.
|
|
14
|
-
* Combines: (1) workflow context header, (2)
|
|
14
|
+
* Combines: (1) workflow context header, (2) delegation instruction if step
|
|
15
|
+
* targets a non-loom agent, (3) resolved step prompt.
|
|
15
16
|
*/
|
|
16
17
|
export declare function composeStepPrompt(stepDef: WorkflowStepDefinition, instance: WorkflowInstance, definition: WorkflowDefinition): string;
|
|
@@ -13,7 +13,10 @@ export interface DiscoveredWorkflow {
|
|
|
13
13
|
*/
|
|
14
14
|
export declare function loadWorkflowDefinition(filePath: string): WorkflowDefinition | null;
|
|
15
15
|
/**
|
|
16
|
-
* Discover all valid workflow definitions from project and user directories.
|
|
17
|
-
*
|
|
16
|
+
* Discover all valid workflow definitions from project, custom, and user directories.
|
|
17
|
+
* Override precedence (highest wins): project > custom > user.
|
|
18
|
+
*
|
|
19
|
+
* @param directory - Project root directory (used to resolve relative custom paths)
|
|
20
|
+
* @param customDirs - Optional extra directories to scan (from config `workflows.directories`)
|
|
18
21
|
*/
|
|
19
|
-
export declare function discoverWorkflows(directory: string): DiscoveredWorkflow[];
|
|
22
|
+
export declare function discoverWorkflows(directory: string, customDirs?: string[]): DiscoveredWorkflow[];
|
|
@@ -30,6 +30,7 @@ export declare function handleRunWorkflow(input: {
|
|
|
30
30
|
promptText: string;
|
|
31
31
|
sessionId: string;
|
|
32
32
|
directory: string;
|
|
33
|
+
workflowDirs?: string[];
|
|
33
34
|
}): WorkflowHookResult;
|
|
34
35
|
/**
|
|
35
36
|
* Check workflow continuation on session.idle.
|
|
@@ -41,6 +42,7 @@ export declare function checkWorkflowContinuation(input: {
|
|
|
41
42
|
directory: string;
|
|
42
43
|
lastAssistantMessage?: string;
|
|
43
44
|
lastUserMessage?: string;
|
|
45
|
+
workflowDirs?: string[];
|
|
44
46
|
}): {
|
|
45
47
|
continuationPrompt: string | null;
|
|
46
48
|
switchAgent: string | null;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* compaction-todo-preserver hook
|
|
3
|
+
*
|
|
4
|
+
* Snapshots todos before compaction, restores them if wiped by compaction.
|
|
5
|
+
* Defense-in-depth against OpenCode's context compaction clearing the todo list.
|
|
6
|
+
*/
|
|
7
|
+
import type { PluginContext } from "../plugin/types";
|
|
8
|
+
export type TodoSnapshot = {
|
|
9
|
+
content: string;
|
|
10
|
+
status: string;
|
|
11
|
+
priority: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function createCompactionTodoPreserver(client: PluginContext["client"]): {
|
|
14
|
+
capture: (sessionID: string) => Promise<void>;
|
|
15
|
+
handleEvent: (event: {
|
|
16
|
+
type: string;
|
|
17
|
+
properties?: unknown;
|
|
18
|
+
}) => Promise<void>;
|
|
19
|
+
getSnapshot: (sessionID: string) => TodoSnapshot[] | undefined;
|
|
20
|
+
};
|
|
@@ -5,6 +5,7 @@ import { shouldApplyVariant, markApplied, markSessionCreated, clearSession } fro
|
|
|
5
5
|
import { processMessageForKeywords } from "./keyword-detector";
|
|
6
6
|
import { checkPatternWrite } from "./pattern-md-only";
|
|
7
7
|
import { buildVerificationReminder } from "./verification-reminder";
|
|
8
|
+
import { applyTodoDescriptionOverride } from "./todo-description-override";
|
|
8
9
|
export type CreatedHooks = ReturnType<typeof createHooks>;
|
|
9
10
|
export declare function createHooks(args: {
|
|
10
11
|
pluginConfig: WeaveConfig;
|
|
@@ -36,5 +37,8 @@ export declare function createHooks(args: {
|
|
|
36
37
|
}) | null;
|
|
37
38
|
workflowCommand: ((message: string) => import("../features/workflow").WorkflowCommandResult) | null;
|
|
38
39
|
verificationReminder: typeof buildVerificationReminder | null;
|
|
40
|
+
todoDescriptionOverride: typeof applyTodoDescriptionOverride | null;
|
|
41
|
+
compactionTodoPreserverEnabled: boolean;
|
|
42
|
+
todoContinuationEnforcerEnabled: boolean;
|
|
39
43
|
analyticsEnabled: boolean;
|
|
40
44
|
};
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -12,3 +12,9 @@ export { buildVerificationReminder } from "./verification-reminder";
|
|
|
12
12
|
export type { VerificationInput, VerificationResult } from "./verification-reminder";
|
|
13
13
|
export { setContextLimit, updateUsage, getState, clearSession as clearTokenSession, clear as clearAllTokenState, } from "./session-token-state";
|
|
14
14
|
export type { SessionTokenEntry } from "./session-token-state";
|
|
15
|
+
export { applyTodoDescriptionOverride, TODOWRITE_DESCRIPTION } from "./todo-description-override";
|
|
16
|
+
export { createCompactionTodoPreserver } from "./compaction-todo-preserver";
|
|
17
|
+
export type { TodoSnapshot } from "./compaction-todo-preserver";
|
|
18
|
+
export { createTodoContinuationEnforcer, FINALIZE_TODOS_MARKER } from "./todo-continuation-enforcer";
|
|
19
|
+
export { resolveTodoWriter } from "./todo-writer";
|
|
20
|
+
export type { TodoItem, TodoWriter } from "./todo-writer";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* todo-continuation-enforcer hook
|
|
3
|
+
*
|
|
4
|
+
* Ensures in_progress todos are finalized when a session goes idle.
|
|
5
|
+
* Extracted from the inline finalization logic in plugin-interface.ts.
|
|
6
|
+
*
|
|
7
|
+
* Primary path (zero-cost): If opencode/session/todo is available, directly
|
|
8
|
+
* mutates the todo list to mark in_progress items as completed.
|
|
9
|
+
*
|
|
10
|
+
* Fallback path (1 LLM turn): If unavailable, injects a prompt asking the LLM
|
|
11
|
+
* to finalize the todos.
|
|
12
|
+
*/
|
|
13
|
+
import type { PluginContext } from "../plugin/types";
|
|
14
|
+
import { type TodoWriter } from "./todo-writer";
|
|
15
|
+
export declare const FINALIZE_TODOS_MARKER = "<!-- weave:finalize-todos -->";
|
|
16
|
+
export declare function createTodoContinuationEnforcer(client: PluginContext["client"], options?: {
|
|
17
|
+
/** Inject a mock todo writer for testing (bypasses dynamic import) */
|
|
18
|
+
todoWriterOverride?: TodoWriter | null;
|
|
19
|
+
}): {
|
|
20
|
+
checkAndFinalize: (sessionID: string) => Promise<void>;
|
|
21
|
+
markFinalized: (sessionID: string) => void;
|
|
22
|
+
isFinalized: (sessionID: string) => boolean;
|
|
23
|
+
clearFinalized: (sessionID: string) => void;
|
|
24
|
+
clearSession: (sessionID: string) => void;
|
|
25
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* todo-description-override hook
|
|
3
|
+
*
|
|
4
|
+
* Overrides the TodoWrite tool description with stronger language emphasizing
|
|
5
|
+
* that it is a destructive full-array replacement and items must NEVER be dropped.
|
|
6
|
+
*/
|
|
7
|
+
export declare const TODOWRITE_DESCRIPTION = "Manages the sidebar todo list. CRITICAL: This tool performs a FULL ARRAY REPLACEMENT \u2014 every call completely DELETES all existing todos and replaces them with whatever you send. NEVER drop existing items. ALWAYS include ALL current todos in EVERY call. If unsure what todos currently exist, call todoread BEFORE calling this tool. Rules: max 35 chars per item, encode WHERE + WHAT (e.g. \"src/foo.ts: add error handler\"). Status values: \"pending\", \"in_progress\", \"completed\", \"cancelled\". Priority values: \"high\", \"medium\", \"low\".";
|
|
8
|
+
/**
|
|
9
|
+
* Applies the enhanced TodoWrite description override.
|
|
10
|
+
* Mutates `output.description` when `input.toolID === "todowrite"`.
|
|
11
|
+
* Pure function — no side effects, no async, no state.
|
|
12
|
+
*/
|
|
13
|
+
export declare function applyTodoDescriptionOverride(input: {
|
|
14
|
+
toolID: string;
|
|
15
|
+
}, output: {
|
|
16
|
+
description: string;
|
|
17
|
+
parameters?: unknown;
|
|
18
|
+
}): void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared todo-writer resolution utility.
|
|
3
|
+
*
|
|
4
|
+
* Dynamically imports opencode/session/todo to get Todo.update().
|
|
5
|
+
* Uses a variable for the module specifier to prevent bundler inlining.
|
|
6
|
+
* Returns null if the module is unavailable (non-fatal).
|
|
7
|
+
*/
|
|
8
|
+
export type TodoItem = {
|
|
9
|
+
content: string;
|
|
10
|
+
status: string;
|
|
11
|
+
priority?: string;
|
|
12
|
+
};
|
|
13
|
+
export type TodoWriter = (input: {
|
|
14
|
+
sessionID: string;
|
|
15
|
+
todos: TodoItem[];
|
|
16
|
+
}) => void;
|
|
17
|
+
export declare function resolveTodoWriter(): Promise<TodoWriter | null>;
|