@fabriccode/weave 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +309 -0
  3. package/dist/agents/agent-builder.d.ts +24 -0
  4. package/dist/agents/builtin-agents.d.ts +32 -0
  5. package/dist/agents/custom-agent-factory.d.ts +24 -0
  6. package/dist/agents/dynamic-prompt-builder.d.ts +35 -0
  7. package/dist/agents/index.d.ts +12 -0
  8. package/dist/agents/loom/default.d.ts +2 -0
  9. package/dist/agents/loom/index.d.ts +11 -0
  10. package/dist/agents/loom/prompt-composer.d.ts +35 -0
  11. package/dist/agents/model-resolution.d.ts +27 -0
  12. package/dist/agents/pattern/default.d.ts +2 -0
  13. package/dist/agents/pattern/index.d.ts +2 -0
  14. package/dist/agents/prompt-loader.d.ts +9 -0
  15. package/dist/agents/prompt-utils.d.ts +2 -0
  16. package/dist/agents/shuttle/default.d.ts +2 -0
  17. package/dist/agents/shuttle/index.d.ts +2 -0
  18. package/dist/agents/spindle/default.d.ts +2 -0
  19. package/dist/agents/spindle/index.d.ts +2 -0
  20. package/dist/agents/tapestry/default.d.ts +2 -0
  21. package/dist/agents/tapestry/index.d.ts +9 -0
  22. package/dist/agents/tapestry/prompt-composer.d.ts +24 -0
  23. package/dist/agents/thread/default.d.ts +2 -0
  24. package/dist/agents/thread/index.d.ts +2 -0
  25. package/dist/agents/types.d.ts +82 -0
  26. package/dist/agents/warp/default.d.ts +2 -0
  27. package/dist/agents/warp/index.d.ts +2 -0
  28. package/dist/agents/weft/default.d.ts +2 -0
  29. package/dist/agents/weft/index.d.ts +2 -0
  30. package/dist/config/index.d.ts +3 -0
  31. package/dist/config/loader.d.ts +2 -0
  32. package/dist/config/merge.d.ts +3 -0
  33. package/dist/config/schema.d.ts +274 -0
  34. package/dist/create-managers.d.ts +21 -0
  35. package/dist/create-tools.d.ts +16 -0
  36. package/dist/features/analytics/adherence.d.ts +10 -0
  37. package/dist/features/analytics/fingerprint.d.ts +33 -0
  38. package/dist/features/analytics/format-metrics.d.ts +10 -0
  39. package/dist/features/analytics/generate-metrics-report.d.ts +17 -0
  40. package/dist/features/analytics/git-diff.d.ts +7 -0
  41. package/dist/features/analytics/index.d.ts +29 -0
  42. package/dist/features/analytics/plan-parser.d.ts +7 -0
  43. package/dist/features/analytics/plan-token-aggregator.d.ts +11 -0
  44. package/dist/features/analytics/session-tracker.d.ts +68 -0
  45. package/dist/features/analytics/storage.d.ts +40 -0
  46. package/dist/features/analytics/suggestions.d.ts +10 -0
  47. package/dist/features/analytics/token-report.d.ts +14 -0
  48. package/dist/features/analytics/types.d.ts +194 -0
  49. package/dist/features/builtin-commands/commands.d.ts +2 -0
  50. package/dist/features/builtin-commands/index.d.ts +2 -0
  51. package/dist/features/builtin-commands/templates/metrics.d.ts +1 -0
  52. package/dist/features/builtin-commands/templates/run-workflow.d.ts +1 -0
  53. package/dist/features/builtin-commands/templates/start-work.d.ts +1 -0
  54. package/dist/features/builtin-commands/types.d.ts +16 -0
  55. package/dist/features/evals/baseline.d.ts +4 -0
  56. package/dist/features/evals/evaluators/deterministic.d.ts +2 -0
  57. package/dist/features/evals/evaluators/llm-judge.d.ts +2 -0
  58. package/dist/features/evals/executors/model-response.d.ts +2 -0
  59. package/dist/features/evals/executors/prompt-renderer.d.ts +2 -0
  60. package/dist/features/evals/index.d.ts +24 -0
  61. package/dist/features/evals/loader.d.ts +8 -0
  62. package/dist/features/evals/reporter.d.ts +2 -0
  63. package/dist/features/evals/runner.d.ts +7 -0
  64. package/dist/features/evals/schema.d.ts +478 -0
  65. package/dist/features/evals/storage.d.ts +7 -0
  66. package/dist/features/evals/targets/builtin-agent-target.d.ts +2 -0
  67. package/dist/features/evals/types.d.ts +223 -0
  68. package/dist/features/skill-loader/discovery.d.ts +12 -0
  69. package/dist/features/skill-loader/fabric-client.d.ts +2 -0
  70. package/dist/features/skill-loader/index.d.ts +6 -0
  71. package/dist/features/skill-loader/loader.d.ts +7 -0
  72. package/dist/features/skill-loader/resolver.d.ts +6 -0
  73. package/dist/features/skill-loader/types.d.ts +18 -0
  74. package/dist/features/work-state/constants.d.ts +8 -0
  75. package/dist/features/work-state/index.d.ts +5 -0
  76. package/dist/features/work-state/storage.d.ts +53 -0
  77. package/dist/features/work-state/types.d.ts +35 -0
  78. package/dist/features/work-state/validation-types.d.ts +26 -0
  79. package/dist/features/work-state/validation.d.ts +9 -0
  80. package/dist/features/workflow/commands.d.ts +17 -0
  81. package/dist/features/workflow/completion.d.ts +31 -0
  82. package/dist/features/workflow/constants.d.ts +12 -0
  83. package/dist/features/workflow/context.d.ts +16 -0
  84. package/dist/features/workflow/discovery.d.ts +19 -0
  85. package/dist/features/workflow/engine.d.ts +49 -0
  86. package/dist/features/workflow/hook.d.ts +47 -0
  87. package/dist/features/workflow/index.d.ts +15 -0
  88. package/dist/features/workflow/schema.d.ts +118 -0
  89. package/dist/features/workflow/storage.d.ts +51 -0
  90. package/dist/features/workflow/types.d.ts +142 -0
  91. package/dist/hooks/context-window-monitor.d.ts +19 -0
  92. package/dist/hooks/create-hooks.d.ts +40 -0
  93. package/dist/hooks/first-message-variant.d.ts +5 -0
  94. package/dist/hooks/index.d.ts +14 -0
  95. package/dist/hooks/keyword-detector.d.ts +8 -0
  96. package/dist/hooks/pattern-md-only.d.ts +13 -0
  97. package/dist/hooks/rules-injector.d.ts +6 -0
  98. package/dist/hooks/session-token-state.d.ts +42 -0
  99. package/dist/hooks/start-work-hook.d.ts +25 -0
  100. package/dist/hooks/verification-reminder.d.ts +22 -0
  101. package/dist/hooks/work-continuation.d.ts +26 -0
  102. package/dist/hooks/write-existing-file-guard.d.ts +14 -0
  103. package/dist/index.d.ts +5 -0
  104. package/dist/index.js +5585 -0
  105. package/dist/managers/background-manager.d.ts +88 -0
  106. package/dist/managers/config-handler.d.ts +54 -0
  107. package/dist/managers/index.d.ts +6 -0
  108. package/dist/managers/skill-mcp-manager.d.ts +30 -0
  109. package/dist/plugin/index.d.ts +1 -0
  110. package/dist/plugin/plugin-interface.d.ts +17 -0
  111. package/dist/plugin/types.d.ts +5 -0
  112. package/dist/shared/agent-display-names.d.ts +31 -0
  113. package/dist/shared/index.d.ts +5 -0
  114. package/dist/shared/log.d.ts +11 -0
  115. package/dist/shared/types.d.ts +6 -0
  116. package/dist/shared/version.d.ts +5 -0
  117. package/dist/tools/index.d.ts +4 -0
  118. package/dist/tools/permissions.d.ts +18 -0
  119. package/dist/tools/registry.d.ts +29 -0
  120. package/package.json +55 -0
@@ -0,0 +1,82 @@
1
+ import type { AgentConfig } from "@fabriccode/sdk";
2
+ /**
3
+ * Agent mode determines UI model selection behavior:
4
+ * - "primary": Respects user's UI-selected model (loom, tapestry)
5
+ * - "subagent": Uses own fallback chain, ignores UI selection (pattern, thread, spindle)
6
+ * - "all": Available in both contexts (shuttle)
7
+ */
8
+ export type AgentMode = "primary" | "subagent" | "all";
9
+ /**
10
+ * Agent factory function with static mode property.
11
+ * Mode is exposed as static property for pre-instantiation access.
12
+ */
13
+ export type AgentFactory = ((model: string) => AgentConfig) & {
14
+ mode: AgentMode;
15
+ };
16
+ /**
17
+ * Agent source is either a factory (called with model) or a static config (cloned)
18
+ */
19
+ export type AgentSource = AgentFactory | AgentConfig;
20
+ /**
21
+ * Agent category for grouping in Loom prompt sections
22
+ */
23
+ export type AgentCategory = "exploration" | "specialist" | "advisor" | "utility";
24
+ /**
25
+ * Cost classification for Tool Selection table
26
+ */
27
+ export type AgentCost = "FREE" | "CHEAP" | "EXPENSIVE";
28
+ /**
29
+ * Delegation trigger for Loom prompt's Delegation Table
30
+ */
31
+ export interface DelegationTrigger {
32
+ /** Domain of work (e.g., "Frontend UI/UX") */
33
+ domain: string;
34
+ /** When to delegate (e.g., "Visual changes only...") */
35
+ trigger: string;
36
+ }
37
+ /**
38
+ * Metadata for generating Loom prompt sections dynamically.
39
+ * Allows adding/removing agents without manually updating the Loom prompt.
40
+ */
41
+ export interface AgentPromptMetadata {
42
+ /** Category for grouping in prompt sections */
43
+ category: AgentCategory;
44
+ /** Cost classification for Tool Selection table */
45
+ cost: AgentCost;
46
+ /** Domain triggers for Delegation Table */
47
+ triggers: DelegationTrigger[];
48
+ /** When to use this agent (for detailed sections) */
49
+ useWhen?: string[];
50
+ /** When NOT to use this agent */
51
+ avoidWhen?: string[];
52
+ /** Optional dedicated prompt section (markdown) */
53
+ dedicatedSection?: string;
54
+ /** Nickname/alias used in prompt (e.g., "Pattern" instead of "pattern") */
55
+ promptAlias?: string;
56
+ /** Key trigger that should appear in Phase 0 quick checks */
57
+ keyTrigger?: string;
58
+ }
59
+ /**
60
+ * The 8 built-in Weave agent names
61
+ */
62
+ export type WeaveAgentName = "loom" | "tapestry" | "shuttle" | "pattern" | "thread" | "spindle" | "weft" | "warp";
63
+ /**
64
+ * Override config for a single agent — all fields optional
65
+ */
66
+ export type AgentOverrideConfig = Partial<AgentConfig> & {
67
+ prompt_append?: string;
68
+ variant?: string;
69
+ fallback_models?: string | string[];
70
+ };
71
+ /**
72
+ * Map of agent name to override config
73
+ */
74
+ export type AgentOverrides = Partial<Record<WeaveAgentName, AgentOverrideConfig>>;
75
+ /**
76
+ * Returns true if the model string identifies a GPT/OpenAI model.
77
+ */
78
+ export declare function isGptModel(model: string): boolean;
79
+ /**
80
+ * Type guard: returns true if source is an AgentFactory (callable with .mode).
81
+ */
82
+ export declare function isFactory(source: AgentSource): source is AgentFactory;
@@ -0,0 +1,2 @@
1
+ import type { AgentConfig } from "@fabriccode/sdk";
2
+ export declare const WARP_DEFAULTS: AgentConfig;
@@ -0,0 +1,2 @@
1
+ import type { AgentFactory } from "../types";
2
+ export declare const createWarpAgent: AgentFactory;
@@ -0,0 +1,2 @@
1
+ import type { AgentConfig } from "@fabriccode/sdk";
2
+ export declare const WEFT_DEFAULTS: AgentConfig;
@@ -0,0 +1,2 @@
1
+ import type { AgentFactory } from "../types";
2
+ export declare const createWeftAgent: AgentFactory;
@@ -0,0 +1,3 @@
1
+ export * from "./schema";
2
+ export { loadWeaveConfig } from "./loader";
3
+ export { mergeConfigs } from "./merge";
@@ -0,0 +1,2 @@
1
+ import { type WeaveConfig } from "./schema";
2
+ export declare function loadWeaveConfig(directory: string, _ctx?: unknown, _homeDir?: string): WeaveConfig;
@@ -0,0 +1,3 @@
1
+ import type { WeaveConfig } from "./schema";
2
+ import type { DeepPartial } from "../shared/types";
3
+ export declare function mergeConfigs(user: DeepPartial<WeaveConfig>, project: DeepPartial<WeaveConfig>): DeepPartial<WeaveConfig>;
@@ -0,0 +1,274 @@
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 ExperimentalConfigSchema: z.ZodObject<{
82
+ plugin_load_timeout_ms: z.ZodOptional<z.ZodNumber>;
83
+ context_window_warning_threshold: z.ZodOptional<z.ZodNumber>;
84
+ context_window_critical_threshold: z.ZodOptional<z.ZodNumber>;
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
+ use_fingerprint: z.ZodOptional<z.ZodBoolean>;
159
+ }, z.core.$strip>;
160
+ export declare const WorkflowConfigSchema: z.ZodObject<{
161
+ disabled_workflows: z.ZodOptional<z.ZodArray<z.ZodString>>;
162
+ }, z.core.$strip>;
163
+ export declare const WeaveConfigSchema: z.ZodObject<{
164
+ $schema: z.ZodOptional<z.ZodString>;
165
+ agents: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
166
+ model: z.ZodOptional<z.ZodString>;
167
+ fallback_models: z.ZodOptional<z.ZodArray<z.ZodString>>;
168
+ variant: z.ZodOptional<z.ZodString>;
169
+ category: z.ZodOptional<z.ZodString>;
170
+ skills: z.ZodOptional<z.ZodArray<z.ZodString>>;
171
+ temperature: z.ZodOptional<z.ZodNumber>;
172
+ top_p: z.ZodOptional<z.ZodNumber>;
173
+ prompt: z.ZodOptional<z.ZodString>;
174
+ prompt_append: z.ZodOptional<z.ZodString>;
175
+ tools: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
176
+ disable: z.ZodOptional<z.ZodBoolean>;
177
+ mode: z.ZodOptional<z.ZodEnum<{
178
+ subagent: "subagent";
179
+ primary: "primary";
180
+ all: "all";
181
+ }>>;
182
+ maxTokens: z.ZodOptional<z.ZodNumber>;
183
+ }, z.core.$strip>>>;
184
+ custom_agents: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
185
+ prompt: z.ZodOptional<z.ZodString>;
186
+ prompt_file: z.ZodOptional<z.ZodString>;
187
+ model: z.ZodOptional<z.ZodString>;
188
+ display_name: z.ZodOptional<z.ZodString>;
189
+ mode: z.ZodOptional<z.ZodEnum<{
190
+ subagent: "subagent";
191
+ primary: "primary";
192
+ all: "all";
193
+ }>>;
194
+ fallback_models: z.ZodOptional<z.ZodArray<z.ZodString>>;
195
+ category: z.ZodOptional<z.ZodEnum<{
196
+ exploration: "exploration";
197
+ specialist: "specialist";
198
+ advisor: "advisor";
199
+ utility: "utility";
200
+ }>>;
201
+ cost: z.ZodOptional<z.ZodEnum<{
202
+ FREE: "FREE";
203
+ CHEAP: "CHEAP";
204
+ EXPENSIVE: "EXPENSIVE";
205
+ }>>;
206
+ temperature: z.ZodOptional<z.ZodNumber>;
207
+ top_p: z.ZodOptional<z.ZodNumber>;
208
+ maxTokens: z.ZodOptional<z.ZodNumber>;
209
+ tools: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
210
+ skills: z.ZodOptional<z.ZodArray<z.ZodString>>;
211
+ triggers: z.ZodOptional<z.ZodArray<z.ZodObject<{
212
+ domain: z.ZodString;
213
+ trigger: z.ZodString;
214
+ }, z.core.$strip>>>;
215
+ description: z.ZodOptional<z.ZodString>;
216
+ }, z.core.$strip>>>;
217
+ categories: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
218
+ description: z.ZodOptional<z.ZodString>;
219
+ model: z.ZodOptional<z.ZodString>;
220
+ fallback_models: z.ZodOptional<z.ZodArray<z.ZodString>>;
221
+ variant: z.ZodOptional<z.ZodString>;
222
+ temperature: z.ZodOptional<z.ZodNumber>;
223
+ top_p: z.ZodOptional<z.ZodNumber>;
224
+ maxTokens: z.ZodOptional<z.ZodNumber>;
225
+ tools: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
226
+ prompt_append: z.ZodOptional<z.ZodString>;
227
+ disable: z.ZodOptional<z.ZodBoolean>;
228
+ }, z.core.$strip>>>;
229
+ disabled_hooks: z.ZodOptional<z.ZodArray<z.ZodString>>;
230
+ disabled_tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
231
+ disabled_agents: z.ZodOptional<z.ZodArray<z.ZodString>>;
232
+ disabled_skills: z.ZodOptional<z.ZodArray<z.ZodString>>;
233
+ background: z.ZodOptional<z.ZodObject<{
234
+ defaultConcurrency: z.ZodOptional<z.ZodNumber>;
235
+ providerConcurrency: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
236
+ modelConcurrency: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
237
+ staleTimeoutMs: z.ZodOptional<z.ZodNumber>;
238
+ }, z.core.$strip>>;
239
+ analytics: z.ZodOptional<z.ZodObject<{
240
+ enabled: z.ZodOptional<z.ZodBoolean>;
241
+ use_fingerprint: z.ZodOptional<z.ZodBoolean>;
242
+ }, z.core.$strip>>;
243
+ tmux: z.ZodOptional<z.ZodObject<{
244
+ enabled: z.ZodOptional<z.ZodBoolean>;
245
+ layout: z.ZodOptional<z.ZodEnum<{
246
+ "main-horizontal": "main-horizontal";
247
+ "main-vertical": "main-vertical";
248
+ tiled: "tiled";
249
+ "even-horizontal": "even-horizontal";
250
+ "even-vertical": "even-vertical";
251
+ }>>;
252
+ main_pane_size: z.ZodOptional<z.ZodNumber>;
253
+ }, z.core.$strip>>;
254
+ experimental: z.ZodOptional<z.ZodObject<{
255
+ plugin_load_timeout_ms: z.ZodOptional<z.ZodNumber>;
256
+ context_window_warning_threshold: z.ZodOptional<z.ZodNumber>;
257
+ context_window_critical_threshold: z.ZodOptional<z.ZodNumber>;
258
+ }, z.core.$strip>>;
259
+ workflows: z.ZodOptional<z.ZodObject<{
260
+ disabled_workflows: z.ZodOptional<z.ZodArray<z.ZodString>>;
261
+ }, z.core.$strip>>;
262
+ }, z.core.$strip>;
263
+ export type AgentOverrideConfig = z.infer<typeof AgentOverrideConfigSchema>;
264
+ export type AgentOverrides = z.infer<typeof AgentOverridesSchema>;
265
+ export type CustomAgentConfig = z.infer<typeof CustomAgentConfigSchema>;
266
+ export type CustomAgentsConfig = z.infer<typeof CustomAgentsConfigSchema>;
267
+ export type CategoryConfig = z.infer<typeof CategoryConfigSchema>;
268
+ export type CategoriesConfig = z.infer<typeof CategoriesConfigSchema>;
269
+ export type BackgroundConfig = z.infer<typeof BackgroundConfigSchema>;
270
+ export type AnalyticsConfig = z.infer<typeof AnalyticsConfigSchema>;
271
+ export type TmuxConfig = z.infer<typeof TmuxConfigSchema>;
272
+ export type ExperimentalConfig = z.infer<typeof ExperimentalConfigSchema>;
273
+ export type WorkflowConfig = z.infer<typeof WorkflowConfigSchema>;
274
+ export type WeaveConfig = z.infer<typeof WeaveConfigSchema>;
@@ -0,0 +1,21 @@
1
+ import type { PluginInput } from "@fabriccode/plugin";
2
+ import type { AgentConfig } from "@fabriccode/sdk";
3
+ import type { WeaveConfig } from "./config/schema";
4
+ import type { ResolveSkillsFn } from "./agents/agent-builder";
5
+ import type { ProjectFingerprint } from "./features/analytics/types";
6
+ import { ConfigHandler } from "./managers/config-handler";
7
+ import { BackgroundManager } from "./managers/background-manager";
8
+ import { SkillMcpManager } from "./managers/skill-mcp-manager";
9
+ export interface WeaveManagers {
10
+ configHandler: ConfigHandler;
11
+ backgroundManager: BackgroundManager;
12
+ skillMcpManager: SkillMcpManager;
13
+ agents: Record<string, AgentConfig>;
14
+ }
15
+ export declare function createManagers(options: {
16
+ ctx: PluginInput;
17
+ pluginConfig: WeaveConfig;
18
+ resolveSkills?: ResolveSkillsFn;
19
+ fingerprint?: ProjectFingerprint | null;
20
+ configDir?: string;
21
+ }): WeaveManagers;
@@ -0,0 +1,16 @@
1
+ import type { PluginInput } from "@fabriccode/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,10 @@
1
+ import type { AdherenceReport } from "./types";
2
+ /**
3
+ * Calculate plan adherence by comparing planned vs actual file changes.
4
+ *
5
+ * - **coverage**: fraction of planned files that were actually changed (0-1).
6
+ * If no files were planned, coverage = 1 (vacuously complete).
7
+ * - **precision**: fraction of actual changes that were planned (0-1).
8
+ * If no files were changed, precision = 1 (vacuously precise).
9
+ */
10
+ export declare function calculateAdherence(plannedFiles: string[], actualFiles: string[]): AdherenceReport;
@@ -0,0 +1,33 @@
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 or stale.
30
+ * Regenerates if the cached fingerprint was generated by a different Weave version.
31
+ * Fire-and-forget: errors are logged but never thrown.
32
+ */
33
+ export declare function getOrCreateFingerprint(directory: string): ProjectFingerprint | null;
@@ -0,0 +1,10 @@
1
+ import type { MetricsReport, SessionSummary } from "./types";
2
+ /**
3
+ * Format metrics reports and session summaries into a markdown dashboard.
4
+ *
5
+ * @param reports - Array of MetricsReport from readMetricsReports()
6
+ * @param summaries - Array of SessionSummary from readSessionSummaries()
7
+ * @param args - Optional arguments: a plan name to filter, "all" for all reports, or empty for last 5
8
+ * @returns Formatted markdown string
9
+ */
10
+ export declare function formatMetricsMarkdown(reports: MetricsReport[], summaries: SessionSummary[], args?: string): string;
@@ -0,0 +1,17 @@
1
+ import type { WorkState } from "../work-state/types";
2
+ import type { MetricsReport } from "./types";
3
+ /**
4
+ * Generate a Phase 1 metrics report for a completed plan.
5
+ *
6
+ * Orchestrates:
7
+ * 1. Extract planned files from the plan markdown
8
+ * 2. Get actual changed files via git diff (startSha..HEAD)
9
+ * 3. Calculate adherence (coverage, precision)
10
+ * 4. Aggregate token usage across all sessions for this plan
11
+ * 5. Compute total duration from session summaries
12
+ * 6. Write the report to metrics-reports.jsonl
13
+ *
14
+ * In Phase 1, `quality` and `gaps` are undefined.
15
+ * Returns the report if successful, null on error.
16
+ */
17
+ export declare function generateMetricsReport(directory: string, state: WorkState): MetricsReport | null;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Get the list of files changed between a given SHA and HEAD.
3
+ *
4
+ * Uses `git diff --name-only fromSha..HEAD` and returns relative paths.
5
+ * Returns an empty array on any error (non-git repo, invalid SHA, etc.).
6
+ */
7
+ export declare function getChangedFiles(directory: string, fromSha: string): string[];
@@ -0,0 +1,29 @@
1
+ export type { ToolUsageEntry, DelegationEntry, SessionSummary, TokenUsage, MetricsTokenUsage, AdherenceReport, MetricsReport, DetectedStack, ProjectFingerprint, Suggestion, InFlightToolCall, TrackedSession, } from "./types";
2
+ export { ANALYTICS_DIR, SESSION_SUMMARIES_FILE, FINGERPRINT_FILE, METRICS_REPORTS_FILE, MAX_METRICS_ENTRIES, zeroTokenUsage, } from "./types";
3
+ export { ensureAnalyticsDir, appendSessionSummary, readSessionSummaries, writeFingerprint, readFingerprint, writeMetricsReport, readMetricsReports, } 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
+ export { generateTokenReport, getTokenReport } from "./token-report";
8
+ export { formatMetricsMarkdown } from "./format-metrics";
9
+ export { generateMetricsReport } from "./generate-metrics-report";
10
+ export { extractPlannedFiles } from "./plan-parser";
11
+ export { getChangedFiles } from "./git-diff";
12
+ export { calculateAdherence } from "./adherence";
13
+ export { aggregateTokensForPlan } from "./plan-token-aggregator";
14
+ import type { SessionTracker } from "./session-tracker";
15
+ import type { ProjectFingerprint } from "./types";
16
+ /** Return value of createAnalytics — bundles tracker + fingerprint */
17
+ export interface Analytics {
18
+ /** Session tracker instance — wire into tool.execute.before/after */
19
+ tracker: SessionTracker;
20
+ /** Project fingerprint (may be null if detection fails) */
21
+ fingerprint: ProjectFingerprint | null;
22
+ }
23
+ /**
24
+ * Create all analytics services for a project.
25
+ * Instantiates the session tracker and uses the provided fingerprint (if any).
26
+ * Fingerprint generation is the caller's responsibility — pass null to opt out.
27
+ * This is the single entry point called from the plugin's main init.
28
+ */
29
+ export declare function createAnalytics(directory: string, fingerprint: ProjectFingerprint | null): Analytics;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Extract all planned file paths from a plan's `## TODOs` section.
3
+ *
4
+ * Parses `**Files**:` lines, splits on commas, strips `(new)` / `Create` prefixes,
5
+ * deduplicates, and returns normalized relative paths.
6
+ */
7
+ export declare function extractPlannedFiles(planPath: string): string[];
@@ -0,0 +1,11 @@
1
+ import type { MetricsTokenUsage } from "./types";
2
+ /**
3
+ * Aggregate token usage for a plan by summing across matching session summaries.
4
+ *
5
+ * Reads all session summaries, filters to those whose `sessionId` is in `sessionIds`,
6
+ * and sums their `tokenUsage` fields. Sessions without `tokenUsage` contribute zeros
7
+ * (backward compatibility).
8
+ *
9
+ * Maps from session TokenUsage (inputTokens/outputTokens) to MetricsTokenUsage (input/output).
10
+ */
11
+ export declare function aggregateTokensForPlan(directory: string, sessionIds: string[]): MetricsTokenUsage;
@@ -0,0 +1,68 @@
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
+ * Set the agent name for a session. Only sets on first call (captures primary agent).
29
+ */
30
+ setAgentName(sessionId: string, agentName: string): void;
31
+ /**
32
+ * Accumulate dollar cost from a message into the session total.
33
+ */
34
+ trackCost(sessionId: string, cost: number): void;
35
+ /**
36
+ * Track token usage from a message.updated event.
37
+ * Accumulates all token fields into the session's running totals.
38
+ * Lazily starts the session if needed.
39
+ */
40
+ trackTokenUsage(sessionId: string, tokens: {
41
+ input?: number;
42
+ output?: number;
43
+ reasoning?: number;
44
+ cacheRead?: number;
45
+ cacheWrite?: number;
46
+ }): void;
47
+ /**
48
+ * End a session and persist the summary. Removes the session from tracking.
49
+ * Returns the generated summary, or null if the session wasn't being tracked.
50
+ */
51
+ endSession(sessionId: string): SessionSummary | null;
52
+ /**
53
+ * Check if a session is currently being tracked.
54
+ */
55
+ isTracking(sessionId: string): boolean;
56
+ /**
57
+ * Get the current tracked session data (for inspection/testing).
58
+ */
59
+ getSession(sessionId: string): TrackedSession | undefined;
60
+ /**
61
+ * Get the number of sessions currently being tracked.
62
+ */
63
+ get activeSessionCount(): number;
64
+ }
65
+ /**
66
+ * Create a new SessionTracker instance.
67
+ */
68
+ export declare function createSessionTracker(directory: string): SessionTracker;