vibe-fabric 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,218 @@
1
+ /**
2
+ * Setup state management for resume functionality
3
+ *
4
+ * Handles saving and loading setup state to allow resuming
5
+ * interrupted `vibe init` workflows.
6
+ */
7
+ import { readFile, writeFile, unlink } from 'fs/promises';
8
+ import { existsSync } from 'fs';
9
+ import path from 'path';
10
+ import { SetupStateSchema } from '../types/state.js';
11
+ /**
12
+ * State file name
13
+ */
14
+ const STATE_FILE = '.vibe-state.json';
15
+ /**
16
+ * Get the path to the state file
17
+ */
18
+ export function getStateFilePath(projectPath) {
19
+ return path.join(projectPath, STATE_FILE);
20
+ }
21
+ /**
22
+ * Check if a state file exists
23
+ */
24
+ export function hasSetupState(projectPath) {
25
+ return existsSync(getStateFilePath(projectPath));
26
+ }
27
+ /**
28
+ * Load setup state from file
29
+ * Returns null if no state file exists or state is invalid
30
+ */
31
+ export async function loadSetupState(projectPath) {
32
+ const statePath = getStateFilePath(projectPath);
33
+ if (!existsSync(statePath)) {
34
+ return null;
35
+ }
36
+ try {
37
+ const content = await readFile(statePath, 'utf-8');
38
+ const parsed = JSON.parse(content);
39
+ const validated = SetupStateSchema.parse(parsed);
40
+ return validated;
41
+ }
42
+ catch {
43
+ // Invalid or corrupted state file
44
+ return null;
45
+ }
46
+ }
47
+ /**
48
+ * Save setup state to file
49
+ */
50
+ export async function saveSetupState(state) {
51
+ const statePath = getStateFilePath(state.projectPath);
52
+ const content = JSON.stringify(state, null, 2);
53
+ await writeFile(statePath, content, 'utf-8');
54
+ }
55
+ /**
56
+ * Delete setup state file (cleanup after successful completion)
57
+ */
58
+ export async function clearSetupState(projectPath) {
59
+ const statePath = getStateFilePath(projectPath);
60
+ if (existsSync(statePath)) {
61
+ await unlink(statePath);
62
+ }
63
+ }
64
+ /**
65
+ * Create initial setup state
66
+ */
67
+ export function createSetupState(projectName, projectPath, projectType) {
68
+ const now = new Date().toISOString();
69
+ return {
70
+ version: 1,
71
+ projectName,
72
+ projectPath,
73
+ projectType,
74
+ startedAt: now,
75
+ lastUpdated: now,
76
+ currentStep: 'prerequisites',
77
+ completedSteps: [],
78
+ data: {},
79
+ };
80
+ }
81
+ /**
82
+ * Update state with a completed step
83
+ */
84
+ export function markStepCompleted(state, step) {
85
+ return {
86
+ ...state,
87
+ lastUpdated: new Date().toISOString(),
88
+ completedSteps: state.completedSteps.includes(step)
89
+ ? state.completedSteps
90
+ : [...state.completedSteps, step],
91
+ };
92
+ }
93
+ /**
94
+ * Update state current step
95
+ */
96
+ export function setCurrentStep(state, step) {
97
+ return {
98
+ ...state,
99
+ lastUpdated: new Date().toISOString(),
100
+ currentStep: step,
101
+ };
102
+ }
103
+ /**
104
+ * Update state with project description
105
+ */
106
+ export function setDescription(state, description) {
107
+ return {
108
+ ...state,
109
+ lastUpdated: new Date().toISOString(),
110
+ data: {
111
+ ...state.data,
112
+ description,
113
+ },
114
+ };
115
+ }
116
+ /**
117
+ * Update state with Claude recommendation
118
+ */
119
+ export function setRecommendation(state, recommendation) {
120
+ return {
121
+ ...state,
122
+ lastUpdated: new Date().toISOString(),
123
+ data: {
124
+ ...state.data,
125
+ recommendation,
126
+ },
127
+ };
128
+ }
129
+ /**
130
+ * Update state with planned repos
131
+ */
132
+ export function setPlannedRepos(state, repos) {
133
+ return {
134
+ ...state,
135
+ lastUpdated: new Date().toISOString(),
136
+ data: {
137
+ ...state.data,
138
+ plannedRepos: repos,
139
+ },
140
+ };
141
+ }
142
+ /**
143
+ * Update state with captured requirements
144
+ */
145
+ export function setRequirements(state, requirements) {
146
+ return {
147
+ ...state,
148
+ lastUpdated: new Date().toISOString(),
149
+ data: {
150
+ ...state.data,
151
+ requirements,
152
+ },
153
+ };
154
+ }
155
+ /**
156
+ * Check if a step has been completed
157
+ */
158
+ export function isStepCompleted(state, step) {
159
+ return state.completedSteps.includes(step);
160
+ }
161
+ /**
162
+ * Get human-readable step name
163
+ */
164
+ export function getStepDisplayName(step) {
165
+ const names = {
166
+ prerequisites: 'Prerequisites check',
167
+ 'project-name': 'Project name',
168
+ 'project-type': 'Project type selection',
169
+ 'github-auth': 'GitHub authentication',
170
+ 'hub-creation': 'Hub creation',
171
+ 'description-capture': 'Project description',
172
+ 'claude-recommendation': 'Claude recommendations',
173
+ 'repo-planning': 'Repository planning',
174
+ 'requirement-capture': 'Requirement capture',
175
+ 'prd-generation': 'PRD generation',
176
+ 'repo-linking': 'Repository linking',
177
+ 'map-generation': 'Map generation',
178
+ 'framework-injection': 'Framework injection',
179
+ complete: 'Complete',
180
+ };
181
+ return names[step] || step;
182
+ }
183
+ /**
184
+ * Get the next step in the workflow
185
+ */
186
+ export function getNextStep(currentStep, projectType) {
187
+ const newProjectSteps = [
188
+ 'prerequisites',
189
+ 'project-name',
190
+ 'project-type',
191
+ 'github-auth',
192
+ 'hub-creation',
193
+ 'description-capture',
194
+ 'claude-recommendation',
195
+ 'repo-planning',
196
+ 'requirement-capture',
197
+ 'prd-generation',
198
+ 'complete',
199
+ ];
200
+ const existingProjectSteps = [
201
+ 'prerequisites',
202
+ 'project-name',
203
+ 'project-type',
204
+ 'github-auth',
205
+ 'hub-creation',
206
+ 'repo-linking',
207
+ 'map-generation',
208
+ 'framework-injection',
209
+ 'complete',
210
+ ];
211
+ const steps = projectType === 'new' ? newProjectSteps : existingProjectSteps;
212
+ const currentIndex = steps.indexOf(currentStep);
213
+ if (currentIndex === -1 || currentIndex === steps.length - 1) {
214
+ return 'complete';
215
+ }
216
+ return steps[currentIndex + 1];
217
+ }
218
+ //# sourceMappingURL=state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.js","sourceRoot":"","sources":["../../src/core/state.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI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AAE,wBAAwB;QACjD,eAAe,EAAE,qBAAqB;QACtC,qBAAqB,EAAE,qBAAqB;QAC5C,gBAAgB,EAAE,gBAAgB;QAClC,cAAc,EAAE,oBAAoB;QACpC,gBAAgB,EAAE,gBAAgB;QAClC,qBAAqB,EAAE,qBAAqB;QAC5C,QAAQ,EAAE,UAAU;KACrB,CAAC;IACF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;AAC7B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,WAAsB,EAAE,WAA+B;IACjF,MAAM,eAAe,GAAgB;QACnC,eAAe;QACf,cAAc;QACd,cAAc;QACd,aAAa;QACb,cAAc;QACd,qBAAqB;QACrB,uBAAuB;QACvB,eAAe;QACf,qBAAqB;QACrB,gBAAgB;QAChB,UAAU;KACX,CAAC;IAEF,MAAM,oBAAoB,GAAgB;QACxC,eAAe;QACf,cAAc;QACd,cAAc;QACd,aAAa;QACb,cAAc;QACd,cAAc;QACd,gBAAgB;QAChB,qBAAqB;QACrB,UAAU;KACX,CAAC;IAEF,MAAM,KAAK,GAAG,WAAW,KAAK,KAAK,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,oBAAoB,CAAC;IAC7E,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAEhD,IAAI,YAAY,KAAK,CAAC,CAAC,IAAI,YAAY,KAAK,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7D,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,OAAO,KAAK,CAAC,YAAY,GAAG,CAAC,CAAc,CAAC;AAC9C,CAAC"}
@@ -29,15 +29,15 @@ export declare const TaskSchema: z.ZodObject<{
29
29
  name: string;
30
30
  status: "complete" | "pending" | "in_progress" | "failed";
31
31
  description: string;
32
- prompt: string;
33
32
  id: number;
33
+ prompt: string;
34
34
  interactive: boolean;
35
35
  context: Record<string, unknown>;
36
36
  }, {
37
37
  name: string;
38
38
  description: string;
39
- prompt: string;
40
39
  id: number;
40
+ prompt: string;
41
41
  status?: "complete" | "pending" | "in_progress" | "failed" | undefined;
42
42
  interactive?: boolean | undefined;
43
43
  context?: Record<string, unknown> | undefined;
@@ -64,15 +64,15 @@ export declare const OperationStateSchema: z.ZodObject<{
64
64
  name: string;
65
65
  status: "complete" | "pending" | "in_progress" | "failed";
66
66
  description: string;
67
- prompt: string;
68
67
  id: number;
68
+ prompt: string;
69
69
  interactive: boolean;
70
70
  context: Record<string, unknown>;
71
71
  }, {
72
72
  name: string;
73
73
  description: string;
74
- prompt: string;
75
74
  id: number;
75
+ prompt: string;
76
76
  status?: "complete" | "pending" | "in_progress" | "failed" | undefined;
77
77
  interactive?: boolean | undefined;
78
78
  context?: Record<string, unknown> | undefined;
@@ -84,15 +84,15 @@ export declare const OperationStateSchema: z.ZodObject<{
84
84
  }, "strip", z.ZodTypeAny, {
85
85
  operation: "prd" | "scope" | "gaps" | "analyze";
86
86
  project_path: string;
87
- phase: "assess" | "execute" | "approve" | "complete";
87
+ phase: "complete" | "assess" | "execute" | "approve";
88
88
  total_tasks: number;
89
89
  current_task: number;
90
90
  tasks: {
91
91
  name: string;
92
92
  status: "complete" | "pending" | "in_progress" | "failed";
93
93
  description: string;
94
- prompt: string;
95
94
  id: number;
95
+ prompt: string;
96
96
  interactive: boolean;
97
97
  context: Record<string, unknown>;
98
98
  }[];
@@ -103,7 +103,7 @@ export declare const OperationStateSchema: z.ZodObject<{
103
103
  }, {
104
104
  operation: "prd" | "scope" | "gaps" | "analyze";
105
105
  project_path: string;
106
- phase: "assess" | "execute" | "approve" | "complete";
106
+ phase: "complete" | "assess" | "execute" | "approve";
107
107
  started_at: string;
108
108
  updated_at: string;
109
109
  total_tasks?: number | undefined;
@@ -111,8 +111,8 @@ export declare const OperationStateSchema: z.ZodObject<{
111
111
  tasks?: {
112
112
  name: string;
113
113
  description: string;
114
- prompt: string;
115
114
  id: number;
115
+ prompt: string;
116
116
  status?: "complete" | "pending" | "in_progress" | "failed" | undefined;
117
117
  interactive?: boolean | undefined;
118
118
  context?: Record<string, unknown> | undefined;