@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,223 @@
1
+ import type { WeaveAgentName } from "../../agents/types";
2
+ export declare const EVAL_PHASES: readonly ["phase1", "phase2", "phase3", "phase4"];
3
+ export type EvalPhase = (typeof EVAL_PHASES)[number];
4
+ export declare const EVAL_TARGET_KINDS: readonly ["builtin-agent-prompt", "custom-agent-prompt", "single-turn-agent", "trajectory-agent"];
5
+ export type EvalTargetKind = (typeof EVAL_TARGET_KINDS)[number];
6
+ export declare const EXECUTOR_KINDS: readonly ["prompt-render", "model-response", "trajectory-run"];
7
+ export type ExecutorKind = (typeof EXECUTOR_KINDS)[number];
8
+ export declare const EVALUATOR_KINDS: readonly ["contains-all", "contains-any", "excludes-all", "section-contains-all", "ordered-contains", "xml-sections-present", "tool-policy", "min-length", "llm-judge", "baseline-diff", "trajectory-assertion"];
9
+ export type EvaluatorKind = (typeof EVALUATOR_KINDS)[number];
10
+ export type BuiltinEvalAgentName = Exclude<WeaveAgentName, "shuttle">;
11
+ export interface BuiltinAgentPromptVariant {
12
+ disabledAgents?: string[];
13
+ }
14
+ export interface BuiltinAgentPromptTarget {
15
+ kind: "builtin-agent-prompt";
16
+ agent: BuiltinEvalAgentName;
17
+ variant?: BuiltinAgentPromptVariant;
18
+ }
19
+ export interface CustomAgentPromptTarget {
20
+ kind: "custom-agent-prompt";
21
+ agentId: string;
22
+ }
23
+ export interface SingleTurnAgentTarget {
24
+ kind: "single-turn-agent";
25
+ agent: string;
26
+ input?: string;
27
+ }
28
+ export interface TrajectoryAgentTarget {
29
+ kind: "trajectory-agent";
30
+ agent: string;
31
+ scenarioRef?: string;
32
+ }
33
+ export type EvalTarget = BuiltinAgentPromptTarget | CustomAgentPromptTarget | SingleTurnAgentTarget | TrajectoryAgentTarget;
34
+ export interface PromptRenderExecutor {
35
+ kind: "prompt-render";
36
+ }
37
+ export interface ModelResponseExecutor {
38
+ kind: "model-response";
39
+ provider: string;
40
+ model: string;
41
+ input: string;
42
+ }
43
+ export interface TrajectoryRunExecutor {
44
+ kind: "trajectory-run";
45
+ scenarioRef: string;
46
+ }
47
+ export type ExecutorSpec = PromptRenderExecutor | ModelResponseExecutor | TrajectoryRunExecutor;
48
+ export interface WeightedEvaluatorSpec {
49
+ weight?: number;
50
+ }
51
+ export interface ContainsAllEvaluator extends WeightedEvaluatorSpec {
52
+ kind: "contains-all";
53
+ patterns: string[];
54
+ }
55
+ export interface ContainsAnyEvaluator extends WeightedEvaluatorSpec {
56
+ kind: "contains-any";
57
+ patterns: string[];
58
+ }
59
+ export interface ExcludesAllEvaluator extends WeightedEvaluatorSpec {
60
+ kind: "excludes-all";
61
+ patterns: string[];
62
+ }
63
+ export interface SectionContainsAllEvaluator extends WeightedEvaluatorSpec {
64
+ kind: "section-contains-all";
65
+ section: string;
66
+ patterns: string[];
67
+ }
68
+ export interface OrderedContainsEvaluator extends WeightedEvaluatorSpec {
69
+ kind: "ordered-contains";
70
+ patterns: string[];
71
+ }
72
+ export interface XmlSectionsPresentEvaluator extends WeightedEvaluatorSpec {
73
+ kind: "xml-sections-present";
74
+ sections: string[];
75
+ }
76
+ export interface ToolPolicyEvaluator extends WeightedEvaluatorSpec {
77
+ kind: "tool-policy";
78
+ expectations: Record<string, boolean>;
79
+ }
80
+ export interface MinLengthEvaluator extends WeightedEvaluatorSpec {
81
+ kind: "min-length";
82
+ min: number;
83
+ }
84
+ export interface LlmJudgeEvaluator extends WeightedEvaluatorSpec {
85
+ kind: "llm-judge";
86
+ rubricRef?: string;
87
+ expectedContains?: string[];
88
+ forbiddenContains?: string[];
89
+ }
90
+ export interface BaselineDiffEvaluator extends WeightedEvaluatorSpec {
91
+ kind: "baseline-diff";
92
+ baselineRef?: string;
93
+ }
94
+ export interface TrajectoryAssertionEvaluator extends WeightedEvaluatorSpec {
95
+ kind: "trajectory-assertion";
96
+ assertionRef?: string;
97
+ }
98
+ export type EvaluatorSpec = ContainsAllEvaluator | ContainsAnyEvaluator | ExcludesAllEvaluator | SectionContainsAllEvaluator | OrderedContainsEvaluator | XmlSectionsPresentEvaluator | ToolPolicyEvaluator | MinLengthEvaluator | LlmJudgeEvaluator | BaselineDiffEvaluator | TrajectoryAssertionEvaluator;
99
+ export interface EvalSuiteManifest {
100
+ id: string;
101
+ title: string;
102
+ phase: EvalPhase;
103
+ caseFiles: string[];
104
+ tags?: string[];
105
+ }
106
+ export interface EvalCase {
107
+ id: string;
108
+ title: string;
109
+ phase: EvalPhase;
110
+ target: EvalTarget;
111
+ executor: ExecutorSpec;
112
+ evaluators: EvaluatorSpec[];
113
+ tags?: string[];
114
+ notes?: string;
115
+ }
116
+ export interface LoadedEvalSuiteManifest extends EvalSuiteManifest {
117
+ filePath: string;
118
+ }
119
+ export interface LoadedEvalCase extends EvalCase {
120
+ filePath: string;
121
+ }
122
+ export interface AgentPromptMetadataArtifact {
123
+ agent: string;
124
+ description?: string;
125
+ sourceKind: "composer" | "default";
126
+ }
127
+ export interface EvalArtifacts {
128
+ renderedPrompt?: string;
129
+ agentMetadata?: AgentPromptMetadataArtifact;
130
+ toolPolicy?: Record<string, boolean>;
131
+ promptLength?: number;
132
+ modelOutput?: string;
133
+ judgeOutput?: string;
134
+ trace?: unknown;
135
+ tokens?: number;
136
+ cost?: number;
137
+ baselineDelta?: unknown;
138
+ }
139
+ export interface AssertionResult {
140
+ evaluatorKind: EvaluatorKind;
141
+ passed: boolean;
142
+ score: number;
143
+ maxScore: number;
144
+ message: string;
145
+ }
146
+ export interface EvalCaseResult {
147
+ caseId: string;
148
+ status: "passed" | "failed" | "error";
149
+ score: number;
150
+ normalizedScore: number;
151
+ maxScore: number;
152
+ durationMs: number;
153
+ artifacts: EvalArtifacts;
154
+ assertionResults: AssertionResult[];
155
+ errors: string[];
156
+ }
157
+ export interface EvalRunSummary {
158
+ totalCases: number;
159
+ passedCases: number;
160
+ failedCases: number;
161
+ errorCases: number;
162
+ totalScore: number;
163
+ normalizedScore: number;
164
+ maxScore: number;
165
+ }
166
+ export interface EvalRunResult {
167
+ runId: string;
168
+ startedAt: string;
169
+ finishedAt: string;
170
+ suiteId: string;
171
+ phase: EvalPhase;
172
+ summary: EvalRunSummary;
173
+ caseResults: EvalCaseResult[];
174
+ }
175
+ export interface ResolvedTarget {
176
+ target: EvalTarget;
177
+ artifacts: EvalArtifacts;
178
+ }
179
+ export interface ExecutionContext {
180
+ mode: "local" | "ci" | "hosted";
181
+ directory: string;
182
+ outputPath?: string;
183
+ }
184
+ export interface RunnerFilters {
185
+ caseIds?: string[];
186
+ agents?: string[];
187
+ tags?: string[];
188
+ }
189
+ export interface RunEvalSuiteOptions {
190
+ directory: string;
191
+ suite: string;
192
+ filters?: RunnerFilters;
193
+ outputPath?: string;
194
+ mode?: ExecutionContext["mode"];
195
+ }
196
+ export interface EvalLoadErrorContext {
197
+ filePath: string;
198
+ detail: string;
199
+ }
200
+ export interface DeterministicBaselineCase {
201
+ caseId: string;
202
+ status: EvalCaseResult["status"];
203
+ normalizedScore: number;
204
+ assertionPassed: number;
205
+ assertionFailed: number;
206
+ errorCount: number;
207
+ }
208
+ export interface DeterministicBaseline {
209
+ version: 1;
210
+ suiteId: string;
211
+ phase: EvalPhase;
212
+ generatedAt: string;
213
+ normalizedScore: number;
214
+ cases: DeterministicBaselineCase[];
215
+ }
216
+ export interface BaselineComparisonOptions {
217
+ scoreDropTolerance?: number;
218
+ }
219
+ export interface BaselineComparison {
220
+ outcome: "no-regression" | "informational-diff" | "regression";
221
+ regressions: string[];
222
+ informational: string[];
223
+ }
@@ -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,2 @@
1
+ import type { LoadedSkill } from "./types";
2
+ export declare function fetchSkillsFromFabric(serverUrl: string | URL, directory: string): Promise<LoadedSkill[]>;
@@ -0,0 +1,6 @@
1
+ export { loadSkills } from "./loader";
2
+ export type { LoadSkillsOptions } from "./loader";
3
+ export { createResolveSkillsFn, createSkillResolver, resolveMultipleSkills, resolveSkill } from "./resolver";
4
+ export { fetchSkillsFromFabric } from "./fabric-client";
5
+ export { scanDirectory, parseFrontmatter } from "./discovery";
6
+ export type { SkillScope, SkillMetadata, LoadedSkill, SkillDiscoveryResult } from "./types";
@@ -0,0 +1,7 @@
1
+ import type { SkillDiscoveryResult } from './types';
2
+ export interface LoadSkillsOptions {
3
+ serverUrl: string | URL;
4
+ directory?: string;
5
+ disabledSkills?: string[];
6
+ }
7
+ export declare function loadSkills(options: LoadSkillsOptions): Promise<SkillDiscoveryResult>;
@@ -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,18 @@
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
+ }
8
+ export interface LoadedSkill {
9
+ name: string;
10
+ description: string;
11
+ content: string;
12
+ scope?: SkillScope;
13
+ path?: string;
14
+ model?: string;
15
+ }
16
+ export interface SkillDiscoveryResult {
17
+ skills: LoadedSkill[];
18
+ }
@@ -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,5 @@
1
+ export type { WorkState, PlanProgress } from "./types";
2
+ export type { ValidationResult, ValidationIssue, ValidationSeverity, ValidationCategory } from "./validation-types";
3
+ export { WEAVE_DIR, WORK_STATE_FILE, WORK_STATE_PATH, PLANS_DIR } from "./constants";
4
+ export { readWorkState, writeWorkState, clearWorkState, appendSessionId, createWorkState, findPlans, getPlanProgress, getPlanName, getHeadSha, pauseWork, resumeWork, } from "./storage";
5
+ export { validatePlan } from "./validation";
@@ -0,0 +1,53 @@
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, directory?: string): WorkState;
25
+ /**
26
+ * Get the current HEAD SHA of the git repo at the given directory.
27
+ * Returns undefined if not a git repo or git is unavailable.
28
+ */
29
+ export declare function getHeadSha(directory: string): string | undefined;
30
+ /**
31
+ * Find all plan files in .weave/plans/, sorted by modification time (newest first).
32
+ * Returns absolute paths.
33
+ */
34
+ export declare function findPlans(directory: string): string[];
35
+ /**
36
+ * Count checked and unchecked markdown checkboxes in a plan file.
37
+ * Returns isComplete: true if file is missing, has 0 checkboxes, or all are checked.
38
+ */
39
+ export declare function getPlanProgress(planPath: string): PlanProgress;
40
+ /**
41
+ * Extract plan name from file path (basename minus .md extension).
42
+ */
43
+ export declare function getPlanName(planPath: string): string;
44
+ /**
45
+ * Pause work by setting paused: true in the work state.
46
+ * Returns false if no state exists (e.g., no active plan).
47
+ */
48
+ export declare function pauseWork(directory: string): boolean;
49
+ /**
50
+ * Resume work by setting paused: false in the work state.
51
+ * Returns false if no state exists.
52
+ */
53
+ export declare function resumeWork(directory: string): boolean;
@@ -0,0 +1,35 @@
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
+ /** Git HEAD SHA at the time work started (absent if not a git repo) */
17
+ start_sha?: string;
18
+ /** Whether work has been paused by a user interrupt; continuation is suppressed while true */
19
+ paused?: boolean;
20
+ /** The `completed` count from getPlanProgress() at the time of the last continuation prompt */
21
+ continuation_completed_snapshot?: number;
22
+ /** How many consecutive continuations have fired without progress changing */
23
+ stale_continuation_count?: number;
24
+ }
25
+ /**
26
+ * Progress snapshot from counting checkboxes in a plan file.
27
+ */
28
+ export interface PlanProgress {
29
+ /** Total number of checkboxes (checked + unchecked) */
30
+ total: number;
31
+ /** Number of completed checkboxes */
32
+ completed: number;
33
+ /** Whether all tasks are done (total === 0 or completed === total) */
34
+ isComplete: boolean;
35
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The 6 validation categories checked by validatePlan().
3
+ */
4
+ export type ValidationCategory = "structure" | "checkboxes" | "file-references" | "numbering" | "effort-estimate" | "verification";
5
+ /** Severity level for a validation issue. */
6
+ export type ValidationSeverity = "error" | "warning";
7
+ /**
8
+ * A single validation issue found in a plan file.
9
+ */
10
+ export interface ValidationIssue {
11
+ severity: ValidationSeverity;
12
+ category: ValidationCategory;
13
+ message: string;
14
+ }
15
+ /**
16
+ * The result of validating a plan file.
17
+ * `valid` is false if there are any blocking errors.
18
+ */
19
+ export interface ValidationResult {
20
+ /** False when there is at least one error (blocking). True when only warnings or clean. */
21
+ valid: boolean;
22
+ /** Blocking issues — prevent /start-work from proceeding */
23
+ errors: ValidationIssue[];
24
+ /** Non-blocking issues — surfaced to user but don't block execution */
25
+ warnings: ValidationIssue[];
26
+ }
@@ -0,0 +1,9 @@
1
+ import type { ValidationResult } from "./validation-types";
2
+ /**
3
+ * Validates a plan file's structure and content before /start-work execution.
4
+ *
5
+ * @param planPath Absolute path to the plan markdown file
6
+ * @param projectDir Absolute path to the project root (used for file-reference checks)
7
+ * @returns ValidationResult with errors (blocking) and warnings (non-blocking)
8
+ */
9
+ export declare function validatePlan(planPath: string, projectDir: string): ValidationResult;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Workflow control sub-commands: keyword detection in user messages during active workflows.
3
+ * These are NOT separate slash commands — they're natural language keywords detected in chat.message.
4
+ */
5
+ export interface WorkflowCommandResult {
6
+ /** Whether a workflow control keyword was detected and handled */
7
+ handled: boolean;
8
+ /** Context to inject into the response */
9
+ contextInjection?: string;
10
+ /** Agent to switch to (if any) */
11
+ switchAgent?: string;
12
+ }
13
+ /**
14
+ * Check if a user message contains a workflow control keyword and handle it.
15
+ * Only active when a workflow instance is running.
16
+ */
17
+ export declare function handleWorkflowCommand(message: string, directory: string): WorkflowCommandResult;
@@ -0,0 +1,31 @@
1
+ import type { CompletionConfig, CompletionMethod } from "./types";
2
+ /**
3
+ * Result of checking whether a step's completion condition is met.
4
+ */
5
+ export interface CompletionCheckResult {
6
+ complete: boolean;
7
+ verdict?: "approve" | "reject";
8
+ artifacts?: Record<string, string>;
9
+ /** Concise summary of step output for context threading */
10
+ summary?: string;
11
+ reason?: string;
12
+ }
13
+ /**
14
+ * Context provided to completion checkers.
15
+ */
16
+ export interface CompletionContext {
17
+ /** Last assistant message text (from message.part.updated tracking) */
18
+ lastAssistantMessage?: string;
19
+ /** Last user message text (for user_confirm) */
20
+ lastUserMessage?: string;
21
+ /** Working directory */
22
+ directory: string;
23
+ /** Completion config from the step definition */
24
+ config: CompletionConfig;
25
+ /** Current artifacts in the instance */
26
+ artifacts: Record<string, string>;
27
+ }
28
+ /**
29
+ * Check whether a step's completion condition is met.
30
+ */
31
+ export declare function checkStepCompletion(method: CompletionMethod, context: CompletionContext): CompletionCheckResult;
@@ -0,0 +1,12 @@
1
+ /** Root directory for Weave state and plans */
2
+ export { WEAVE_DIR } from "../work-state/constants";
3
+ /** Directory under .weave/ for workflow instance state */
4
+ export declare const WORKFLOWS_STATE_DIR = ".weave/workflows";
5
+ /** File name for individual instance state */
6
+ export declare const INSTANCE_STATE_FILE = "state.json";
7
+ /** Pointer file tracking the currently active workflow instance */
8
+ export declare const ACTIVE_INSTANCE_FILE = "active-instance.json";
9
+ /** Project-level directory for workflow definitions */
10
+ export declare const WORKFLOWS_DIR_PROJECT = ".fabric/workflows";
11
+ /** User-level directory for workflow definitions (under ~/.config/fabric/) */
12
+ export declare const WORKFLOWS_DIR_USER = "workflows";
@@ -0,0 +1,16 @@
1
+ import type { WorkflowInstance, WorkflowDefinition, WorkflowStepDefinition } from "./types";
2
+ /**
3
+ * Resolve template variables in a string.
4
+ * Supports: {{instance.goal}}, {{instance.slug}}, {{artifacts.X}}, {{step.name}}, {{step.id}}
5
+ * Unknown variables are left as-is.
6
+ */
7
+ export declare function resolveTemplate(template: string, instance: WorkflowInstance, definition: WorkflowDefinition): string;
8
+ /**
9
+ * Build the workflow context header showing goal, step history, and accumulated artifacts.
10
+ */
11
+ export declare function buildContextHeader(instance: WorkflowInstance, definition: WorkflowDefinition): string;
12
+ /**
13
+ * Build the full context-threaded prompt for a step.
14
+ * Combines: (1) workflow context header, (2) resolved step prompt.
15
+ */
16
+ export declare function composeStepPrompt(stepDef: WorkflowStepDefinition, instance: WorkflowInstance, definition: WorkflowDefinition): string;
@@ -0,0 +1,19 @@
1
+ import type { WorkflowDefinition } from "./types";
2
+ /**
3
+ * A workflow definition discovered from the filesystem.
4
+ */
5
+ export interface DiscoveredWorkflow {
6
+ definition: WorkflowDefinition;
7
+ path: string;
8
+ scope: "project" | "user";
9
+ }
10
+ /**
11
+ * Load and validate a single workflow definition from a JSONC file path.
12
+ * Returns null if the file can't be read, parsed, or fails validation.
13
+ */
14
+ export declare function loadWorkflowDefinition(filePath: string): WorkflowDefinition | null;
15
+ /**
16
+ * Discover all valid workflow definitions from project and user directories.
17
+ * Project workflows override user workflows with the same name.
18
+ */
19
+ export declare function discoverWorkflows(directory: string): DiscoveredWorkflow[];
@@ -0,0 +1,49 @@
1
+ import type { WorkflowDefinition } from "./types";
2
+ import type { CompletionContext } from "./completion";
3
+ /**
4
+ * An action the engine wants the caller to take.
5
+ */
6
+ export interface EngineAction {
7
+ type: "inject_prompt" | "switch_agent" | "pause" | "complete" | "none";
8
+ /** Context-threaded prompt to inject */
9
+ prompt?: string;
10
+ /** Agent to switch to for the next step */
11
+ agent?: string;
12
+ reason?: string;
13
+ }
14
+ /**
15
+ * Start a new workflow instance from a definition and goal.
16
+ * Creates the instance, sets it as active, and returns the first step's prompt.
17
+ */
18
+ export declare function startWorkflow(input: {
19
+ definition: WorkflowDefinition;
20
+ definitionPath: string;
21
+ goal: string;
22
+ sessionId: string;
23
+ directory: string;
24
+ }): EngineAction;
25
+ /**
26
+ * Check the current step's completion and advance if complete.
27
+ * This is called on session.idle events.
28
+ */
29
+ export declare function checkAndAdvance(input: {
30
+ directory: string;
31
+ context: CompletionContext;
32
+ }): EngineAction;
33
+ /**
34
+ * Pause the active workflow instance.
35
+ */
36
+ export declare function pauseWorkflow(directory: string, reason?: string): boolean;
37
+ /**
38
+ * Resume a paused workflow instance.
39
+ * Returns the current step's context-threaded prompt.
40
+ */
41
+ export declare function resumeWorkflow(directory: string): EngineAction;
42
+ /**
43
+ * Skip the current step and advance to the next.
44
+ */
45
+ export declare function skipStep(directory: string): EngineAction;
46
+ /**
47
+ * Abort the active workflow instance.
48
+ */
49
+ export declare function abortWorkflow(directory: string): boolean;
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Workflow hook handler: detects /run-workflow commands, parses arguments,
3
+ * manages workflow instances, and drives step transitions on session.idle.
4
+ */
5
+ /**
6
+ * Marker embedded in workflow continuation prompts so the auto-pause guard
7
+ * in plugin-interface.ts can recognize them and NOT pause coexisting WorkState plans.
8
+ */
9
+ export declare const WORKFLOW_CONTINUATION_MARKER = "<!-- weave:workflow-continuation -->";
10
+ export interface WorkflowHookResult {
11
+ /** Context to inject into the prompt (step prompt with workflow context) */
12
+ contextInjection: string | null;
13
+ /** Agent to switch to for the current step */
14
+ switchAgent: string | null;
15
+ }
16
+ /**
17
+ * Parse /run-workflow arguments into workflow name and optional goal.
18
+ * Argument format: `<workflow-name> "goal text"` or `<workflow-name>` or empty.
19
+ */
20
+ export declare function parseWorkflowArgs(args: string): {
21
+ workflowName: string | null;
22
+ goal: string | null;
23
+ };
24
+ /**
25
+ * Handle the /run-workflow command.
26
+ * Detects the command via <session-context> tag, parses arguments,
27
+ * and either creates a new instance, resumes an existing one, or lists available definitions.
28
+ */
29
+ export declare function handleRunWorkflow(input: {
30
+ promptText: string;
31
+ sessionId: string;
32
+ directory: string;
33
+ }): WorkflowHookResult;
34
+ /**
35
+ * Check workflow continuation on session.idle.
36
+ * If an active workflow instance exists and the current step's completion condition is met,
37
+ * advance to the next step and return a continuation prompt.
38
+ */
39
+ export declare function checkWorkflowContinuation(input: {
40
+ sessionId: string;
41
+ directory: string;
42
+ lastAssistantMessage?: string;
43
+ lastUserMessage?: string;
44
+ }): {
45
+ continuationPrompt: string | null;
46
+ switchAgent: string | null;
47
+ };
@@ -0,0 +1,15 @@
1
+ export type { StepType, CompletionMethod, StepStatus, WorkflowStatus, OnRejectAction, ArtifactRef, StepArtifacts, CompletionConfig, WorkflowStepDefinition, WorkflowDefinition, StepState, WorkflowInstance, ActiveInstancePointer, } from "./types";
2
+ export { WORKFLOWS_STATE_DIR, INSTANCE_STATE_FILE, ACTIVE_INSTANCE_FILE, WORKFLOWS_DIR_PROJECT, WORKFLOWS_DIR_USER, } from "./constants";
3
+ export { generateInstanceId, generateSlug, createWorkflowInstance, readWorkflowInstance, writeWorkflowInstance, readActiveInstance, setActiveInstance, clearActiveInstance, getActiveWorkflowInstance, listInstances, appendInstanceSessionId, } from "./storage";
4
+ export type { DiscoveredWorkflow } from "./discovery";
5
+ export { loadWorkflowDefinition, discoverWorkflows } from "./discovery";
6
+ export { resolveTemplate, buildContextHeader, composeStepPrompt } from "./context";
7
+ export type { CompletionCheckResult, CompletionContext } from "./completion";
8
+ export { checkStepCompletion } from "./completion";
9
+ export type { EngineAction } from "./engine";
10
+ export { startWorkflow, checkAndAdvance, pauseWorkflow, resumeWorkflow, skipStep, abortWorkflow, } from "./engine";
11
+ export { WORKFLOW_CONTINUATION_MARKER } from "./hook";
12
+ export type { WorkflowHookResult } from "./hook";
13
+ export { parseWorkflowArgs, handleRunWorkflow, checkWorkflowContinuation } from "./hook";
14
+ export type { WorkflowCommandResult } from "./commands";
15
+ export { handleWorkflowCommand } from "./commands";