@opencode_weave/weave 0.6.1 → 0.6.3
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 +5 -0
- package/dist/agents/agent-builder.d.ts +14 -0
- package/dist/agents/builtin-agents.d.ts +16 -0
- package/dist/agents/custom-agent-factory.d.ts +24 -0
- package/dist/agents/dynamic-prompt-builder.d.ts +6 -0
- package/dist/agents/index.d.ts +6 -2
- package/dist/agents/loom/index.d.ts +9 -0
- package/dist/agents/loom/prompt-composer.d.ts +35 -0
- package/dist/agents/model-resolution.d.ts +9 -1
- package/dist/agents/prompt-loader.d.ts +9 -0
- package/dist/agents/prompt-utils.d.ts +2 -0
- package/dist/agents/tapestry/index.d.ts +7 -0
- package/dist/agents/tapestry/prompt-composer.d.ts +24 -0
- package/dist/config/schema.d.ts +112 -0
- package/dist/create-managers.d.ts +3 -0
- package/dist/features/analytics/fingerprint.d.ts +32 -0
- package/dist/features/analytics/index.d.ts +22 -0
- package/dist/features/analytics/session-tracker.d.ts +48 -0
- package/dist/features/analytics/storage.d.ts +28 -0
- package/dist/features/analytics/suggestions.d.ts +10 -0
- package/dist/features/analytics/types.d.ts +104 -0
- package/dist/features/work-state/index.d.ts +1 -1
- package/dist/features/work-state/storage.d.ts +10 -0
- package/dist/features/work-state/types.d.ts +6 -0
- package/dist/hooks/create-hooks.d.ts +2 -0
- package/dist/hooks/work-continuation.d.ts +9 -0
- package/dist/index.js +1112 -173
- package/dist/plugin/plugin-interface.d.ts +3 -0
- package/dist/shared/agent-display-names.d.ts +11 -0
- package/dist/shared/index.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,6 +9,7 @@ Weave is a lean OpenCode plugin with multi-agent orchestration. It provides a co
|
|
|
9
9
|
## Table of Contents
|
|
10
10
|
|
|
11
11
|
- [Overview](#overview)
|
|
12
|
+
- [Documentation](#documentation)
|
|
12
13
|
- [Agents](#agents)
|
|
13
14
|
- [Agent Modes](#agent-modes)
|
|
14
15
|
- [Agent Details](#agent-details)
|
|
@@ -47,6 +48,10 @@ Weave is a lean OpenCode plugin with multi-agent orchestration. It provides a co
|
|
|
47
48
|
- **Tool permissions** enforced per-agent to ensure safety and prevent unauthorized file modifications.
|
|
48
49
|
- **JSONC configuration** supporting comments and trailing commas with hierarchical user and project-level merging.
|
|
49
50
|
|
|
51
|
+
## Documentation
|
|
52
|
+
|
|
53
|
+
Visit [tryweave.io](https://tryweave.io) for more information, or head straight to the [documentation](https://tryweave.io/docs/) for detailed guides on setup, configuration, and usage.
|
|
54
|
+
|
|
50
55
|
## Agents
|
|
51
56
|
|
|
52
57
|
| Agent | Role | Mode | Description |
|
|
@@ -6,5 +6,19 @@ export type BuildAgentOptions = {
|
|
|
6
6
|
categories?: CategoriesConfig;
|
|
7
7
|
disabledSkills?: Set<string>;
|
|
8
8
|
resolveSkills?: ResolveSkillsFn;
|
|
9
|
+
disabledAgents?: Set<string>;
|
|
9
10
|
};
|
|
11
|
+
/**
|
|
12
|
+
* Register name variants for a custom agent so that
|
|
13
|
+
* `stripDisabledAgentReferences` can strip its references from prompts.
|
|
14
|
+
* Does not override existing (builtin) entries.
|
|
15
|
+
*/
|
|
16
|
+
export declare function registerAgentNameVariants(name: string, variants?: string[]): void;
|
|
17
|
+
/**
|
|
18
|
+
* Remove lines from a prompt that reference disabled agents.
|
|
19
|
+
* Only strips lines where an agent name appears as a standalone concept
|
|
20
|
+
* (e.g. "Use thread (codebase explorer)"), not incidental word matches.
|
|
21
|
+
* Uses word-boundary matching to avoid false positives.
|
|
22
|
+
*/
|
|
23
|
+
export declare function stripDisabledAgentReferences(prompt: string, disabled: Set<string>): string;
|
|
10
24
|
export declare function buildAgent(source: AgentSource, model: string, options?: BuildAgentOptions): AgentConfig;
|
|
@@ -2,6 +2,8 @@ import type { AgentConfig } from "@opencode-ai/sdk";
|
|
|
2
2
|
import type { AgentPromptMetadata, WeaveAgentName } from "./types";
|
|
3
3
|
import type { CategoriesConfig, AgentOverrideConfig } from "../config/schema";
|
|
4
4
|
import type { ResolveSkillsFn } from "./agent-builder";
|
|
5
|
+
import type { ProjectFingerprint } from "../features/analytics/types";
|
|
6
|
+
import type { AvailableAgent } from "./dynamic-prompt-builder";
|
|
5
7
|
export interface CreateBuiltinAgentsOptions {
|
|
6
8
|
disabledAgents?: string[];
|
|
7
9
|
agentOverrides?: Record<string, AgentOverrideConfig>;
|
|
@@ -11,6 +13,20 @@ export interface CreateBuiltinAgentsOptions {
|
|
|
11
13
|
availableModels?: Set<string>;
|
|
12
14
|
disabledSkills?: Set<string>;
|
|
13
15
|
resolveSkills?: ResolveSkillsFn;
|
|
16
|
+
/** Project fingerprint for injecting project context into agent prompts */
|
|
17
|
+
fingerprint?: ProjectFingerprint | null;
|
|
18
|
+
/** Custom agent metadata for Loom's dynamic delegation prompt */
|
|
19
|
+
customAgentMetadata?: AvailableAgent[];
|
|
14
20
|
}
|
|
15
21
|
export declare const AGENT_METADATA: Record<WeaveAgentName, AgentPromptMetadata>;
|
|
22
|
+
/**
|
|
23
|
+
* Register metadata for a custom agent. Used by create-managers.ts
|
|
24
|
+
* to integrate custom agents into Loom's dynamic prompt builder.
|
|
25
|
+
*/
|
|
26
|
+
export declare function registerCustomAgentMetadata(name: string, metadata: AgentPromptMetadata): void;
|
|
27
|
+
/**
|
|
28
|
+
* Get all agent metadata — builtins + registered custom agents.
|
|
29
|
+
* Returns a new merged record on each call.
|
|
30
|
+
*/
|
|
31
|
+
export declare function getAllAgentMetadata(): Record<string, AgentPromptMetadata>;
|
|
16
32
|
export declare function createBuiltinAgents(options?: CreateBuiltinAgentsOptions): Record<string, AgentConfig>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { AgentConfig } from "@opencode-ai/sdk";
|
|
2
|
+
import type { CustomAgentConfig } from "../config/schema";
|
|
3
|
+
import type { AgentPromptMetadata } from "./types";
|
|
4
|
+
import type { ResolveSkillsFn } from "./agent-builder";
|
|
5
|
+
export interface BuildCustomAgentOptions {
|
|
6
|
+
resolveSkills?: ResolveSkillsFn;
|
|
7
|
+
disabledSkills?: Set<string>;
|
|
8
|
+
availableModels?: Set<string>;
|
|
9
|
+
systemDefaultModel?: string;
|
|
10
|
+
uiSelectedModel?: string;
|
|
11
|
+
/** Base directory for resolving relative prompt_file paths */
|
|
12
|
+
configDir?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Build an AgentConfig from a custom agent definition.
|
|
16
|
+
* Handles prompt resolution (inline, file, or skills), model resolution,
|
|
17
|
+
* and display name registration.
|
|
18
|
+
*/
|
|
19
|
+
export declare function buildCustomAgent(name: string, config: CustomAgentConfig, options?: BuildCustomAgentOptions): AgentConfig;
|
|
20
|
+
/**
|
|
21
|
+
* Build AgentPromptMetadata for a custom agent from its config.
|
|
22
|
+
* Used to integrate custom agents into Loom's delegation table.
|
|
23
|
+
*/
|
|
24
|
+
export declare function buildCustomAgentMetadata(name: string, config: CustomAgentConfig): AgentPromptMetadata;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AgentPromptMetadata } from "./types";
|
|
2
|
+
import type { ProjectFingerprint } from "../features/analytics/types";
|
|
2
3
|
export interface AvailableAgent {
|
|
3
4
|
name: string;
|
|
4
5
|
description: string;
|
|
@@ -27,3 +28,8 @@ export declare function buildWeftSection(agents: AvailableAgent[]): string;
|
|
|
27
28
|
export declare function buildWarpSection(agents: AvailableAgent[]): string;
|
|
28
29
|
export declare function buildDelegationTable(agents: AvailableAgent[]): string;
|
|
29
30
|
export declare function buildCategorySkillsDelegationGuide(categories: AvailableCategory[], skills: AvailableSkill[]): string;
|
|
31
|
+
/**
|
|
32
|
+
* Build a project context section from a codebase fingerprint.
|
|
33
|
+
* Returns an empty string if no fingerprint is available.
|
|
34
|
+
*/
|
|
35
|
+
export declare function buildProjectContextSection(fingerprint: ProjectFingerprint | null | undefined): string;
|
package/dist/agents/index.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
export { createBuiltinAgents, AGENT_METADATA } from "./builtin-agents";
|
|
1
|
+
export { createBuiltinAgents, AGENT_METADATA, registerCustomAgentMetadata, getAllAgentMetadata } from "./builtin-agents";
|
|
2
2
|
export type { CreateBuiltinAgentsOptions } from "./builtin-agents";
|
|
3
|
-
export { buildAgent } from "./agent-builder";
|
|
3
|
+
export { buildAgent, stripDisabledAgentReferences } from "./agent-builder";
|
|
4
4
|
export type { BuildAgentOptions, ResolveSkillsFn } from "./agent-builder";
|
|
5
5
|
export { resolveAgentModel, AGENT_MODEL_REQUIREMENTS } from "./model-resolution";
|
|
6
|
+
export type { FallbackEntry, AgentModelRequirement, ResolveAgentModelOptions } from "./model-resolution";
|
|
7
|
+
export { buildCustomAgent, buildCustomAgentMetadata } from "./custom-agent-factory";
|
|
8
|
+
export type { BuildCustomAgentOptions } from "./custom-agent-factory";
|
|
9
|
+
export { loadPromptFile } from "./prompt-loader";
|
|
6
10
|
export * from "./dynamic-prompt-builder";
|
|
7
11
|
export type { AgentMode, AgentFactory, AgentSource, AgentCategory, AgentCost, DelegationTrigger, AgentPromptMetadata, WeaveAgentName, } from "./types";
|
|
8
12
|
export { isFactory, isGptModel } from "./types";
|
|
@@ -1,2 +1,11 @@
|
|
|
1
|
+
import type { AgentConfig } from "@opencode-ai/sdk";
|
|
1
2
|
import type { AgentFactory } from "../types";
|
|
3
|
+
import type { AvailableAgent } from "../dynamic-prompt-builder";
|
|
4
|
+
import type { ProjectFingerprint } from "../../features/analytics/types";
|
|
5
|
+
export { composeLoomPrompt } from "./prompt-composer";
|
|
6
|
+
export type { LoomPromptOptions } from "./prompt-composer";
|
|
7
|
+
/**
|
|
8
|
+
* Create a Loom agent config with optional disabled agents, fingerprint, and custom agents for prompt composition.
|
|
9
|
+
*/
|
|
10
|
+
export declare function createLoomAgentWithOptions(model: string, disabledAgents?: Set<string>, fingerprint?: ProjectFingerprint | null, customAgents?: AvailableAgent[]): AgentConfig;
|
|
2
11
|
export declare const createLoomAgent: AgentFactory;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loom prompt composer — assembles the Loom system prompt from sections,
|
|
3
|
+
* conditionally including/excluding content based on enabled agents.
|
|
4
|
+
*
|
|
5
|
+
* Default behavior (no disabled agents) produces identical output to the
|
|
6
|
+
* hardcoded LOOM_DEFAULTS.prompt string.
|
|
7
|
+
*/
|
|
8
|
+
import type { ProjectFingerprint } from "../../features/analytics/types";
|
|
9
|
+
import type { AvailableAgent } from "../dynamic-prompt-builder";
|
|
10
|
+
export interface LoomPromptOptions {
|
|
11
|
+
/** Set of disabled agent names (lowercase config keys) */
|
|
12
|
+
disabledAgents?: Set<string>;
|
|
13
|
+
/** Project fingerprint for injecting project context into the prompt */
|
|
14
|
+
fingerprint?: ProjectFingerprint | null;
|
|
15
|
+
/** Custom agent metadata for dynamic delegation sections */
|
|
16
|
+
customAgents?: AvailableAgent[];
|
|
17
|
+
}
|
|
18
|
+
export declare function buildRoleSection(): string;
|
|
19
|
+
export declare function buildDisciplineSection(): string;
|
|
20
|
+
export declare function buildSidebarTodosSection(): string;
|
|
21
|
+
export declare function buildDelegationSection(disabled: Set<string>): string;
|
|
22
|
+
export declare function buildDelegationNarrationSection(disabled?: Set<string>): string;
|
|
23
|
+
export declare function buildPlanWorkflowSection(disabled: Set<string>): string;
|
|
24
|
+
export declare function buildReviewWorkflowSection(disabled: Set<string>): string;
|
|
25
|
+
export declare function buildStyleSection(): string;
|
|
26
|
+
/**
|
|
27
|
+
* Build a delegation section for custom agents.
|
|
28
|
+
* Returns empty string if no enabled custom agents exist.
|
|
29
|
+
*/
|
|
30
|
+
export declare function buildCustomAgentDelegationSection(customAgents: AvailableAgent[], disabled: Set<string>): string;
|
|
31
|
+
/**
|
|
32
|
+
* Compose the full Loom system prompt from sections.
|
|
33
|
+
* When no agents are disabled, produces identical output to LOOM_DEFAULTS.prompt.
|
|
34
|
+
*/
|
|
35
|
+
export declare function composeLoomPrompt(options?: LoomPromptOptions): string;
|
|
@@ -15,5 +15,13 @@ export type ResolveAgentModelOptions = {
|
|
|
15
15
|
categoryModel?: string;
|
|
16
16
|
overrideModel?: string;
|
|
17
17
|
systemDefaultModel?: string;
|
|
18
|
+
/** Custom fallback chain for agents not in AGENT_MODEL_REQUIREMENTS */
|
|
19
|
+
customFallbackChain?: FallbackEntry[];
|
|
18
20
|
};
|
|
19
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Resolve the model for an agent. Accepts any string agent name.
|
|
23
|
+
* Built-in agents use AGENT_MODEL_REQUIREMENTS for fallback chains.
|
|
24
|
+
* Custom agents use the customFallbackChain option, or fall through
|
|
25
|
+
* to system default / hardcoded fallback.
|
|
26
|
+
*/
|
|
27
|
+
export declare function resolveAgentModel(agentName: string, options: ResolveAgentModelOptions): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Load a prompt from a file path. Supports .md and .txt files.
|
|
3
|
+
* Paths are sandboxed to basePath (or cwd) — traversal outside is rejected.
|
|
4
|
+
*
|
|
5
|
+
* @param promptFilePath - Path to the prompt file (relative to basePath; absolute paths are rejected)
|
|
6
|
+
* @param basePath - Base directory for resolving relative paths (defaults to cwd)
|
|
7
|
+
* @returns The file contents as a string, or null if the file doesn't exist or path escapes the sandbox
|
|
8
|
+
*/
|
|
9
|
+
export declare function loadPromptFile(promptFilePath: string, basePath?: string): string | null;
|
|
@@ -1,2 +1,9 @@
|
|
|
1
|
+
import type { AgentConfig } from "@opencode-ai/sdk";
|
|
1
2
|
import type { AgentFactory } from "../types";
|
|
3
|
+
export { composeTapestryPrompt } from "./prompt-composer";
|
|
4
|
+
export type { TapestryPromptOptions } from "./prompt-composer";
|
|
5
|
+
/**
|
|
6
|
+
* Create a Tapestry agent config with optional disabled agents for prompt composition.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createTapestryAgentWithOptions(model: string, disabledAgents?: Set<string>): AgentConfig;
|
|
2
9
|
export declare const createTapestryAgent: AgentFactory;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tapestry prompt composer — assembles the Tapestry system prompt from sections,
|
|
3
|
+
* conditionally including/excluding content based on enabled agents.
|
|
4
|
+
*
|
|
5
|
+
* Default behavior (no disabled agents) produces identical output to the
|
|
6
|
+
* hardcoded TAPESTRY_DEFAULTS.prompt string.
|
|
7
|
+
*/
|
|
8
|
+
export interface TapestryPromptOptions {
|
|
9
|
+
/** Set of disabled agent names (lowercase config keys) */
|
|
10
|
+
disabledAgents?: Set<string>;
|
|
11
|
+
}
|
|
12
|
+
export declare function buildTapestryRoleSection(): string;
|
|
13
|
+
export declare function buildTapestryDisciplineSection(): string;
|
|
14
|
+
export declare function buildTapestrySidebarTodosSection(): string;
|
|
15
|
+
export declare function buildTapestryPlanExecutionSection(disabled?: Set<string>): string;
|
|
16
|
+
export declare function buildTapestryVerificationSection(): string;
|
|
17
|
+
export declare function buildTapestryPostExecutionReviewSection(disabled: Set<string>): string;
|
|
18
|
+
export declare function buildTapestryExecutionSection(): string;
|
|
19
|
+
export declare function buildTapestryStyleSection(): string;
|
|
20
|
+
/**
|
|
21
|
+
* Compose the full Tapestry system prompt from sections.
|
|
22
|
+
* When no agents are disabled, produces identical output to TAPESTRY_DEFAULTS.prompt.
|
|
23
|
+
*/
|
|
24
|
+
export declare function composeTapestryPrompt(options?: TapestryPromptOptions): string;
|
package/dist/config/schema.d.ts
CHANGED
|
@@ -83,6 +83,79 @@ export declare const ExperimentalConfigSchema: z.ZodObject<{
|
|
|
83
83
|
context_window_warning_threshold: z.ZodOptional<z.ZodNumber>;
|
|
84
84
|
context_window_critical_threshold: z.ZodOptional<z.ZodNumber>;
|
|
85
85
|
}, z.core.$strip>;
|
|
86
|
+
export declare const DelegationTriggerSchema: z.ZodObject<{
|
|
87
|
+
domain: z.ZodString;
|
|
88
|
+
trigger: z.ZodString;
|
|
89
|
+
}, z.core.$strip>;
|
|
90
|
+
export declare const CustomAgentConfigSchema: z.ZodObject<{
|
|
91
|
+
prompt: z.ZodOptional<z.ZodString>;
|
|
92
|
+
prompt_file: z.ZodOptional<z.ZodString>;
|
|
93
|
+
model: z.ZodOptional<z.ZodString>;
|
|
94
|
+
display_name: z.ZodOptional<z.ZodString>;
|
|
95
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
96
|
+
subagent: "subagent";
|
|
97
|
+
primary: "primary";
|
|
98
|
+
all: "all";
|
|
99
|
+
}>>;
|
|
100
|
+
fallback_models: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
101
|
+
category: z.ZodOptional<z.ZodEnum<{
|
|
102
|
+
exploration: "exploration";
|
|
103
|
+
specialist: "specialist";
|
|
104
|
+
advisor: "advisor";
|
|
105
|
+
utility: "utility";
|
|
106
|
+
}>>;
|
|
107
|
+
cost: z.ZodOptional<z.ZodEnum<{
|
|
108
|
+
FREE: "FREE";
|
|
109
|
+
CHEAP: "CHEAP";
|
|
110
|
+
EXPENSIVE: "EXPENSIVE";
|
|
111
|
+
}>>;
|
|
112
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
113
|
+
top_p: z.ZodOptional<z.ZodNumber>;
|
|
114
|
+
maxTokens: z.ZodOptional<z.ZodNumber>;
|
|
115
|
+
tools: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
|
|
116
|
+
skills: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
117
|
+
triggers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
118
|
+
domain: z.ZodString;
|
|
119
|
+
trigger: z.ZodString;
|
|
120
|
+
}, z.core.$strip>>>;
|
|
121
|
+
description: z.ZodOptional<z.ZodString>;
|
|
122
|
+
}, z.core.$strip>;
|
|
123
|
+
export declare const CustomAgentsConfigSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
124
|
+
prompt: z.ZodOptional<z.ZodString>;
|
|
125
|
+
prompt_file: z.ZodOptional<z.ZodString>;
|
|
126
|
+
model: z.ZodOptional<z.ZodString>;
|
|
127
|
+
display_name: z.ZodOptional<z.ZodString>;
|
|
128
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
129
|
+
subagent: "subagent";
|
|
130
|
+
primary: "primary";
|
|
131
|
+
all: "all";
|
|
132
|
+
}>>;
|
|
133
|
+
fallback_models: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
134
|
+
category: z.ZodOptional<z.ZodEnum<{
|
|
135
|
+
exploration: "exploration";
|
|
136
|
+
specialist: "specialist";
|
|
137
|
+
advisor: "advisor";
|
|
138
|
+
utility: "utility";
|
|
139
|
+
}>>;
|
|
140
|
+
cost: z.ZodOptional<z.ZodEnum<{
|
|
141
|
+
FREE: "FREE";
|
|
142
|
+
CHEAP: "CHEAP";
|
|
143
|
+
EXPENSIVE: "EXPENSIVE";
|
|
144
|
+
}>>;
|
|
145
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
146
|
+
top_p: z.ZodOptional<z.ZodNumber>;
|
|
147
|
+
maxTokens: z.ZodOptional<z.ZodNumber>;
|
|
148
|
+
tools: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
|
|
149
|
+
skills: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
150
|
+
triggers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
151
|
+
domain: z.ZodString;
|
|
152
|
+
trigger: z.ZodString;
|
|
153
|
+
}, z.core.$strip>>>;
|
|
154
|
+
description: z.ZodOptional<z.ZodString>;
|
|
155
|
+
}, z.core.$strip>>;
|
|
156
|
+
export declare const AnalyticsConfigSchema: z.ZodObject<{
|
|
157
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
158
|
+
}, z.core.$strip>;
|
|
86
159
|
export declare const WeaveConfigSchema: z.ZodObject<{
|
|
87
160
|
$schema: z.ZodOptional<z.ZodString>;
|
|
88
161
|
agents: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
@@ -104,6 +177,39 @@ export declare const WeaveConfigSchema: z.ZodObject<{
|
|
|
104
177
|
}>>;
|
|
105
178
|
maxTokens: z.ZodOptional<z.ZodNumber>;
|
|
106
179
|
}, z.core.$strip>>>;
|
|
180
|
+
custom_agents: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
181
|
+
prompt: z.ZodOptional<z.ZodString>;
|
|
182
|
+
prompt_file: z.ZodOptional<z.ZodString>;
|
|
183
|
+
model: z.ZodOptional<z.ZodString>;
|
|
184
|
+
display_name: z.ZodOptional<z.ZodString>;
|
|
185
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
186
|
+
subagent: "subagent";
|
|
187
|
+
primary: "primary";
|
|
188
|
+
all: "all";
|
|
189
|
+
}>>;
|
|
190
|
+
fallback_models: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
191
|
+
category: z.ZodOptional<z.ZodEnum<{
|
|
192
|
+
exploration: "exploration";
|
|
193
|
+
specialist: "specialist";
|
|
194
|
+
advisor: "advisor";
|
|
195
|
+
utility: "utility";
|
|
196
|
+
}>>;
|
|
197
|
+
cost: z.ZodOptional<z.ZodEnum<{
|
|
198
|
+
FREE: "FREE";
|
|
199
|
+
CHEAP: "CHEAP";
|
|
200
|
+
EXPENSIVE: "EXPENSIVE";
|
|
201
|
+
}>>;
|
|
202
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
203
|
+
top_p: z.ZodOptional<z.ZodNumber>;
|
|
204
|
+
maxTokens: z.ZodOptional<z.ZodNumber>;
|
|
205
|
+
tools: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
|
|
206
|
+
skills: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
207
|
+
triggers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
208
|
+
domain: z.ZodString;
|
|
209
|
+
trigger: z.ZodString;
|
|
210
|
+
}, z.core.$strip>>>;
|
|
211
|
+
description: z.ZodOptional<z.ZodString>;
|
|
212
|
+
}, z.core.$strip>>>;
|
|
107
213
|
categories: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
108
214
|
description: z.ZodOptional<z.ZodString>;
|
|
109
215
|
model: z.ZodOptional<z.ZodString>;
|
|
@@ -126,6 +232,9 @@ export declare const WeaveConfigSchema: z.ZodObject<{
|
|
|
126
232
|
modelConcurrency: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
127
233
|
staleTimeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
128
234
|
}, z.core.$strip>>;
|
|
235
|
+
analytics: z.ZodOptional<z.ZodObject<{
|
|
236
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
237
|
+
}, z.core.$strip>>;
|
|
129
238
|
tmux: z.ZodOptional<z.ZodObject<{
|
|
130
239
|
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
131
240
|
layout: z.ZodOptional<z.ZodEnum<{
|
|
@@ -145,9 +254,12 @@ export declare const WeaveConfigSchema: z.ZodObject<{
|
|
|
145
254
|
}, z.core.$strip>;
|
|
146
255
|
export type AgentOverrideConfig = z.infer<typeof AgentOverrideConfigSchema>;
|
|
147
256
|
export type AgentOverrides = z.infer<typeof AgentOverridesSchema>;
|
|
257
|
+
export type CustomAgentConfig = z.infer<typeof CustomAgentConfigSchema>;
|
|
258
|
+
export type CustomAgentsConfig = z.infer<typeof CustomAgentsConfigSchema>;
|
|
148
259
|
export type CategoryConfig = z.infer<typeof CategoryConfigSchema>;
|
|
149
260
|
export type CategoriesConfig = z.infer<typeof CategoriesConfigSchema>;
|
|
150
261
|
export type BackgroundConfig = z.infer<typeof BackgroundConfigSchema>;
|
|
262
|
+
export type AnalyticsConfig = z.infer<typeof AnalyticsConfigSchema>;
|
|
151
263
|
export type TmuxConfig = z.infer<typeof TmuxConfigSchema>;
|
|
152
264
|
export type ExperimentalConfig = z.infer<typeof ExperimentalConfigSchema>;
|
|
153
265
|
export type WeaveConfig = z.infer<typeof WeaveConfigSchema>;
|
|
@@ -2,6 +2,7 @@ import type { PluginInput } from "@opencode-ai/plugin";
|
|
|
2
2
|
import type { AgentConfig } from "@opencode-ai/sdk";
|
|
3
3
|
import type { WeaveConfig } from "./config/schema";
|
|
4
4
|
import type { ResolveSkillsFn } from "./agents/agent-builder";
|
|
5
|
+
import type { ProjectFingerprint } from "./features/analytics/types";
|
|
5
6
|
import { ConfigHandler } from "./managers/config-handler";
|
|
6
7
|
import { BackgroundManager } from "./managers/background-manager";
|
|
7
8
|
import { SkillMcpManager } from "./managers/skill-mcp-manager";
|
|
@@ -15,4 +16,6 @@ export declare function createManagers(options: {
|
|
|
15
16
|
ctx: PluginInput;
|
|
16
17
|
pluginConfig: WeaveConfig;
|
|
17
18
|
resolveSkills?: ResolveSkillsFn;
|
|
19
|
+
fingerprint?: ProjectFingerprint | null;
|
|
20
|
+
configDir?: string;
|
|
18
21
|
}): WeaveManagers;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ProjectFingerprint, DetectedStack } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Detect the technology stack of a project by scanning for marker files.
|
|
4
|
+
* This is a fast, synchronous scan — suitable for fire-and-forget use.
|
|
5
|
+
*/
|
|
6
|
+
export declare function detectStack(directory: string): DetectedStack[];
|
|
7
|
+
/**
|
|
8
|
+
* Detect the package manager used by the project.
|
|
9
|
+
*/
|
|
10
|
+
export declare function detectPackageManager(directory: string): string | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Detect whether the project is a monorepo.
|
|
13
|
+
*/
|
|
14
|
+
export declare function detectMonorepo(directory: string): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Detect the primary language of the project.
|
|
17
|
+
*/
|
|
18
|
+
export declare function detectPrimaryLanguage(stack: DetectedStack[]): string | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Generate a complete project fingerprint.
|
|
21
|
+
*/
|
|
22
|
+
export declare function generateFingerprint(directory: string): ProjectFingerprint;
|
|
23
|
+
/**
|
|
24
|
+
* Generate and persist a project fingerprint.
|
|
25
|
+
* Fire-and-forget: errors are logged but never thrown.
|
|
26
|
+
*/
|
|
27
|
+
export declare function fingerprintProject(directory: string): ProjectFingerprint | null;
|
|
28
|
+
/**
|
|
29
|
+
* Get the cached fingerprint, or generate a new one if missing.
|
|
30
|
+
* Fire-and-forget: errors are logged but never thrown.
|
|
31
|
+
*/
|
|
32
|
+
export declare function getOrCreateFingerprint(directory: string): ProjectFingerprint | null;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type { ToolUsageEntry, DelegationEntry, SessionSummary, DetectedStack, ProjectFingerprint, Suggestion, InFlightToolCall, TrackedSession, } from "./types";
|
|
2
|
+
export { ANALYTICS_DIR, SESSION_SUMMARIES_FILE, FINGERPRINT_FILE } from "./types";
|
|
3
|
+
export { ensureAnalyticsDir, appendSessionSummary, readSessionSummaries, writeFingerprint, readFingerprint, } from "./storage";
|
|
4
|
+
export { detectStack, detectPackageManager, detectMonorepo, detectPrimaryLanguage, generateFingerprint, fingerprintProject, getOrCreateFingerprint, } from "./fingerprint";
|
|
5
|
+
export { SessionTracker, createSessionTracker } from "./session-tracker";
|
|
6
|
+
export { generateSuggestions, getSuggestionsForProject } from "./suggestions";
|
|
7
|
+
import type { SessionTracker } from "./session-tracker";
|
|
8
|
+
import type { ProjectFingerprint } from "./types";
|
|
9
|
+
/** Return value of createAnalytics — bundles tracker + fingerprint */
|
|
10
|
+
export interface Analytics {
|
|
11
|
+
/** Session tracker instance — wire into tool.execute.before/after */
|
|
12
|
+
tracker: SessionTracker;
|
|
13
|
+
/** Project fingerprint (may be null if detection fails) */
|
|
14
|
+
fingerprint: ProjectFingerprint | null;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Create all analytics services for a project.
|
|
18
|
+
* Instantiates the session tracker and optionally generates/loads the project fingerprint.
|
|
19
|
+
* If a fingerprint is provided, it is reused; otherwise one is generated.
|
|
20
|
+
* This is the single entry point called from the plugin's main init.
|
|
21
|
+
*/
|
|
22
|
+
export declare function createAnalytics(directory: string, fingerprint?: ProjectFingerprint | null): Analytics;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { TrackedSession, SessionSummary } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* SessionTracker tracks tool usage and delegations across sessions,
|
|
4
|
+
* producing SessionSummary records when sessions end.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* - Call `startSession()` when a session begins (or lazily on first tool call)
|
|
8
|
+
* - Call `trackToolStart()` / `trackToolEnd()` on tool.execute.before/after
|
|
9
|
+
* - Call `endSession()` when the session ends → writes summary to JSONL
|
|
10
|
+
*/
|
|
11
|
+
export declare class SessionTracker {
|
|
12
|
+
private sessions;
|
|
13
|
+
private directory;
|
|
14
|
+
constructor(directory: string);
|
|
15
|
+
/**
|
|
16
|
+
* Start tracking a session. Idempotent — if already tracking, returns existing.
|
|
17
|
+
*/
|
|
18
|
+
startSession(sessionId: string): TrackedSession;
|
|
19
|
+
/**
|
|
20
|
+
* Track a tool execution start. Lazily starts the session if needed.
|
|
21
|
+
*/
|
|
22
|
+
trackToolStart(sessionId: string, toolName: string, callId: string, agent?: string): void;
|
|
23
|
+
/**
|
|
24
|
+
* Track a tool execution end. Records delegation if it was a task tool.
|
|
25
|
+
*/
|
|
26
|
+
trackToolEnd(sessionId: string, toolName: string, callId: string, agent?: string): void;
|
|
27
|
+
/**
|
|
28
|
+
* End a session and persist the summary. Removes the session from tracking.
|
|
29
|
+
* Returns the generated summary, or null if the session wasn't being tracked.
|
|
30
|
+
*/
|
|
31
|
+
endSession(sessionId: string): SessionSummary | null;
|
|
32
|
+
/**
|
|
33
|
+
* Check if a session is currently being tracked.
|
|
34
|
+
*/
|
|
35
|
+
isTracking(sessionId: string): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Get the current tracked session data (for inspection/testing).
|
|
38
|
+
*/
|
|
39
|
+
getSession(sessionId: string): TrackedSession | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Get the number of sessions currently being tracked.
|
|
42
|
+
*/
|
|
43
|
+
get activeSessionCount(): number;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Create a new SessionTracker instance.
|
|
47
|
+
*/
|
|
48
|
+
export declare function createSessionTracker(directory: string): SessionTracker;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { SessionSummary, ProjectFingerprint } from "./types";
|
|
2
|
+
/** Maximum number of session summary entries to keep in the JSONL file */
|
|
3
|
+
export declare const MAX_SESSION_ENTRIES = 1000;
|
|
4
|
+
/**
|
|
5
|
+
* Ensure the analytics directory exists, creating it if needed.
|
|
6
|
+
* Returns the absolute path to the analytics directory.
|
|
7
|
+
*/
|
|
8
|
+
export declare function ensureAnalyticsDir(directory: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* Append a session summary to the JSONL file.
|
|
11
|
+
* Auto-creates the analytics directory if needed.
|
|
12
|
+
*/
|
|
13
|
+
export declare function appendSessionSummary(directory: string, summary: SessionSummary): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Read all session summaries from the JSONL file.
|
|
16
|
+
* Returns an empty array if the file doesn't exist or is unparseable.
|
|
17
|
+
*/
|
|
18
|
+
export declare function readSessionSummaries(directory: string): SessionSummary[];
|
|
19
|
+
/**
|
|
20
|
+
* Write a project fingerprint to the analytics directory.
|
|
21
|
+
* Auto-creates the analytics directory if needed.
|
|
22
|
+
*/
|
|
23
|
+
export declare function writeFingerprint(directory: string, fingerprint: ProjectFingerprint): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Read the project fingerprint from the analytics directory.
|
|
26
|
+
* Returns null if the file doesn't exist or is unparseable.
|
|
27
|
+
*/
|
|
28
|
+
export declare function readFingerprint(directory: string): ProjectFingerprint | null;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { SessionSummary, Suggestion } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Generate suggestions based on session history.
|
|
4
|
+
* Analyzes tool usage patterns, delegation frequency, and workflow patterns.
|
|
5
|
+
*/
|
|
6
|
+
export declare function generateSuggestions(summaries: SessionSummary[]): Suggestion[];
|
|
7
|
+
/**
|
|
8
|
+
* Generate suggestions from stored session summaries for a project.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getSuggestionsForProject(directory: string): Suggestion[];
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Analytics types for session intelligence and learning.
|
|
3
|
+
* All analytics data is stored under `.weave/analytics/`.
|
|
4
|
+
*/
|
|
5
|
+
/** Directory where analytics data is stored (relative to project root) */
|
|
6
|
+
export declare const ANALYTICS_DIR = ".weave/analytics";
|
|
7
|
+
/** File name for session summaries (JSONL format) */
|
|
8
|
+
export declare const SESSION_SUMMARIES_FILE = "session-summaries.jsonl";
|
|
9
|
+
/** File name for project fingerprint */
|
|
10
|
+
export declare const FINGERPRINT_FILE = "fingerprint.json";
|
|
11
|
+
/** A single tool invocation recorded during a session */
|
|
12
|
+
export interface ToolUsageEntry {
|
|
13
|
+
/** Tool name (e.g., "read", "write", "task") */
|
|
14
|
+
tool: string;
|
|
15
|
+
/** Number of times this tool was invoked */
|
|
16
|
+
count: number;
|
|
17
|
+
}
|
|
18
|
+
/** A delegation to a sub-agent recorded during a session */
|
|
19
|
+
export interface DelegationEntry {
|
|
20
|
+
/** Sub-agent type (e.g., "thread", "pattern", "weft") */
|
|
21
|
+
agent: string;
|
|
22
|
+
/** Tool call ID that started this delegation */
|
|
23
|
+
toolCallId: string;
|
|
24
|
+
/** Duration in milliseconds (if completed) */
|
|
25
|
+
durationMs?: number;
|
|
26
|
+
}
|
|
27
|
+
/** Summary of a completed session, appended as a JSONL line */
|
|
28
|
+
export interface SessionSummary {
|
|
29
|
+
/** Unique session identifier */
|
|
30
|
+
sessionId: string;
|
|
31
|
+
/** ISO timestamp when session started */
|
|
32
|
+
startedAt: string;
|
|
33
|
+
/** ISO timestamp when session ended */
|
|
34
|
+
endedAt: string;
|
|
35
|
+
/** Duration in milliseconds */
|
|
36
|
+
durationMs: number;
|
|
37
|
+
/** Tools used during the session */
|
|
38
|
+
toolUsage: ToolUsageEntry[];
|
|
39
|
+
/** Delegations made during the session */
|
|
40
|
+
delegations: DelegationEntry[];
|
|
41
|
+
/** Total number of tool calls */
|
|
42
|
+
totalToolCalls: number;
|
|
43
|
+
/** Total number of delegations */
|
|
44
|
+
totalDelegations: number;
|
|
45
|
+
}
|
|
46
|
+
/** Detected language/framework in the project */
|
|
47
|
+
export interface DetectedStack {
|
|
48
|
+
/** Language or framework name (e.g., "typescript", "react", "bun") */
|
|
49
|
+
name: string;
|
|
50
|
+
/** Detection confidence: "high" if found in lockfile/config, "medium" for deps */
|
|
51
|
+
confidence: "high" | "medium";
|
|
52
|
+
/** Evidence for detection (e.g., "tsconfig.json exists") */
|
|
53
|
+
evidence: string;
|
|
54
|
+
}
|
|
55
|
+
/** Project fingerprint — captures the tech stack and structure */
|
|
56
|
+
export interface ProjectFingerprint {
|
|
57
|
+
/** ISO timestamp when fingerprint was generated */
|
|
58
|
+
generatedAt: string;
|
|
59
|
+
/** Detected technology stack entries */
|
|
60
|
+
stack: DetectedStack[];
|
|
61
|
+
/** Whether a monorepo structure was detected */
|
|
62
|
+
isMonorepo: boolean;
|
|
63
|
+
/** Package manager detected (e.g., "bun", "npm", "yarn", "pnpm") */
|
|
64
|
+
packageManager?: string;
|
|
65
|
+
/** Primary language detected */
|
|
66
|
+
primaryLanguage?: string;
|
|
67
|
+
/** Operating system (e.g., "darwin", "win32", "linux") */
|
|
68
|
+
os?: string;
|
|
69
|
+
/** CPU architecture (e.g., "arm64", "x64") */
|
|
70
|
+
arch?: string;
|
|
71
|
+
}
|
|
72
|
+
/** A suggestion generated from session analytics */
|
|
73
|
+
export interface Suggestion {
|
|
74
|
+
/** Unique identifier for deduplication */
|
|
75
|
+
id: string;
|
|
76
|
+
/** Human-readable suggestion text */
|
|
77
|
+
text: string;
|
|
78
|
+
/** Category of suggestion */
|
|
79
|
+
category: "tool-usage" | "delegation" | "workflow";
|
|
80
|
+
/** Confidence level */
|
|
81
|
+
confidence: "high" | "medium" | "low";
|
|
82
|
+
}
|
|
83
|
+
/** Tracks in-flight tool calls for duration measurement */
|
|
84
|
+
export interface InFlightToolCall {
|
|
85
|
+
/** Tool name */
|
|
86
|
+
tool: string;
|
|
87
|
+
/** Start timestamp (ms since epoch) */
|
|
88
|
+
startedAt: number;
|
|
89
|
+
/** Sub-agent type if this is a task delegation */
|
|
90
|
+
agent?: string;
|
|
91
|
+
}
|
|
92
|
+
/** Active session being tracked */
|
|
93
|
+
export interface TrackedSession {
|
|
94
|
+
/** Session ID */
|
|
95
|
+
sessionId: string;
|
|
96
|
+
/** ISO timestamp when tracking started */
|
|
97
|
+
startedAt: string;
|
|
98
|
+
/** Tool usage counts keyed by tool name */
|
|
99
|
+
toolCounts: Record<string, number>;
|
|
100
|
+
/** Completed delegations */
|
|
101
|
+
delegations: DelegationEntry[];
|
|
102
|
+
/** In-flight tool calls keyed by callID */
|
|
103
|
+
inFlight: Record<string, InFlightToolCall>;
|
|
104
|
+
}
|