@hyperdrive.bot/gut 0.1.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.
Files changed (87) hide show
  1. package/README.md +809 -0
  2. package/bin/dev +16 -0
  3. package/bin/run +5 -0
  4. package/dist/base-command.d.ts +21 -0
  5. package/dist/base-command.js +110 -0
  6. package/dist/commands/add.d.ts +13 -0
  7. package/dist/commands/add.js +73 -0
  8. package/dist/commands/affected.d.ts +23 -0
  9. package/dist/commands/affected.js +326 -0
  10. package/dist/commands/audit.d.ts +33 -0
  11. package/dist/commands/audit.js +593 -0
  12. package/dist/commands/back.d.ts +6 -0
  13. package/dist/commands/back.js +29 -0
  14. package/dist/commands/commit.d.ts +11 -0
  15. package/dist/commands/commit.js +113 -0
  16. package/dist/commands/context.d.ts +6 -0
  17. package/dist/commands/context.js +36 -0
  18. package/dist/commands/contexts.d.ts +7 -0
  19. package/dist/commands/contexts.js +92 -0
  20. package/dist/commands/deps.d.ts +10 -0
  21. package/dist/commands/deps.js +104 -0
  22. package/dist/commands/entity/add.d.ts +16 -0
  23. package/dist/commands/entity/add.js +105 -0
  24. package/dist/commands/entity/clone-all.d.ts +17 -0
  25. package/dist/commands/entity/clone-all.js +135 -0
  26. package/dist/commands/entity/clone.d.ts +15 -0
  27. package/dist/commands/entity/clone.js +109 -0
  28. package/dist/commands/entity/list.d.ts +11 -0
  29. package/dist/commands/entity/list.js +82 -0
  30. package/dist/commands/entity/remove.d.ts +12 -0
  31. package/dist/commands/entity/remove.js +58 -0
  32. package/dist/commands/focus.d.ts +19 -0
  33. package/dist/commands/focus.js +139 -0
  34. package/dist/commands/graph.d.ts +18 -0
  35. package/dist/commands/graph.js +238 -0
  36. package/dist/commands/init.d.ts +11 -0
  37. package/dist/commands/init.js +84 -0
  38. package/dist/commands/insights.d.ts +21 -0
  39. package/dist/commands/insights.js +434 -0
  40. package/dist/commands/patterns.d.ts +40 -0
  41. package/dist/commands/patterns.js +412 -0
  42. package/dist/commands/pull.d.ts +11 -0
  43. package/dist/commands/pull.js +121 -0
  44. package/dist/commands/push.d.ts +11 -0
  45. package/dist/commands/push.js +101 -0
  46. package/dist/commands/quick-setup.d.ts +20 -0
  47. package/dist/commands/quick-setup.js +422 -0
  48. package/dist/commands/recent.d.ts +9 -0
  49. package/dist/commands/recent.js +55 -0
  50. package/dist/commands/related.d.ts +23 -0
  51. package/dist/commands/related.js +257 -0
  52. package/dist/commands/repos.d.ts +14 -0
  53. package/dist/commands/repos.js +185 -0
  54. package/dist/commands/stack.d.ts +10 -0
  55. package/dist/commands/stack.js +83 -0
  56. package/dist/commands/status.d.ts +14 -0
  57. package/dist/commands/status.js +246 -0
  58. package/dist/commands/sync.d.ts +11 -0
  59. package/dist/commands/sync.js +142 -0
  60. package/dist/commands/unfocus.d.ts +6 -0
  61. package/dist/commands/unfocus.js +23 -0
  62. package/dist/commands/used-by.d.ts +10 -0
  63. package/dist/commands/used-by.js +111 -0
  64. package/dist/commands/workspace.d.ts +20 -0
  65. package/dist/commands/workspace.js +365 -0
  66. package/dist/index.d.ts +1 -0
  67. package/dist/index.js +5 -0
  68. package/dist/models/entity.model.d.ts +81 -0
  69. package/dist/models/entity.model.js +2 -0
  70. package/dist/services/config.service.d.ts +34 -0
  71. package/dist/services/config.service.js +230 -0
  72. package/dist/services/entity.service.d.ts +19 -0
  73. package/dist/services/entity.service.js +130 -0
  74. package/dist/services/focus.service.d.ts +70 -0
  75. package/dist/services/focus.service.js +587 -0
  76. package/dist/services/git.service.d.ts +37 -0
  77. package/dist/services/git.service.js +180 -0
  78. package/dist/utils/display.d.ts +25 -0
  79. package/dist/utils/display.js +150 -0
  80. package/dist/utils/filesystem.d.ts +32 -0
  81. package/dist/utils/filesystem.js +220 -0
  82. package/dist/utils/index.d.ts +13 -0
  83. package/dist/utils/index.js +18 -0
  84. package/dist/utils/validation.d.ts +22 -0
  85. package/dist/utils/validation.js +196 -0
  86. package/oclif.manifest.json +1463 -0
  87. package/package.json +76 -0
@@ -0,0 +1,365 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const core_1 = require("@oclif/core");
5
+ const base_command_1 = require("../base-command");
6
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
7
+ const fs = tslib_1.__importStar(require("fs"));
8
+ const path = tslib_1.__importStar(require("path"));
9
+ class Workspace extends base_command_1.BaseCommand {
10
+ static description = 'Manage workspace structure and entity metadata';
11
+ static examples = [
12
+ '<%= config.bin %> <%= command.id %> init',
13
+ '<%= config.bin %> <%= command.id %> structure',
14
+ '<%= config.bin %> <%= command.id %> generate-metadata',
15
+ ];
16
+ static args = {
17
+ action: core_1.Args.string({
18
+ name: 'action',
19
+ required: true,
20
+ description: 'Action to perform (init, structure, generate-metadata)',
21
+ options: ['init', 'structure', 'generate-metadata'],
22
+ }),
23
+ };
24
+ static flags = {
25
+ force: core_1.Flags.boolean({
26
+ char: 'f',
27
+ description: 'force overwrite existing files',
28
+ }),
29
+ 'entity-type': core_1.Flags.string({
30
+ char: 't',
31
+ description: 'entity type for metadata generation',
32
+ options: ['client', 'prospect', 'company', 'initiative', 'system'],
33
+ }),
34
+ };
35
+ async run() {
36
+ const { args, flags } = await this.parse(Workspace);
37
+ switch (args.action) {
38
+ case 'init':
39
+ await this.initWorkspaceStructure(flags.force);
40
+ break;
41
+ case 'structure':
42
+ await this.showWorkspaceStructure();
43
+ break;
44
+ case 'generate-metadata':
45
+ await this.generateEntityMetadata(flags['entity-type'], flags.force);
46
+ break;
47
+ default:
48
+ this.error(`Unknown action: ${args.action}`);
49
+ }
50
+ }
51
+ async initWorkspaceStructure(force) {
52
+ const workspaceRoot = this.configService.getWorkspaceRoot();
53
+ this.log(chalk_1.default.bold('\n🏗️ Initializing Workspace Structure'));
54
+ this.log(chalk_1.default.dim('─'.repeat(50)));
55
+ // Create directory structure
56
+ const directories = [
57
+ 'entities/clients',
58
+ 'entities/prospects',
59
+ 'entities/companies',
60
+ 'entities/initiatives',
61
+ 'systems/api',
62
+ 'systems/tools',
63
+ 'systems/shared',
64
+ 'focus/current',
65
+ 'focus/recent',
66
+ 'focus/breadcrumbs',
67
+ 'focus/stack',
68
+ ];
69
+ for (const dir of directories) {
70
+ const fullPath = path.join(workspaceRoot, dir);
71
+ if (!fs.existsSync(fullPath)) {
72
+ fs.mkdirSync(fullPath, { recursive: true });
73
+ this.log(`✓ Created ${chalk_1.default.green(dir)}`);
74
+ }
75
+ else {
76
+ this.log(` ${chalk_1.default.dim(dir)} (already exists)`);
77
+ }
78
+ }
79
+ // Create workspace configuration
80
+ const workspaceConfigPath = path.join(workspaceRoot, '.workspace', 'config.yaml');
81
+ const workspaceConfigDir = path.dirname(workspaceConfigPath);
82
+ if (!fs.existsSync(workspaceConfigDir)) {
83
+ fs.mkdirSync(workspaceConfigDir, { recursive: true });
84
+ }
85
+ if (!fs.existsSync(workspaceConfigPath) || force) {
86
+ const workspaceConfig = this.generateWorkspaceConfig();
87
+ fs.writeFileSync(workspaceConfigPath, workspaceConfig);
88
+ this.log(`✓ Created ${chalk_1.default.green('.workspace/config.yaml')}`);
89
+ }
90
+ else {
91
+ this.log(` ${chalk_1.default.dim('.workspace/config.yaml')} (already exists)`);
92
+ }
93
+ // Create contexts configuration
94
+ const contextsConfigPath = path.join(workspaceRoot, '.workspace', 'contexts.yaml');
95
+ if (!fs.existsSync(contextsConfigPath) || force) {
96
+ const contextsConfig = this.generateContextsConfig();
97
+ fs.writeFileSync(contextsConfigPath, contextsConfig);
98
+ this.log(`✓ Created ${chalk_1.default.green('.workspace/contexts.yaml')}`);
99
+ }
100
+ else {
101
+ this.log(` ${chalk_1.default.dim('.workspace/contexts.yaml')} (already exists)`);
102
+ }
103
+ this.log(chalk_1.default.dim('\n─'.repeat(50)));
104
+ this.log(chalk_1.default.green('✅ Workspace structure initialized'));
105
+ this.log(chalk_1.default.dim('Next steps:'));
106
+ this.log(chalk_1.default.dim('• Add entities: gut entity add <name> <type> <path>'));
107
+ this.log(chalk_1.default.dim('• Generate metadata: gut workspace generate-metadata'));
108
+ this.log(chalk_1.default.dim('• Set focus: gut focus client <name>'));
109
+ }
110
+ async showWorkspaceStructure() {
111
+ const workspaceRoot = this.configService.getWorkspaceRoot();
112
+ this.log(chalk_1.default.bold('\n📁 Workspace Structure'));
113
+ this.log(chalk_1.default.dim('─'.repeat(50)));
114
+ // Show directory tree
115
+ this.showDirectoryTree(workspaceRoot, '', 0, 2);
116
+ // Show entities summary
117
+ const entities = this.entityService.getAllEntities();
118
+ if (entities.length > 0) {
119
+ this.log(chalk_1.default.bold('\n🏢 Entities Summary'));
120
+ this.log(chalk_1.default.dim('─'.repeat(50)));
121
+ const byType = entities.reduce((acc, entity) => {
122
+ if (!acc[entity.type])
123
+ acc[entity.type] = 0;
124
+ acc[entity.type]++;
125
+ return acc;
126
+ }, {});
127
+ for (const [type, count] of Object.entries(byType)) {
128
+ const emoji = this.getTypeEmoji(type);
129
+ this.log(`${emoji} ${type}: ${count}`);
130
+ }
131
+ }
132
+ }
133
+ showDirectoryTree(dirPath, prefix, depth, maxDepth) {
134
+ if (depth > maxDepth)
135
+ return;
136
+ try {
137
+ const items = fs.readdirSync(dirPath)
138
+ .filter(item => !item.startsWith('.') || item === '.workspace')
139
+ .sort();
140
+ items.forEach((item, index) => {
141
+ const itemPath = path.join(dirPath, item);
142
+ const isLast = index === items.length - 1;
143
+ const currentPrefix = isLast ? '└── ' : '├── ';
144
+ const nextPrefix = prefix + (isLast ? ' ' : '│ ');
145
+ try {
146
+ const stats = fs.statSync(itemPath);
147
+ if (stats.isDirectory()) {
148
+ this.log(`${prefix}${currentPrefix}${chalk_1.default.blue(item)}/`);
149
+ if (depth < maxDepth) {
150
+ this.showDirectoryTree(itemPath, nextPrefix, depth + 1, maxDepth);
151
+ }
152
+ }
153
+ else {
154
+ this.log(`${prefix}${currentPrefix}${item}`);
155
+ }
156
+ }
157
+ catch {
158
+ // Skip items we can't access
159
+ }
160
+ });
161
+ }
162
+ catch {
163
+ // Skip directories we can't read
164
+ }
165
+ }
166
+ async generateEntityMetadata(entityType, force) {
167
+ const entities = entityType
168
+ ? this.entityService.getEntitiesByType(entityType)
169
+ : this.entityService.getAllEntities();
170
+ if (entities.length === 0) {
171
+ this.error('No entities found. Add entities first with "gut entity add"');
172
+ }
173
+ this.log(chalk_1.default.bold('\n📝 Generating Entity Metadata'));
174
+ this.log(chalk_1.default.dim('─'.repeat(50)));
175
+ for (const entity of entities) {
176
+ const entityPath = this.entityService.resolveEntityPath(entity);
177
+ const metadataPath = path.join(entityPath, '.entity.yaml');
178
+ if (fs.existsSync(metadataPath) && !force) {
179
+ this.log(` ${chalk_1.default.dim(entity.name)} (metadata already exists)`);
180
+ continue;
181
+ }
182
+ // Ensure entity directory exists
183
+ if (!fs.existsSync(entityPath)) {
184
+ fs.mkdirSync(entityPath, { recursive: true });
185
+ }
186
+ const metadata = this.generateEntityMetadataContent(entity);
187
+ fs.writeFileSync(metadataPath, metadata);
188
+ this.log(`✓ Generated metadata for ${chalk_1.default.green(entity.name)}`);
189
+ }
190
+ this.log(chalk_1.default.dim('\n─'.repeat(50)));
191
+ this.log(chalk_1.default.green('✅ Entity metadata generated'));
192
+ }
193
+ generateWorkspaceConfig() {
194
+ return `# DevSquad Context Operating System - Workspace Configuration
195
+ # Generated on ${new Date().toISOString()}
196
+
197
+ workspace:
198
+ version: "1.0"
199
+ name: "DevSquad Workspace"
200
+ description: "Context-aware development workspace"
201
+
202
+ structure:
203
+ entities_dir: "entities"
204
+ systems_dir: "systems"
205
+ focus_dir: "focus"
206
+
207
+ settings:
208
+ default_focus_mode: "delivery"
209
+ auto_context_generation: true
210
+ focus_session_tracking: true
211
+
212
+ integrations:
213
+ git:
214
+ auto_sync: false
215
+ multi_repo_operations: true
216
+ ai:
217
+ context_generation: true
218
+ persona_switching: true
219
+ jira:
220
+ enabled: false
221
+ base_url: ""
222
+
223
+ # Entity type definitions
224
+ entity_types:
225
+ client:
226
+ description: "Active client relationships"
227
+ default_modes: ["delivery", "strategy", "audit"]
228
+
229
+ prospect:
230
+ description: "Potential client relationships"
231
+ default_modes: ["research", "proposal"]
232
+
233
+ company:
234
+ description: "DevSquad group companies"
235
+ default_modes: ["strategy", "audit"]
236
+
237
+ initiative:
238
+ description: "Strategic cross-entity initiatives"
239
+ default_modes: ["strategy", "delivery"]
240
+
241
+ system:
242
+ description: "Supporting systems and infrastructure"
243
+ default_modes: ["delivery", "debug"]
244
+ `;
245
+ }
246
+ generateContextsConfig() {
247
+ return `# Context Definitions for AI and Focus Management
248
+ # Generated on ${new Date().toISOString()}
249
+
250
+ contexts:
251
+ # Example client context
252
+ # clients:
253
+ # mindtools:
254
+ # type: "client"
255
+ # description: "MindTools React platform - 24M+ users"
256
+ # status: "active_development"
257
+ #
258
+ # repositories:
259
+ # primary: "entities/clients/mindtools/delivery"
260
+ # private: "entities/clients/mindtools/business"
261
+ # related: ["systems/api", "systems/shared/design-system"]
262
+ #
263
+ # focus_modes:
264
+ # delivery:
265
+ # include: ["delivery/repos/", "systems/shared/design-system/"]
266
+ # exclude: ["business/contracts/"]
267
+ # ai_persona: "senior_react_developer"
268
+ # suggested_duration: "1h 30m"
269
+ #
270
+ # strategy:
271
+ # include: ["delivery/", "business/", "insights/"]
272
+ # exclude: []
273
+ # ai_persona: "ceo_strategic_advisor"
274
+ # suggested_duration: "2h 30m"
275
+
276
+ # Focus mode definitions
277
+ focus_modes:
278
+ delivery:
279
+ description: "Technical development and implementation"
280
+ typical_duration: "1-2 hours"
281
+ ai_persona: "senior_developer"
282
+
283
+ strategy:
284
+ description: "Business strategy and planning"
285
+ typical_duration: "2-3 hours"
286
+ ai_persona: "strategic_advisor"
287
+
288
+ audit:
289
+ description: "Review and compliance analysis"
290
+ typical_duration: "45-90 minutes"
291
+ ai_persona: "business_auditor"
292
+
293
+ debug:
294
+ description: "Problem investigation and resolution"
295
+ typical_duration: "30-60 minutes"
296
+ ai_persona: "debugging_specialist"
297
+
298
+ research:
299
+ description: "Market and technical research"
300
+ typical_duration: "1-2 hours"
301
+ ai_persona: "research_analyst"
302
+
303
+ proposal:
304
+ description: "Proposal preparation and client communication"
305
+ typical_duration: "2-4 hours"
306
+ ai_persona: "business_consultant"
307
+ `;
308
+ }
309
+ generateEntityMetadataContent(entity) {
310
+ const now = new Date().toISOString();
311
+ return `# Entity Metadata for ${entity.name}
312
+ # Generated on ${now}
313
+
314
+ entity:
315
+ type: "${entity.type}"
316
+ name: "${entity.name}"
317
+ description: "${entity.description || `${entity.type} entity: ${entity.name}`}"
318
+ created: "${now}"
319
+
320
+ # Business information (for client/prospect entities)
321
+ business:
322
+ # primary_contact: ""
323
+ # contract_value: ""
324
+ # team_size: 0
325
+ # priority: "medium" # low, medium, high
326
+ # status: "active"
327
+
328
+ # Relationships with other entities
329
+ relationships:
330
+ # similar_entities: []
331
+ # dependent_systems: ["systems/api"]
332
+ # related_initiatives: []
333
+
334
+ # Working patterns and preferences
335
+ working_patterns:
336
+ # typical_focus_duration: "2h"
337
+ # common_paired_entities: []
338
+ # strategic_review_frequency: "weekly"
339
+ # productive_times: ["9-11am", "2-4pm"]
340
+
341
+ # AI context configuration
342
+ ai_context:
343
+ # persona: "senior_developer"
344
+ # knowledge_scope: "complete_technical_context"
345
+ # decision_authority: "technical_implementation"
346
+
347
+ # Focus intelligence (learned from usage)
348
+ focus_intelligence:
349
+ # optimal_session_duration: ""
350
+ # average_interruptions: 0
351
+ # effectiveness_metrics:
352
+ # commits_per_session: 0
353
+ # lines_changed_per_session: 0
354
+ # issues_resolved_per_session: 0
355
+
356
+ # Repository information
357
+ repository:
358
+ path: "${entity.path}"
359
+ # remote: "${entity.repository || ''}"
360
+ # branch: "main"
361
+ # last_sync: ""
362
+ `;
363
+ }
364
+ }
365
+ exports.default = Workspace;
@@ -0,0 +1 @@
1
+ export { run } from '@oclif/core';
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.run = void 0;
4
+ var core_1 = require("@oclif/core");
5
+ Object.defineProperty(exports, "run", { enumerable: true, get: function () { return core_1.run; } });
@@ -0,0 +1,81 @@
1
+ export type EntityType = 'client' | 'prospect' | 'company' | 'initiative' | 'system' | 'delivery' | 'module' | 'service' | 'tool';
2
+ export type FocusMode = 'delivery' | 'strategy' | 'audit' | 'debug' | 'research' | 'proposal';
3
+ export interface Entity {
4
+ name: string;
5
+ type: EntityType;
6
+ path: string;
7
+ repository?: string;
8
+ repo?: string;
9
+ remote?: string;
10
+ description?: string;
11
+ metadata?: EntityMetadata;
12
+ }
13
+ export interface EntityMetadata {
14
+ business?: {
15
+ primary_contact?: string;
16
+ contract_value?: string;
17
+ team_size?: number;
18
+ priority?: 'low' | 'medium' | 'high';
19
+ status?: string;
20
+ };
21
+ relationships?: {
22
+ similar_entities?: string[];
23
+ dependent_systems?: string[];
24
+ related_initiatives?: string[];
25
+ };
26
+ working_patterns?: {
27
+ typical_focus_duration?: string;
28
+ common_paired_entities?: string[];
29
+ strategic_review_frequency?: string;
30
+ };
31
+ ai_context?: {
32
+ persona?: string;
33
+ knowledge_scope?: string;
34
+ decision_authority?: string;
35
+ };
36
+ }
37
+ export interface Focus {
38
+ type: string;
39
+ name: string;
40
+ path: string;
41
+ timestamp?: number;
42
+ entities?: Entity[];
43
+ mode?: FocusMode;
44
+ duration?: string;
45
+ remember?: boolean;
46
+ }
47
+ export interface FocusContext {
48
+ current_focus?: Focus;
49
+ entity_type?: EntityType;
50
+ entity_name?: string;
51
+ mode?: FocusMode;
52
+ duration?: string;
53
+ start_time?: string;
54
+ ai_context?: {
55
+ persona?: string;
56
+ knowledge_scope?: string[];
57
+ available_data?: Record<string, any>;
58
+ suggested_actions?: string[];
59
+ restricted_knowledge?: string[];
60
+ };
61
+ }
62
+ export interface HistoryEntry {
63
+ entities: string[];
64
+ timestamp: number;
65
+ }
66
+ export interface Config {
67
+ initialized: boolean;
68
+ entities: Entity[];
69
+ workspace?: string;
70
+ defaultRemote?: string;
71
+ }
72
+ export interface RepoStatus {
73
+ entity: string;
74
+ path: string;
75
+ branch: string;
76
+ ahead: number;
77
+ behind: number;
78
+ changes: string[];
79
+ untracked: string[];
80
+ hasChanges: boolean;
81
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,34 @@
1
+ import { Config, Focus, HistoryEntry, FocusContext } from '../models/entity.model';
2
+ export declare class ConfigService {
3
+ private readonly workspaceRoot;
4
+ private readonly gutDir;
5
+ private readonly focusFile;
6
+ private readonly configFile;
7
+ private readonly historyFile;
8
+ private readonly focusContextFile;
9
+ private readonly focusDir;
10
+ private config;
11
+ private focus;
12
+ private history;
13
+ constructor(workspaceRoot?: string);
14
+ private ensureDirectories;
15
+ private loadAll;
16
+ loadConfig(): Promise<Config>;
17
+ private loadConfigSync;
18
+ private loadFocus;
19
+ private loadHistory;
20
+ getConfig(): Config;
21
+ saveConfig(config: Config): void;
22
+ getFocus(): Focus | null;
23
+ saveFocus(focus: Focus | null): void;
24
+ getHistory(): HistoryEntry[];
25
+ addToHistory(focus: Focus): void;
26
+ clearHistory(): void;
27
+ isInitialized(): boolean;
28
+ getWorkspaceRoot(): string;
29
+ initWorkspace(workspacePath: string): Promise<void>;
30
+ getGutDir(): string;
31
+ saveFocusContext(context: FocusContext): Promise<void>;
32
+ private convertToYaml;
33
+ getFocusDir(): string;
34
+ }