@opencode_weave/weave 0.3.2
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/LICENSE +21 -0
- package/README.md +317 -0
- package/dist/agents/agent-builder.d.ts +10 -0
- package/dist/agents/builtin-agents.d.ts +16 -0
- package/dist/agents/dynamic-prompt-builder.d.ts +29 -0
- package/dist/agents/index.d.ts +8 -0
- package/dist/agents/loom/default.d.ts +2 -0
- package/dist/agents/loom/index.d.ts +2 -0
- package/dist/agents/model-resolution.d.ts +19 -0
- package/dist/agents/pattern/default.d.ts +2 -0
- package/dist/agents/pattern/index.d.ts +2 -0
- package/dist/agents/shuttle/default.d.ts +2 -0
- package/dist/agents/shuttle/index.d.ts +2 -0
- package/dist/agents/spindle/default.d.ts +2 -0
- package/dist/agents/spindle/index.d.ts +2 -0
- package/dist/agents/tapestry/default.d.ts +2 -0
- package/dist/agents/tapestry/index.d.ts +2 -0
- package/dist/agents/thread/default.d.ts +2 -0
- package/dist/agents/thread/index.d.ts +2 -0
- package/dist/agents/types.d.ts +82 -0
- package/dist/agents/warp/default.d.ts +2 -0
- package/dist/agents/warp/index.d.ts +2 -0
- package/dist/agents/weft/default.d.ts +2 -0
- package/dist/agents/weft/index.d.ts +2 -0
- package/dist/config/index.d.ts +3 -0
- package/dist/config/loader.d.ts +2 -0
- package/dist/config/merge.d.ts +3 -0
- package/dist/config/schema.d.ts +162 -0
- package/dist/create-managers.d.ts +18 -0
- package/dist/create-tools.d.ts +16 -0
- package/dist/features/builtin-commands/commands.d.ts +2 -0
- package/dist/features/builtin-commands/index.d.ts +2 -0
- package/dist/features/builtin-commands/templates/start-work.d.ts +1 -0
- package/dist/features/builtin-commands/types.d.ts +16 -0
- package/dist/features/skill-loader/builtin-skills.d.ts +2 -0
- package/dist/features/skill-loader/discovery.d.ts +12 -0
- package/dist/features/skill-loader/index.d.ts +7 -0
- package/dist/features/skill-loader/loader.d.ts +6 -0
- package/dist/features/skill-loader/merger.d.ts +2 -0
- package/dist/features/skill-loader/resolver.d.ts +6 -0
- package/dist/features/skill-loader/types.d.ts +25 -0
- package/dist/features/work-state/constants.d.ts +8 -0
- package/dist/features/work-state/index.d.ts +3 -0
- package/dist/features/work-state/storage.d.ts +38 -0
- package/dist/features/work-state/types.d.ts +27 -0
- package/dist/hooks/context-window-monitor.d.ts +19 -0
- package/dist/hooks/create-hooks.d.ts +32 -0
- package/dist/hooks/first-message-variant.d.ts +5 -0
- package/dist/hooks/index.d.ts +12 -0
- package/dist/hooks/keyword-detector.d.ts +8 -0
- package/dist/hooks/pattern-md-only.d.ts +13 -0
- package/dist/hooks/rules-injector.d.ts +6 -0
- package/dist/hooks/start-work-hook.d.ts +20 -0
- package/dist/hooks/verification-reminder.d.ts +22 -0
- package/dist/hooks/work-continuation.d.ts +17 -0
- package/dist/hooks/write-existing-file-guard.d.ts +14 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +2191 -0
- package/dist/managers/background-manager.d.ts +68 -0
- package/dist/managers/config-handler.d.ts +54 -0
- package/dist/managers/index.d.ts +6 -0
- package/dist/managers/skill-mcp-manager.d.ts +30 -0
- package/dist/plugin/index.d.ts +1 -0
- package/dist/plugin/plugin-interface.d.ts +12 -0
- package/dist/plugin/types.d.ts +5 -0
- package/dist/shared/agent-display-names.d.ts +20 -0
- package/dist/shared/index.d.ts +3 -0
- package/dist/shared/log.d.ts +2 -0
- package/dist/shared/types.d.ts +6 -0
- package/dist/tools/index.d.ts +4 -0
- package/dist/tools/permissions.d.ts +18 -0
- package/dist/tools/registry.d.ts +29 -0
- package/package.json +52 -0
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const AgentOverrideConfigSchema: z.ZodObject<{
|
|
3
|
+
model: z.ZodOptional<z.ZodString>;
|
|
4
|
+
fallback_models: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
5
|
+
variant: z.ZodOptional<z.ZodString>;
|
|
6
|
+
category: z.ZodOptional<z.ZodString>;
|
|
7
|
+
skills: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
8
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
9
|
+
top_p: z.ZodOptional<z.ZodNumber>;
|
|
10
|
+
prompt: z.ZodOptional<z.ZodString>;
|
|
11
|
+
prompt_append: z.ZodOptional<z.ZodString>;
|
|
12
|
+
tools: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
|
|
13
|
+
disable: z.ZodOptional<z.ZodBoolean>;
|
|
14
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
15
|
+
subagent: "subagent";
|
|
16
|
+
primary: "primary";
|
|
17
|
+
all: "all";
|
|
18
|
+
}>>;
|
|
19
|
+
maxTokens: z.ZodOptional<z.ZodNumber>;
|
|
20
|
+
}, z.core.$strip>;
|
|
21
|
+
export declare const AgentOverridesSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
22
|
+
model: z.ZodOptional<z.ZodString>;
|
|
23
|
+
fallback_models: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
24
|
+
variant: z.ZodOptional<z.ZodString>;
|
|
25
|
+
category: z.ZodOptional<z.ZodString>;
|
|
26
|
+
skills: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
27
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
28
|
+
top_p: z.ZodOptional<z.ZodNumber>;
|
|
29
|
+
prompt: z.ZodOptional<z.ZodString>;
|
|
30
|
+
prompt_append: z.ZodOptional<z.ZodString>;
|
|
31
|
+
tools: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
|
|
32
|
+
disable: z.ZodOptional<z.ZodBoolean>;
|
|
33
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
34
|
+
subagent: "subagent";
|
|
35
|
+
primary: "primary";
|
|
36
|
+
all: "all";
|
|
37
|
+
}>>;
|
|
38
|
+
maxTokens: z.ZodOptional<z.ZodNumber>;
|
|
39
|
+
}, z.core.$strip>>;
|
|
40
|
+
export declare const CategoryConfigSchema: z.ZodObject<{
|
|
41
|
+
description: z.ZodOptional<z.ZodString>;
|
|
42
|
+
model: z.ZodOptional<z.ZodString>;
|
|
43
|
+
fallback_models: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
44
|
+
variant: z.ZodOptional<z.ZodString>;
|
|
45
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
46
|
+
top_p: z.ZodOptional<z.ZodNumber>;
|
|
47
|
+
maxTokens: z.ZodOptional<z.ZodNumber>;
|
|
48
|
+
tools: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
|
|
49
|
+
prompt_append: z.ZodOptional<z.ZodString>;
|
|
50
|
+
disable: z.ZodOptional<z.ZodBoolean>;
|
|
51
|
+
}, z.core.$strip>;
|
|
52
|
+
export declare const CategoriesConfigSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
53
|
+
description: z.ZodOptional<z.ZodString>;
|
|
54
|
+
model: z.ZodOptional<z.ZodString>;
|
|
55
|
+
fallback_models: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
56
|
+
variant: z.ZodOptional<z.ZodString>;
|
|
57
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
58
|
+
top_p: z.ZodOptional<z.ZodNumber>;
|
|
59
|
+
maxTokens: z.ZodOptional<z.ZodNumber>;
|
|
60
|
+
tools: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
|
|
61
|
+
prompt_append: z.ZodOptional<z.ZodString>;
|
|
62
|
+
disable: z.ZodOptional<z.ZodBoolean>;
|
|
63
|
+
}, z.core.$strip>>;
|
|
64
|
+
export declare const BackgroundConfigSchema: z.ZodObject<{
|
|
65
|
+
defaultConcurrency: z.ZodOptional<z.ZodNumber>;
|
|
66
|
+
providerConcurrency: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
67
|
+
modelConcurrency: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
68
|
+
staleTimeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
69
|
+
}, z.core.$strip>;
|
|
70
|
+
export declare const TmuxConfigSchema: z.ZodObject<{
|
|
71
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
72
|
+
layout: z.ZodOptional<z.ZodEnum<{
|
|
73
|
+
"main-horizontal": "main-horizontal";
|
|
74
|
+
"main-vertical": "main-vertical";
|
|
75
|
+
tiled: "tiled";
|
|
76
|
+
"even-horizontal": "even-horizontal";
|
|
77
|
+
"even-vertical": "even-vertical";
|
|
78
|
+
}>>;
|
|
79
|
+
main_pane_size: z.ZodOptional<z.ZodNumber>;
|
|
80
|
+
}, z.core.$strip>;
|
|
81
|
+
export declare const SkillsConfigSchema: z.ZodObject<{
|
|
82
|
+
paths: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
83
|
+
recursive: z.ZodOptional<z.ZodBoolean>;
|
|
84
|
+
}, z.core.$strip>;
|
|
85
|
+
export declare const ExperimentalConfigSchema: z.ZodObject<{
|
|
86
|
+
plugin_load_timeout_ms: z.ZodOptional<z.ZodNumber>;
|
|
87
|
+
context_window_warning_threshold: z.ZodOptional<z.ZodNumber>;
|
|
88
|
+
context_window_critical_threshold: z.ZodOptional<z.ZodNumber>;
|
|
89
|
+
}, z.core.$strip>;
|
|
90
|
+
export declare const WeaveConfigSchema: z.ZodObject<{
|
|
91
|
+
$schema: z.ZodOptional<z.ZodString>;
|
|
92
|
+
agents: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
93
|
+
model: z.ZodOptional<z.ZodString>;
|
|
94
|
+
fallback_models: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
95
|
+
variant: z.ZodOptional<z.ZodString>;
|
|
96
|
+
category: z.ZodOptional<z.ZodString>;
|
|
97
|
+
skills: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
98
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
99
|
+
top_p: z.ZodOptional<z.ZodNumber>;
|
|
100
|
+
prompt: z.ZodOptional<z.ZodString>;
|
|
101
|
+
prompt_append: z.ZodOptional<z.ZodString>;
|
|
102
|
+
tools: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
|
|
103
|
+
disable: z.ZodOptional<z.ZodBoolean>;
|
|
104
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
105
|
+
subagent: "subagent";
|
|
106
|
+
primary: "primary";
|
|
107
|
+
all: "all";
|
|
108
|
+
}>>;
|
|
109
|
+
maxTokens: z.ZodOptional<z.ZodNumber>;
|
|
110
|
+
}, z.core.$strip>>>;
|
|
111
|
+
categories: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
112
|
+
description: z.ZodOptional<z.ZodString>;
|
|
113
|
+
model: z.ZodOptional<z.ZodString>;
|
|
114
|
+
fallback_models: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
115
|
+
variant: z.ZodOptional<z.ZodString>;
|
|
116
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
117
|
+
top_p: z.ZodOptional<z.ZodNumber>;
|
|
118
|
+
maxTokens: z.ZodOptional<z.ZodNumber>;
|
|
119
|
+
tools: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
|
|
120
|
+
prompt_append: z.ZodOptional<z.ZodString>;
|
|
121
|
+
disable: z.ZodOptional<z.ZodBoolean>;
|
|
122
|
+
}, z.core.$strip>>>;
|
|
123
|
+
disabled_hooks: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
124
|
+
disabled_tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
125
|
+
disabled_agents: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
126
|
+
disabled_skills: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
127
|
+
background: z.ZodOptional<z.ZodObject<{
|
|
128
|
+
defaultConcurrency: z.ZodOptional<z.ZodNumber>;
|
|
129
|
+
providerConcurrency: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
130
|
+
modelConcurrency: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
131
|
+
staleTimeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
132
|
+
}, z.core.$strip>>;
|
|
133
|
+
tmux: z.ZodOptional<z.ZodObject<{
|
|
134
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
135
|
+
layout: z.ZodOptional<z.ZodEnum<{
|
|
136
|
+
"main-horizontal": "main-horizontal";
|
|
137
|
+
"main-vertical": "main-vertical";
|
|
138
|
+
tiled: "tiled";
|
|
139
|
+
"even-horizontal": "even-horizontal";
|
|
140
|
+
"even-vertical": "even-vertical";
|
|
141
|
+
}>>;
|
|
142
|
+
main_pane_size: z.ZodOptional<z.ZodNumber>;
|
|
143
|
+
}, z.core.$strip>>;
|
|
144
|
+
skills: z.ZodOptional<z.ZodObject<{
|
|
145
|
+
paths: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
146
|
+
recursive: z.ZodOptional<z.ZodBoolean>;
|
|
147
|
+
}, z.core.$strip>>;
|
|
148
|
+
experimental: z.ZodOptional<z.ZodObject<{
|
|
149
|
+
plugin_load_timeout_ms: z.ZodOptional<z.ZodNumber>;
|
|
150
|
+
context_window_warning_threshold: z.ZodOptional<z.ZodNumber>;
|
|
151
|
+
context_window_critical_threshold: z.ZodOptional<z.ZodNumber>;
|
|
152
|
+
}, z.core.$strip>>;
|
|
153
|
+
}, z.core.$strip>;
|
|
154
|
+
export type AgentOverrideConfig = z.infer<typeof AgentOverrideConfigSchema>;
|
|
155
|
+
export type AgentOverrides = z.infer<typeof AgentOverridesSchema>;
|
|
156
|
+
export type CategoryConfig = z.infer<typeof CategoryConfigSchema>;
|
|
157
|
+
export type CategoriesConfig = z.infer<typeof CategoriesConfigSchema>;
|
|
158
|
+
export type BackgroundConfig = z.infer<typeof BackgroundConfigSchema>;
|
|
159
|
+
export type TmuxConfig = z.infer<typeof TmuxConfigSchema>;
|
|
160
|
+
export type SkillsConfig = z.infer<typeof SkillsConfigSchema>;
|
|
161
|
+
export type ExperimentalConfig = z.infer<typeof ExperimentalConfigSchema>;
|
|
162
|
+
export type WeaveConfig = z.infer<typeof WeaveConfigSchema>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { PluginInput } from "@opencode-ai/plugin";
|
|
2
|
+
import type { AgentConfig } from "@opencode-ai/sdk";
|
|
3
|
+
import type { WeaveConfig } from "./config/schema";
|
|
4
|
+
import type { ResolveSkillsFn } from "./agents/agent-builder";
|
|
5
|
+
import { ConfigHandler } from "./managers/config-handler";
|
|
6
|
+
import { BackgroundManager } from "./managers/background-manager";
|
|
7
|
+
import { SkillMcpManager } from "./managers/skill-mcp-manager";
|
|
8
|
+
export interface WeaveManagers {
|
|
9
|
+
configHandler: ConfigHandler;
|
|
10
|
+
backgroundManager: BackgroundManager;
|
|
11
|
+
skillMcpManager: SkillMcpManager;
|
|
12
|
+
agents: Record<string, AgentConfig>;
|
|
13
|
+
}
|
|
14
|
+
export declare function createManagers(options: {
|
|
15
|
+
ctx: PluginInput;
|
|
16
|
+
pluginConfig: WeaveConfig;
|
|
17
|
+
resolveSkills?: ResolveSkillsFn;
|
|
18
|
+
}): WeaveManagers;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { PluginInput } from "@opencode-ai/plugin";
|
|
2
|
+
import type { WeaveConfig } from "./config/schema";
|
|
3
|
+
import type { WeaveManagers } from "./create-managers";
|
|
4
|
+
import type { ToolsRecord } from "./plugin/types";
|
|
5
|
+
import type { LoadedSkill } from "./features/skill-loader/types";
|
|
6
|
+
import type { ResolveSkillsFn } from "./agents/agent-builder";
|
|
7
|
+
export interface ToolsResult {
|
|
8
|
+
tools: ToolsRecord;
|
|
9
|
+
availableSkills: LoadedSkill[];
|
|
10
|
+
resolveSkillsFn: ResolveSkillsFn;
|
|
11
|
+
}
|
|
12
|
+
export declare function createTools(options: {
|
|
13
|
+
ctx: PluginInput;
|
|
14
|
+
pluginConfig: WeaveConfig;
|
|
15
|
+
managers?: WeaveManagers;
|
|
16
|
+
}): Promise<ToolsResult>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const START_WORK_TEMPLATE = "You are being activated by the /start-work command to execute a Weave plan.\n\n## Your Mission\nRead and execute the work plan, completing each task systematically.\n\n## Startup Procedure\n\n1. **Check for active work state**: Read `.weave/state.json` to see if there's a plan already in progress.\n2. **If resuming**: The system has injected context below with the active plan path and progress. Read the plan file, find the first unchecked `- [ ]` task, and continue from there.\n3. **If starting fresh**: The system has selected a plan and created work state. Read the plan file and begin from the first task.\n\n## Execution Loop\n\nFor each unchecked `- [ ]` task in the plan:\n\n1. **Read** the task description, acceptance criteria, and any references\n2. **Execute** the task \u2014 write code, run commands, create files as needed\n3. **Verify** the work \u2014 run tests, check for errors, validate acceptance criteria\n4. **Mark complete** \u2014 use the Edit tool to change `- [ ]` to `- [x]` in the plan file\n5. **Move on** \u2014 find the next unchecked task and repeat\n\n## Rules\n\n- Work through tasks **top to bottom** unless dependencies require a different order\n- **Verify every task** before marking it complete\n- If blocked on a task, document the reason as a comment in the plan and move to the next unblocked task\n- Report progress after each task: \"Completed task N/M: [title]\"\n- Do NOT stop until all checkboxes are checked or you are explicitly told to stop\n- After all tasks are complete, report a final summary";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A built-in command that can be invoked via /command-name in the chat.
|
|
3
|
+
*/
|
|
4
|
+
export interface BuiltinCommand {
|
|
5
|
+
/** Command name matching the key in BUILTIN_COMMANDS (e.g., "start-work") */
|
|
6
|
+
name: string;
|
|
7
|
+
/** Human-readable description shown in command list */
|
|
8
|
+
description: string;
|
|
9
|
+
/** Agent to switch to when this command is executed */
|
|
10
|
+
agent: string;
|
|
11
|
+
/** Prompt template with $SESSION_ID, $TIMESTAMP, $ARGUMENTS placeholders */
|
|
12
|
+
template: string;
|
|
13
|
+
/** Hint shown for the argument (e.g., "[plan-name]") */
|
|
14
|
+
argumentHint?: string;
|
|
15
|
+
}
|
|
16
|
+
export type BuiltinCommandName = "start-work";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { LoadedSkill, SkillMetadata, SkillScope } from "./types";
|
|
2
|
+
interface ParsedFrontmatter {
|
|
3
|
+
metadata: SkillMetadata;
|
|
4
|
+
content: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function parseFrontmatter(text: string): ParsedFrontmatter;
|
|
7
|
+
export interface ScanDirectoryOptions {
|
|
8
|
+
directory: string;
|
|
9
|
+
scope: SkillScope;
|
|
10
|
+
}
|
|
11
|
+
export declare function scanDirectory(options: ScanDirectoryOptions): LoadedSkill[];
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { loadSkills } from "./loader";
|
|
2
|
+
export type { LoadSkillsOptions } from "./loader";
|
|
3
|
+
export { createResolveSkillsFn, createSkillResolver, resolveMultipleSkills, resolveSkill } from "./resolver";
|
|
4
|
+
export { scanDirectory, parseFrontmatter } from "./discovery";
|
|
5
|
+
export { mergeSkills } from "./merger";
|
|
6
|
+
export { createBuiltinSkills } from "./builtin-skills";
|
|
7
|
+
export type { SkillScope, SkillMetadata, LoadedSkill, SkillDiscoveryResult } from "./types";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SkillDiscoveryResult } from "./types";
|
|
2
|
+
export declare function resolveSkill(name: string, result: SkillDiscoveryResult): string;
|
|
3
|
+
export declare function resolveMultipleSkills(skillNames: string[], disabledSkills?: Set<string>, discovered?: SkillDiscoveryResult): string;
|
|
4
|
+
export declare function createSkillResolver(discovered: SkillDiscoveryResult): (skillNames: string[], disabledSkills?: Set<string>) => string;
|
|
5
|
+
/** @deprecated Use createSkillResolver instead */
|
|
6
|
+
export declare const createResolveSkillsFn: typeof createSkillResolver;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type SkillScope = "builtin" | "user" | "project";
|
|
2
|
+
export interface SkillMetadata {
|
|
3
|
+
name?: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
model?: string;
|
|
6
|
+
tools?: string | string[];
|
|
7
|
+
mcp?: {
|
|
8
|
+
name: string;
|
|
9
|
+
type: "stdio" | "http";
|
|
10
|
+
command?: string;
|
|
11
|
+
args?: string[];
|
|
12
|
+
url?: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export interface LoadedSkill {
|
|
16
|
+
name: string;
|
|
17
|
+
description: string;
|
|
18
|
+
content: string;
|
|
19
|
+
scope: SkillScope;
|
|
20
|
+
path?: string;
|
|
21
|
+
model?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface SkillDiscoveryResult {
|
|
24
|
+
skills: LoadedSkill[];
|
|
25
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Root directory for Weave state and plans */
|
|
2
|
+
export declare const WEAVE_DIR = ".weave";
|
|
3
|
+
/** Work state file name */
|
|
4
|
+
export declare const WORK_STATE_FILE = "state.json";
|
|
5
|
+
/** Full relative path to work state */
|
|
6
|
+
export declare const WORK_STATE_PATH = ".weave/state.json";
|
|
7
|
+
/** Directory where plan files are stored */
|
|
8
|
+
export declare const PLANS_DIR = ".weave/plans";
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export type { WorkState, PlanProgress } from "./types";
|
|
2
|
+
export { WEAVE_DIR, WORK_STATE_FILE, WORK_STATE_PATH, PLANS_DIR } from "./constants";
|
|
3
|
+
export { readWorkState, writeWorkState, clearWorkState, appendSessionId, createWorkState, findPlans, getPlanProgress, getPlanName, } from "./storage";
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { WorkState, PlanProgress } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Read work state from .weave/state.json.
|
|
4
|
+
* Returns null if file is missing, unparseable, or invalid.
|
|
5
|
+
*/
|
|
6
|
+
export declare function readWorkState(directory: string): WorkState | null;
|
|
7
|
+
/**
|
|
8
|
+
* Write work state to .weave/state.json.
|
|
9
|
+
* Creates .weave/ directory if needed.
|
|
10
|
+
*/
|
|
11
|
+
export declare function writeWorkState(directory: string, state: WorkState): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Clear work state by deleting .weave/state.json.
|
|
14
|
+
*/
|
|
15
|
+
export declare function clearWorkState(directory: string): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Append a session ID to the work state (if not already present).
|
|
18
|
+
* Returns the updated state, or null if no state exists.
|
|
19
|
+
*/
|
|
20
|
+
export declare function appendSessionId(directory: string, sessionId: string): WorkState | null;
|
|
21
|
+
/**
|
|
22
|
+
* Create a fresh WorkState for a plan file.
|
|
23
|
+
*/
|
|
24
|
+
export declare function createWorkState(planPath: string, sessionId: string, agent?: string): WorkState;
|
|
25
|
+
/**
|
|
26
|
+
* Find all plan files in .weave/plans/, sorted by modification time (newest first).
|
|
27
|
+
* Returns absolute paths.
|
|
28
|
+
*/
|
|
29
|
+
export declare function findPlans(directory: string): string[];
|
|
30
|
+
/**
|
|
31
|
+
* Count checked and unchecked markdown checkboxes in a plan file.
|
|
32
|
+
* Returns isComplete: true if file is missing, has 0 checkboxes, or all are checked.
|
|
33
|
+
*/
|
|
34
|
+
export declare function getPlanProgress(planPath: string): PlanProgress;
|
|
35
|
+
/**
|
|
36
|
+
* Extract plan name from file path (basename minus .md extension).
|
|
37
|
+
*/
|
|
38
|
+
export declare function getPlanName(planPath: string): string;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tracks the active plan being executed via /start-work.
|
|
3
|
+
* Stored at .weave/state.json in the project root.
|
|
4
|
+
*/
|
|
5
|
+
export interface WorkState {
|
|
6
|
+
/** Absolute path to the active plan file */
|
|
7
|
+
active_plan: string;
|
|
8
|
+
/** ISO timestamp when work started */
|
|
9
|
+
started_at: string;
|
|
10
|
+
/** Session IDs that have worked on this plan */
|
|
11
|
+
session_ids: string[];
|
|
12
|
+
/** Plan name derived from filename (without .md) */
|
|
13
|
+
plan_name: string;
|
|
14
|
+
/** Agent type to use when resuming (e.g., "tapestry") */
|
|
15
|
+
agent?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Progress snapshot from counting checkboxes in a plan file.
|
|
19
|
+
*/
|
|
20
|
+
export interface PlanProgress {
|
|
21
|
+
/** Total number of checkboxes (checked + unchecked) */
|
|
22
|
+
total: number;
|
|
23
|
+
/** Number of completed checkboxes */
|
|
24
|
+
completed: number;
|
|
25
|
+
/** Whether all tasks are done (total === 0 or completed === total) */
|
|
26
|
+
isComplete: boolean;
|
|
27
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface ContextWindowState {
|
|
2
|
+
usedTokens: number;
|
|
3
|
+
maxTokens: number;
|
|
4
|
+
sessionId: string;
|
|
5
|
+
}
|
|
6
|
+
export interface ContextWindowThresholds {
|
|
7
|
+
warningPct: number;
|
|
8
|
+
criticalPct: number;
|
|
9
|
+
}
|
|
10
|
+
export type ContextWindowAction = "none" | "warn" | "recover";
|
|
11
|
+
export interface ContextWindowCheckResult {
|
|
12
|
+
action: ContextWindowAction;
|
|
13
|
+
usagePct: number;
|
|
14
|
+
message?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function checkContextWindow(state: ContextWindowState, thresholds?: ContextWindowThresholds): ContextWindowCheckResult;
|
|
17
|
+
export declare function createContextWindowMonitor(thresholds?: ContextWindowThresholds): {
|
|
18
|
+
check: (state: ContextWindowState) => ContextWindowCheckResult;
|
|
19
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { WeaveConfig } from "../config/schema";
|
|
2
|
+
import { checkContextWindow } from "./context-window-monitor";
|
|
3
|
+
import { getRulesForFile, shouldInjectRules } from "./rules-injector";
|
|
4
|
+
import { shouldApplyVariant, markApplied, markSessionCreated, clearSession } from "./first-message-variant";
|
|
5
|
+
import { processMessageForKeywords } from "./keyword-detector";
|
|
6
|
+
import { checkPatternWrite } from "./pattern-md-only";
|
|
7
|
+
import { buildVerificationReminder } from "./verification-reminder";
|
|
8
|
+
export type CreatedHooks = ReturnType<typeof createHooks>;
|
|
9
|
+
export declare function createHooks(args: {
|
|
10
|
+
pluginConfig: WeaveConfig;
|
|
11
|
+
isHookEnabled: (hookName: string) => boolean;
|
|
12
|
+
directory: string;
|
|
13
|
+
}): {
|
|
14
|
+
checkContextWindow: ((state: Parameters<typeof checkContextWindow>[0]) => import("./context-window-monitor").ContextWindowCheckResult) | null;
|
|
15
|
+
writeGuard: {
|
|
16
|
+
trackRead: (filePath: string) => void;
|
|
17
|
+
checkWrite: (filePath: string) => import("./write-existing-file-guard").WriteGuardCheckResult;
|
|
18
|
+
} | null;
|
|
19
|
+
shouldInjectRules: typeof shouldInjectRules | null;
|
|
20
|
+
getRulesForFile: typeof getRulesForFile | null;
|
|
21
|
+
firstMessageVariant: {
|
|
22
|
+
shouldApplyVariant: typeof shouldApplyVariant;
|
|
23
|
+
markApplied: typeof markApplied;
|
|
24
|
+
markSessionCreated: typeof markSessionCreated;
|
|
25
|
+
clearSession: typeof clearSession;
|
|
26
|
+
} | null;
|
|
27
|
+
processMessageForKeywords: typeof processMessageForKeywords | null;
|
|
28
|
+
patternMdOnly: typeof checkPatternWrite | null;
|
|
29
|
+
startWork: ((promptText: string, sessionId: string) => import("./start-work-hook").StartWorkResult) | null;
|
|
30
|
+
workContinuation: ((sessionId: string) => import("./work-continuation").ContinuationResult) | null;
|
|
31
|
+
verificationReminder: typeof buildVerificationReminder | null;
|
|
32
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function markSessionCreated(sessionId: string): void;
|
|
2
|
+
export declare function markApplied(sessionId: string): void;
|
|
3
|
+
export declare function shouldApplyVariant(sessionId: string): boolean;
|
|
4
|
+
export declare function clearSession(sessionId: string): void;
|
|
5
|
+
export declare function clearAll(): void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { createHooks } from "./create-hooks";
|
|
2
|
+
export type { CreatedHooks } from "./create-hooks";
|
|
3
|
+
export { checkContextWindow, createContextWindowMonitor } from "./context-window-monitor";
|
|
4
|
+
export type { ContextWindowState, ContextWindowThresholds, ContextWindowCheckResult, ContextWindowAction, } from "./context-window-monitor";
|
|
5
|
+
export { createWriteGuard, createWriteGuardState, trackFileRead, checkWriteAllowed, } from "./write-existing-file-guard";
|
|
6
|
+
export type { WriteGuardState, WriteGuardCheckResult } from "./write-existing-file-guard";
|
|
7
|
+
export { shouldInjectRules, getRulesForFile, buildRulesInjection, getDirectoryFromFilePath, findRulesFile, loadRulesForDirectory, } from "./rules-injector";
|
|
8
|
+
export { shouldApplyVariant, markApplied, markSessionCreated, clearSession, clearAll, } from "./first-message-variant";
|
|
9
|
+
export { detectKeywords, buildKeywordInjection, processMessageForKeywords, DEFAULT_KEYWORD_ACTIONS, } from "./keyword-detector";
|
|
10
|
+
export type { KeywordAction } from "./keyword-detector";
|
|
11
|
+
export { buildVerificationReminder } from "./verification-reminder";
|
|
12
|
+
export type { VerificationInput, VerificationResult } from "./verification-reminder";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface KeywordAction {
|
|
2
|
+
keyword: string;
|
|
3
|
+
injection: string;
|
|
4
|
+
}
|
|
5
|
+
export declare const DEFAULT_KEYWORD_ACTIONS: KeywordAction[];
|
|
6
|
+
export declare function detectKeywords(message: string, actions?: KeywordAction[]): KeywordAction[];
|
|
7
|
+
export declare function buildKeywordInjection(detected: KeywordAction[]): string | undefined;
|
|
8
|
+
export declare function processMessageForKeywords(message: string, sessionId: string, actions?: KeywordAction[]): string | undefined;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Guard hook that prevents Pattern agent from writing non-.md files
|
|
3
|
+
* or writing outside the .weave/ directory.
|
|
4
|
+
*/
|
|
5
|
+
export interface PatternWriteCheckResult {
|
|
6
|
+
allowed: boolean;
|
|
7
|
+
reason?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Check whether a write/edit operation should be allowed for the given agent.
|
|
11
|
+
* Only blocks writes from the "pattern" agent to non-.md files or files outside .weave/.
|
|
12
|
+
*/
|
|
13
|
+
export declare function checkPatternWrite(agentName: string, toolName: string, filePath: string): PatternWriteCheckResult;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function findRulesFile(directory: string): string | undefined;
|
|
2
|
+
export declare function loadRulesForDirectory(directory: string): string | undefined;
|
|
3
|
+
export declare function shouldInjectRules(toolName: string): boolean;
|
|
4
|
+
export declare function getDirectoryFromFilePath(filePath: string): string;
|
|
5
|
+
export declare function buildRulesInjection(rulesContent: string, directory: string): string;
|
|
6
|
+
export declare function getRulesForFile(filePath: string): string | undefined;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Start-work hook: detects the /start-work command, resolves the target plan,
|
|
3
|
+
* creates/updates work state, and returns context for injection into the prompt.
|
|
4
|
+
*/
|
|
5
|
+
export interface StartWorkInput {
|
|
6
|
+
promptText: string;
|
|
7
|
+
sessionId: string;
|
|
8
|
+
directory: string;
|
|
9
|
+
}
|
|
10
|
+
export interface StartWorkResult {
|
|
11
|
+
/** Context to inject into the prompt (plan path, progress, instructions) */
|
|
12
|
+
contextInjection: string | null;
|
|
13
|
+
/** Agent to switch to (always "tapestry" when command is detected) */
|
|
14
|
+
switchAgent: string | null;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Handle the /start-work command.
|
|
18
|
+
* Returns null contextInjection if this message is not a /start-work command.
|
|
19
|
+
*/
|
|
20
|
+
export declare function handleStartWork(input: StartWorkInput): StartWorkResult;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Verification reminder hook: builds a prompt that reminds the orchestrator
|
|
3
|
+
* to verify completed work, optionally delegating to Weft for review.
|
|
4
|
+
*/
|
|
5
|
+
export interface VerificationInput {
|
|
6
|
+
/** Name of the plan being executed, if any */
|
|
7
|
+
planName?: string;
|
|
8
|
+
/** Progress of the current plan */
|
|
9
|
+
progress?: {
|
|
10
|
+
total: number;
|
|
11
|
+
completed: number;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export interface VerificationResult {
|
|
15
|
+
/** Verification prompt to inject, or null if not applicable */
|
|
16
|
+
verificationPrompt: string | null;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Build a verification reminder prompt to inject after task completion.
|
|
20
|
+
* Returns a structured reminder for the orchestrator to verify work.
|
|
21
|
+
*/
|
|
22
|
+
export declare function buildVerificationReminder(input: VerificationInput): VerificationResult;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Work continuation hook: checks if there's an active plan with remaining tasks
|
|
3
|
+
* and returns a continuation prompt to keep the executor going.
|
|
4
|
+
*/
|
|
5
|
+
export interface ContinuationInput {
|
|
6
|
+
sessionId: string;
|
|
7
|
+
directory: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ContinuationResult {
|
|
10
|
+
/** Continuation prompt to inject, or null if no active work / plan complete */
|
|
11
|
+
continuationPrompt: string | null;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Check if there's active work that should continue.
|
|
15
|
+
* Returns a continuation prompt if the plan has remaining tasks, null otherwise.
|
|
16
|
+
*/
|
|
17
|
+
export declare function checkContinuation(input: ContinuationInput): ContinuationResult;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface WriteGuardState {
|
|
2
|
+
readFiles: Set<string>;
|
|
3
|
+
}
|
|
4
|
+
export declare function createWriteGuardState(): WriteGuardState;
|
|
5
|
+
export declare function trackFileRead(state: WriteGuardState, filePath: string): void;
|
|
6
|
+
export interface WriteGuardCheckResult {
|
|
7
|
+
allowed: boolean;
|
|
8
|
+
warning?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function checkWriteAllowed(state: WriteGuardState, filePath: string): WriteGuardCheckResult;
|
|
11
|
+
export declare function createWriteGuard(state: WriteGuardState): {
|
|
12
|
+
trackRead: (filePath: string) => void;
|
|
13
|
+
checkWrite: (filePath: string) => WriteGuardCheckResult;
|
|
14
|
+
};
|