@mytechtoday/augment-extensions 0.1.0 → 0.1.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.
- package/AGENTS.md +83 -3
- package/README.md +6 -5
- package/augment-extensions/coding-standards/python/README.md +44 -0
- package/augment-extensions/coding-standards/python/module.json +26 -0
- package/augment-extensions/coding-standards/python/rules/best-practices.md +232 -0
- package/augment-extensions/coding-standards/python/rules/code-organization.md +220 -0
- package/augment-extensions/coding-standards/python/rules/error-handling.md +221 -0
- package/augment-extensions/coding-standards/python/rules/naming-conventions.md +172 -0
- package/augment-extensions/coding-standards/python/rules/type-hints.md +188 -0
- package/augment-extensions/coding-standards/react/README.md +45 -0
- package/augment-extensions/coding-standards/react/module.json +27 -0
- package/augment-extensions/coding-standards/react/rules/component-patterns.md +214 -0
- package/augment-extensions/coding-standards/react/rules/hooks-best-practices.md +235 -0
- package/augment-extensions/coding-standards/react/rules/performance.md +300 -0
- package/augment-extensions/coding-standards/react/rules/state-management.md +265 -0
- package/augment-extensions/coding-standards/react/rules/typescript-react.md +271 -0
- package/augment-extensions/domain-rules/api-design/README.md +41 -0
- package/augment-extensions/domain-rules/api-design/module.json +27 -0
- package/augment-extensions/domain-rules/api-design/rules/authentication.md +263 -0
- package/augment-extensions/domain-rules/api-design/rules/documentation.md +395 -0
- package/augment-extensions/domain-rules/api-design/rules/error-handling.md +290 -0
- package/augment-extensions/domain-rules/api-design/rules/graphql-api.md +313 -0
- package/augment-extensions/domain-rules/api-design/rules/rest-api.md +214 -0
- package/augment-extensions/domain-rules/api-design/rules/versioning.md +268 -0
- package/augment-extensions/domain-rules/security/README.md +41 -0
- package/augment-extensions/domain-rules/security/module.json +28 -0
- package/augment-extensions/domain-rules/security/rules/authentication-security.md +361 -0
- package/augment-extensions/domain-rules/security/rules/encryption.md +208 -0
- package/augment-extensions/domain-rules/security/rules/input-validation.md +294 -0
- package/augment-extensions/domain-rules/security/rules/owasp-top-10.md +339 -0
- package/augment-extensions/domain-rules/security/rules/secure-coding.md +293 -0
- package/augment-extensions/domain-rules/security/rules/web-security.md +268 -0
- package/augment-extensions/examples/design-patterns/README.md +37 -0
- package/augment-extensions/examples/design-patterns/examples/behavioral-patterns.md +370 -0
- package/augment-extensions/examples/design-patterns/examples/creational-patterns.md +250 -0
- package/augment-extensions/examples/design-patterns/examples/structural-patterns.md +264 -0
- package/augment-extensions/examples/design-patterns/module.json +27 -0
- package/{modules → augment-extensions}/workflows/beads/examples/complete-workflow-example.md +5 -5
- package/{modules → augment-extensions}/workflows/beads/rules/file-format.md +45 -1
- package/{modules → augment-extensions}/workflows/beads/rules/workflow.md +41 -0
- package/{modules → augment-extensions}/workflows/openspec/examples/complete-change-example.md +14 -0
- package/{modules → augment-extensions}/workflows/openspec/rules/spec-format.md +44 -1
- package/{modules → augment-extensions}/workflows/openspec/rules/workflow.md +25 -0
- package/cli/dist/cli.js +64 -0
- package/cli/dist/cli.js.map +1 -1
- package/cli/dist/commands/coord.d.ts +30 -0
- package/cli/dist/commands/coord.d.ts.map +1 -0
- package/cli/dist/commands/coord.js +150 -0
- package/cli/dist/commands/coord.js.map +1 -0
- package/cli/dist/commands/link.js +1 -1
- package/cli/dist/commands/link.js.map +1 -1
- package/cli/dist/commands/list.js +1 -1
- package/cli/dist/commands/list.js.map +1 -1
- package/cli/dist/commands/search.d.ts.map +1 -1
- package/cli/dist/commands/search.js +107 -5
- package/cli/dist/commands/search.js.map +1 -1
- package/cli/dist/commands/show.js +1 -1
- package/cli/dist/commands/show.js.map +1 -1
- package/cli/dist/commands/sync.d.ts +26 -0
- package/cli/dist/commands/sync.d.ts.map +1 -0
- package/cli/dist/commands/sync.js +106 -0
- package/cli/dist/commands/sync.js.map +1 -0
- package/cli/dist/commands/update.d.ts.map +1 -1
- package/cli/dist/commands/update.js +132 -7
- package/cli/dist/commands/update.js.map +1 -1
- package/cli/dist/utils/auto-sync.d.ts +34 -0
- package/cli/dist/utils/auto-sync.d.ts.map +1 -0
- package/cli/dist/utils/auto-sync.js +172 -0
- package/cli/dist/utils/auto-sync.js.map +1 -0
- package/cli/dist/utils/beads-sync.d.ts +51 -0
- package/cli/dist/utils/beads-sync.d.ts.map +1 -0
- package/cli/dist/utils/beads-sync.js +171 -0
- package/cli/dist/utils/beads-sync.js.map +1 -0
- package/cli/dist/utils/coordination-queries.d.ts +79 -0
- package/cli/dist/utils/coordination-queries.d.ts.map +1 -0
- package/cli/dist/utils/coordination-queries.js +155 -0
- package/cli/dist/utils/coordination-queries.js.map +1 -0
- package/cli/dist/utils/file-tracking.d.ts +42 -0
- package/cli/dist/utils/file-tracking.d.ts.map +1 -0
- package/cli/dist/utils/file-tracking.js +155 -0
- package/cli/dist/utils/file-tracking.js.map +1 -0
- package/cli/dist/utils/migrate.d.ts +25 -0
- package/cli/dist/utils/migrate.d.ts.map +1 -0
- package/cli/dist/utils/migrate.js +204 -0
- package/cli/dist/utils/migrate.js.map +1 -0
- package/cli/dist/utils/openspec-sync.d.ts +48 -0
- package/cli/dist/utils/openspec-sync.d.ts.map +1 -0
- package/cli/dist/utils/openspec-sync.js +167 -0
- package/cli/dist/utils/openspec-sync.js.map +1 -0
- package/{MODULES.md → modules.md} +1 -1
- package/package.json +9 -7
- /package/{modules → augment-extensions}/coding-standards/typescript/README.md +0 -0
- /package/{modules → augment-extensions}/coding-standards/typescript/module.json +0 -0
- /package/{modules → augment-extensions}/coding-standards/typescript/rules/naming-conventions.md +0 -0
- /package/{modules → augment-extensions}/workflows/beads/README.md +0 -0
- /package/{modules → augment-extensions}/workflows/beads/module.json +0 -0
- /package/{modules → augment-extensions}/workflows/beads/rules/best-practices.md +0 -0
- /package/{modules → augment-extensions}/workflows/beads/rules/manual-setup.md +0 -0
- /package/{modules → augment-extensions}/workflows/openspec/README.md +0 -0
- /package/{modules → augment-extensions}/workflows/openspec/module.json +0 -0
- /package/{modules → augment-extensions}/workflows/openspec/rules/best-practices.md +0 -0
- /package/{modules → augment-extensions}/workflows/openspec/rules/manual-setup.md +0 -0
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
# Creational Design Patterns
|
|
2
|
+
|
|
3
|
+
Patterns for object creation mechanisms.
|
|
4
|
+
|
|
5
|
+
## Singleton Pattern
|
|
6
|
+
|
|
7
|
+
Ensure a class has only one instance and provide a global access point.
|
|
8
|
+
|
|
9
|
+
### Implementation
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
class Database {
|
|
13
|
+
private static instance: Database;
|
|
14
|
+
private connection: any;
|
|
15
|
+
|
|
16
|
+
private constructor() {
|
|
17
|
+
// Private constructor prevents direct instantiation
|
|
18
|
+
this.connection = this.connect();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public static getInstance(): Database {
|
|
22
|
+
if (!Database.instance) {
|
|
23
|
+
Database.instance = new Database();
|
|
24
|
+
}
|
|
25
|
+
return Database.instance;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
private connect() {
|
|
29
|
+
console.log('Connecting to database...');
|
|
30
|
+
return { connected: true };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public query(sql: string) {
|
|
34
|
+
console.log(`Executing: ${sql}`);
|
|
35
|
+
return this.connection;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Usage
|
|
40
|
+
const db1 = Database.getInstance();
|
|
41
|
+
const db2 = Database.getInstance();
|
|
42
|
+
console.log(db1 === db2); // true - same instance
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Use Cases
|
|
46
|
+
|
|
47
|
+
- Database connections
|
|
48
|
+
- Configuration managers
|
|
49
|
+
- Logging services
|
|
50
|
+
- Cache managers
|
|
51
|
+
|
|
52
|
+
### Pitfalls
|
|
53
|
+
|
|
54
|
+
- Difficult to test (global state)
|
|
55
|
+
- Can hide dependencies
|
|
56
|
+
- Thread safety issues (in multi-threaded environments)
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Factory Pattern
|
|
61
|
+
|
|
62
|
+
Create objects without specifying exact class.
|
|
63
|
+
|
|
64
|
+
### Implementation
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
interface Animal {
|
|
68
|
+
speak(): string;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
class Dog implements Animal {
|
|
72
|
+
speak(): string {
|
|
73
|
+
return 'Woof!';
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
class Cat implements Animal {
|
|
78
|
+
speak(): string {
|
|
79
|
+
return 'Meow!';
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
class AnimalFactory {
|
|
84
|
+
static createAnimal(type: 'dog' | 'cat'): Animal {
|
|
85
|
+
switch (type) {
|
|
86
|
+
case 'dog':
|
|
87
|
+
return new Dog();
|
|
88
|
+
case 'cat':
|
|
89
|
+
return new Cat();
|
|
90
|
+
default:
|
|
91
|
+
throw new Error(`Unknown animal type: ${type}`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Usage
|
|
97
|
+
const dog = AnimalFactory.createAnimal('dog');
|
|
98
|
+
console.log(dog.speak()); // "Woof!"
|
|
99
|
+
|
|
100
|
+
const cat = AnimalFactory.createAnimal('cat');
|
|
101
|
+
console.log(cat.speak()); // "Meow!"
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Use Cases
|
|
105
|
+
|
|
106
|
+
- Creating UI components based on configuration
|
|
107
|
+
- Database connection factories (MySQL, PostgreSQL, etc.)
|
|
108
|
+
- Document parsers (JSON, XML, CSV)
|
|
109
|
+
- Payment processors (Stripe, PayPal, etc.)
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## Builder Pattern
|
|
114
|
+
|
|
115
|
+
Construct complex objects step by step.
|
|
116
|
+
|
|
117
|
+
### Implementation
|
|
118
|
+
|
|
119
|
+
```typescript
|
|
120
|
+
class User {
|
|
121
|
+
constructor(
|
|
122
|
+
public name: string,
|
|
123
|
+
public email: string,
|
|
124
|
+
public age?: number,
|
|
125
|
+
public address?: string,
|
|
126
|
+
public phone?: string
|
|
127
|
+
) {}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
class UserBuilder {
|
|
131
|
+
private name: string = '';
|
|
132
|
+
private email: string = '';
|
|
133
|
+
private age?: number;
|
|
134
|
+
private address?: string;
|
|
135
|
+
private phone?: string;
|
|
136
|
+
|
|
137
|
+
setName(name: string): UserBuilder {
|
|
138
|
+
this.name = name;
|
|
139
|
+
return this;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
setEmail(email: string): UserBuilder {
|
|
143
|
+
this.email = email;
|
|
144
|
+
return this;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
setAge(age: number): UserBuilder {
|
|
148
|
+
this.age = age;
|
|
149
|
+
return this;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
setAddress(address: string): UserBuilder {
|
|
153
|
+
this.address = address;
|
|
154
|
+
return this;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
setPhone(phone: string): UserBuilder {
|
|
158
|
+
this.phone = phone;
|
|
159
|
+
return this;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
build(): User {
|
|
163
|
+
if (!this.name || !this.email) {
|
|
164
|
+
throw new Error('Name and email are required');
|
|
165
|
+
}
|
|
166
|
+
return new User(this.name, this.email, this.age, this.address, this.phone);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// Usage
|
|
171
|
+
const user = new UserBuilder()
|
|
172
|
+
.setName('John Doe')
|
|
173
|
+
.setEmail('john@example.com')
|
|
174
|
+
.setAge(30)
|
|
175
|
+
.setAddress('123 Main St')
|
|
176
|
+
.build();
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Use Cases
|
|
180
|
+
|
|
181
|
+
- Building complex configuration objects
|
|
182
|
+
- Creating HTTP requests
|
|
183
|
+
- Constructing SQL queries
|
|
184
|
+
- Building UI components with many options
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## Prototype Pattern
|
|
189
|
+
|
|
190
|
+
Create new objects by cloning existing ones.
|
|
191
|
+
|
|
192
|
+
### Implementation
|
|
193
|
+
|
|
194
|
+
```typescript
|
|
195
|
+
interface Cloneable<T> {
|
|
196
|
+
clone(): T;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
class Shape implements Cloneable<Shape> {
|
|
200
|
+
constructor(
|
|
201
|
+
public x: number,
|
|
202
|
+
public y: number,
|
|
203
|
+
public color: string
|
|
204
|
+
) {}
|
|
205
|
+
|
|
206
|
+
clone(): Shape {
|
|
207
|
+
return new Shape(this.x, this.y, this.color);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
class Circle extends Shape {
|
|
212
|
+
constructor(
|
|
213
|
+
x: number,
|
|
214
|
+
y: number,
|
|
215
|
+
color: string,
|
|
216
|
+
public radius: number
|
|
217
|
+
) {
|
|
218
|
+
super(x, y, color);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
clone(): Circle {
|
|
222
|
+
return new Circle(this.x, this.y, this.color, this.radius);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// Usage
|
|
227
|
+
const originalCircle = new Circle(10, 20, 'red', 5);
|
|
228
|
+
const clonedCircle = originalCircle.clone();
|
|
229
|
+
|
|
230
|
+
clonedCircle.x = 30;
|
|
231
|
+
clonedCircle.color = 'blue';
|
|
232
|
+
|
|
233
|
+
console.log(originalCircle); // Circle { x: 10, y: 20, color: 'red', radius: 5 }
|
|
234
|
+
console.log(clonedCircle); // Circle { x: 30, y: 20, color: 'blue', radius: 5 }
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### Use Cases
|
|
238
|
+
|
|
239
|
+
- Cloning game objects
|
|
240
|
+
- Creating template objects
|
|
241
|
+
- Avoiding expensive initialization
|
|
242
|
+
- Creating variations of objects
|
|
243
|
+
|
|
244
|
+
### Best Practices
|
|
245
|
+
|
|
246
|
+
1. **Singleton**: Use sparingly, prefer dependency injection
|
|
247
|
+
2. **Factory**: Use when object creation logic is complex
|
|
248
|
+
3. **Builder**: Use for objects with many optional parameters
|
|
249
|
+
4. **Prototype**: Use when cloning is cheaper than creating new
|
|
250
|
+
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
# Structural Design Patterns
|
|
2
|
+
|
|
3
|
+
Patterns for composing classes and objects.
|
|
4
|
+
|
|
5
|
+
## Adapter Pattern
|
|
6
|
+
|
|
7
|
+
Convert interface of a class into another interface clients expect.
|
|
8
|
+
|
|
9
|
+
### Implementation
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
// Old API
|
|
13
|
+
class OldPaymentProcessor {
|
|
14
|
+
processPayment(amount: number): void {
|
|
15
|
+
console.log(`Processing $${amount} via old system`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// New API interface
|
|
20
|
+
interface PaymentGateway {
|
|
21
|
+
pay(amount: number, currency: string): void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Adapter
|
|
25
|
+
class PaymentAdapter implements PaymentGateway {
|
|
26
|
+
constructor(private oldProcessor: OldPaymentProcessor) {}
|
|
27
|
+
|
|
28
|
+
pay(amount: number, currency: string): void {
|
|
29
|
+
// Convert new API call to old API call
|
|
30
|
+
console.log(`Converting ${currency} payment`);
|
|
31
|
+
this.oldProcessor.processPayment(amount);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Usage
|
|
36
|
+
const oldProcessor = new OldPaymentProcessor();
|
|
37
|
+
const adapter = new PaymentAdapter(oldProcessor);
|
|
38
|
+
adapter.pay(100, 'USD');
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Use Cases
|
|
42
|
+
|
|
43
|
+
- Integrating third-party libraries
|
|
44
|
+
- Working with legacy code
|
|
45
|
+
- API versioning
|
|
46
|
+
- Database adapters
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Decorator Pattern
|
|
51
|
+
|
|
52
|
+
Add new functionality to objects dynamically.
|
|
53
|
+
|
|
54
|
+
### Implementation
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
interface Coffee {
|
|
58
|
+
cost(): number;
|
|
59
|
+
description(): string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
class SimpleCoffee implements Coffee {
|
|
63
|
+
cost(): number {
|
|
64
|
+
return 5;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
description(): string {
|
|
68
|
+
return 'Simple coffee';
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Decorator base class
|
|
73
|
+
abstract class CoffeeDecorator implements Coffee {
|
|
74
|
+
constructor(protected coffee: Coffee) {}
|
|
75
|
+
|
|
76
|
+
abstract cost(): number;
|
|
77
|
+
abstract description(): string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
class MilkDecorator extends CoffeeDecorator {
|
|
81
|
+
cost(): number {
|
|
82
|
+
return this.coffee.cost() + 1;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
description(): string {
|
|
86
|
+
return this.coffee.description() + ', milk';
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
class SugarDecorator extends CoffeeDecorator {
|
|
91
|
+
cost(): number {
|
|
92
|
+
return this.coffee.cost() + 0.5;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
description(): string {
|
|
96
|
+
return this.coffee.description() + ', sugar';
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Usage
|
|
101
|
+
let coffee: Coffee = new SimpleCoffee();
|
|
102
|
+
console.log(`${coffee.description()}: $${coffee.cost()}`);
|
|
103
|
+
// "Simple coffee: $5"
|
|
104
|
+
|
|
105
|
+
coffee = new MilkDecorator(coffee);
|
|
106
|
+
console.log(`${coffee.description()}: $${coffee.cost()}`);
|
|
107
|
+
// "Simple coffee, milk: $6"
|
|
108
|
+
|
|
109
|
+
coffee = new SugarDecorator(coffee);
|
|
110
|
+
console.log(`${coffee.description()}: $${coffee.cost()}`);
|
|
111
|
+
// "Simple coffee, milk, sugar: $6.5"
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Use Cases
|
|
115
|
+
|
|
116
|
+
- Adding features to objects at runtime
|
|
117
|
+
- Middleware in web frameworks
|
|
118
|
+
- Stream processing (compression, encryption)
|
|
119
|
+
- UI component enhancement
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## Facade Pattern
|
|
124
|
+
|
|
125
|
+
Provide simplified interface to complex subsystem.
|
|
126
|
+
|
|
127
|
+
### Implementation
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
// Complex subsystems
|
|
131
|
+
class CPU {
|
|
132
|
+
freeze(): void {
|
|
133
|
+
console.log('CPU: Freezing...');
|
|
134
|
+
}
|
|
135
|
+
jump(position: number): void {
|
|
136
|
+
console.log(`CPU: Jumping to ${position}`);
|
|
137
|
+
}
|
|
138
|
+
execute(): void {
|
|
139
|
+
console.log('CPU: Executing...');
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
class Memory {
|
|
144
|
+
load(position: number, data: string): void {
|
|
145
|
+
console.log(`Memory: Loading ${data} at ${position}`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
class HardDrive {
|
|
150
|
+
read(sector: number, size: number): string {
|
|
151
|
+
console.log(`HardDrive: Reading sector ${sector}, size ${size}`);
|
|
152
|
+
return 'boot data';
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Facade
|
|
157
|
+
class ComputerFacade {
|
|
158
|
+
private cpu: CPU;
|
|
159
|
+
private memory: Memory;
|
|
160
|
+
private hardDrive: HardDrive;
|
|
161
|
+
|
|
162
|
+
constructor() {
|
|
163
|
+
this.cpu = new CPU();
|
|
164
|
+
this.memory = new Memory();
|
|
165
|
+
this.hardDrive = new HardDrive();
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
start(): void {
|
|
169
|
+
console.log('Computer: Starting...');
|
|
170
|
+
this.cpu.freeze();
|
|
171
|
+
const bootData = this.hardDrive.read(0, 1024);
|
|
172
|
+
this.memory.load(0, bootData);
|
|
173
|
+
this.cpu.jump(0);
|
|
174
|
+
this.cpu.execute();
|
|
175
|
+
console.log('Computer: Started!');
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// Usage
|
|
180
|
+
const computer = new ComputerFacade();
|
|
181
|
+
computer.start(); // Simple interface hides complexity
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Use Cases
|
|
185
|
+
|
|
186
|
+
- Simplifying complex libraries
|
|
187
|
+
- API wrappers
|
|
188
|
+
- Database access layers
|
|
189
|
+
- Service orchestration
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## Proxy Pattern
|
|
194
|
+
|
|
195
|
+
Provide placeholder for another object to control access.
|
|
196
|
+
|
|
197
|
+
### Implementation
|
|
198
|
+
|
|
199
|
+
```typescript
|
|
200
|
+
interface Image {
|
|
201
|
+
display(): void;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
class RealImage implements Image {
|
|
205
|
+
constructor(private filename: string) {
|
|
206
|
+
this.loadFromDisk();
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
private loadFromDisk(): void {
|
|
210
|
+
console.log(`Loading image: ${this.filename}`);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
display(): void {
|
|
214
|
+
console.log(`Displaying image: ${this.filename}`);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
class ImageProxy implements Image {
|
|
219
|
+
private realImage: RealImage | null = null;
|
|
220
|
+
|
|
221
|
+
constructor(private filename: string) {}
|
|
222
|
+
|
|
223
|
+
display(): void {
|
|
224
|
+
// Lazy loading - only create real image when needed
|
|
225
|
+
if (!this.realImage) {
|
|
226
|
+
this.realImage = new RealImage(this.filename);
|
|
227
|
+
}
|
|
228
|
+
this.realImage.display();
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// Usage
|
|
233
|
+
const image1 = new ImageProxy('photo1.jpg');
|
|
234
|
+
const image2 = new ImageProxy('photo2.jpg');
|
|
235
|
+
|
|
236
|
+
// Images not loaded yet
|
|
237
|
+
console.log('Images created');
|
|
238
|
+
|
|
239
|
+
// Load and display only when needed
|
|
240
|
+
image1.display(); // Loads and displays
|
|
241
|
+
image1.display(); // Just displays (already loaded)
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### Types of Proxies
|
|
245
|
+
|
|
246
|
+
1. **Virtual Proxy**: Lazy initialization (example above)
|
|
247
|
+
2. **Protection Proxy**: Access control
|
|
248
|
+
3. **Remote Proxy**: Remote object representation
|
|
249
|
+
4. **Caching Proxy**: Cache results
|
|
250
|
+
|
|
251
|
+
### Use Cases
|
|
252
|
+
|
|
253
|
+
- Lazy loading of resources
|
|
254
|
+
- Access control and authentication
|
|
255
|
+
- Logging and monitoring
|
|
256
|
+
- Caching expensive operations
|
|
257
|
+
|
|
258
|
+
### Best Practices
|
|
259
|
+
|
|
260
|
+
1. **Adapter**: Use when interfaces are incompatible
|
|
261
|
+
2. **Decorator**: Use to add responsibilities dynamically
|
|
262
|
+
3. **Facade**: Use to simplify complex subsystems
|
|
263
|
+
4. **Proxy**: Use to control access or add lazy loading
|
|
264
|
+
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "design-patterns",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"displayName": "Design Patterns Examples",
|
|
5
|
+
"description": "Common design patterns with TypeScript/JavaScript implementations and use cases",
|
|
6
|
+
"type": "examples",
|
|
7
|
+
"author": "Augment Extensions",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"augment": {
|
|
10
|
+
"characterCount": 42000,
|
|
11
|
+
"priority": "medium",
|
|
12
|
+
"category": "examples"
|
|
13
|
+
},
|
|
14
|
+
"installation": {
|
|
15
|
+
"required": false,
|
|
16
|
+
"dependencies": []
|
|
17
|
+
},
|
|
18
|
+
"tags": [
|
|
19
|
+
"design-patterns",
|
|
20
|
+
"typescript",
|
|
21
|
+
"javascript",
|
|
22
|
+
"oop",
|
|
23
|
+
"architecture",
|
|
24
|
+
"examples"
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
|
package/{modules → augment-extensions}/workflows/beads/examples/complete-workflow-example.md
RENAMED
|
@@ -29,7 +29,7 @@ bd create "User Authentication System" -p 0
|
|
|
29
29
|
**Without CLI** - Append to `.beads/issues.jsonl`:
|
|
30
30
|
|
|
31
31
|
```json
|
|
32
|
-
{"id":"bd-a3f8","title":"User Authentication System","status":"open","priority":0,"created":"2024-01-20T10:00:00Z","updated":"2024-01-20T10:00:00Z"}
|
|
32
|
+
{"id":"bd-a3f8","title":"User Authentication System","status":"open","priority":0,"spec":"features/authentication","rules":["security-guidelines.md"],"created":"2024-01-20T10:00:00Z","updated":"2024-01-20T10:00:00Z"}
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
## Step 3: Create Tasks
|
|
@@ -52,10 +52,10 @@ bd create "Add login endpoint" -p 1 --parent bd-a3f8
|
|
|
52
52
|
**Without CLI** - Append to `.beads/issues.jsonl`:
|
|
53
53
|
|
|
54
54
|
```jsonl
|
|
55
|
-
{"id":"bd-a3f8.1","title":"Add database schema","status":"open","priority":0,"parent":"bd-a3f8","created":"2024-01-20T10:01:00Z","updated":"2024-01-20T10:01:00Z"}
|
|
56
|
-
{"id":"bd-a3f8.2","title":"Add password hashing","status":"open","priority":1,"parent":"bd-a3f8","created":"2024-01-20T10:02:00Z","updated":"2024-01-20T10:02:00Z"}
|
|
57
|
-
{"id":"bd-a3f8.3","title":"Add JWT generation","status":"open","priority":1,"parent":"bd-a3f8","created":"2024-01-20T10:03:00Z","updated":"2024-01-20T10:03:00Z"}
|
|
58
|
-
{"id":"bd-a3f8.4","title":"Add login endpoint","status":"open","priority":1,"parent":"bd-a3f8","created":"2024-01-20T10:04:00Z","updated":"2024-01-20T10:04:00Z"}
|
|
55
|
+
{"id":"bd-a3f8.1","title":"Add database schema","status":"open","priority":0,"parent":"bd-a3f8","spec":"features/authentication","rules":["module-development.md"],"created":"2024-01-20T10:01:00Z","updated":"2024-01-20T10:01:00Z"}
|
|
56
|
+
{"id":"bd-a3f8.2","title":"Add password hashing","status":"open","priority":1,"parent":"bd-a3f8","spec":"features/authentication","rules":["security-guidelines.md"],"created":"2024-01-20T10:02:00Z","updated":"2024-01-20T10:02:00Z"}
|
|
57
|
+
{"id":"bd-a3f8.3","title":"Add JWT generation","status":"open","priority":1,"parent":"bd-a3f8","spec":"features/authentication","rules":["security-guidelines.md"],"created":"2024-01-20T10:03:00Z","updated":"2024-01-20T10:03:00Z"}
|
|
58
|
+
{"id":"bd-a3f8.4","title":"Add login endpoint","status":"open","priority":1,"parent":"bd-a3f8","spec":"features/authentication","rules":["module-development.md","security-guidelines.md"],"created":"2024-01-20T10:04:00Z","updated":"2024-01-20T10:04:00Z"}
|
|
59
59
|
```
|
|
60
60
|
|
|
61
61
|
## Step 4: Add Dependencies
|
|
@@ -43,6 +43,8 @@ Beads stores issues in `.beads/issues.jsonl` using JSONL (JSON Lines) format. Ea
|
|
|
43
43
|
"blocked_by": [],
|
|
44
44
|
"related": ["bd-d4e5"],
|
|
45
45
|
"parent": null,
|
|
46
|
+
"spec": "features/authentication",
|
|
47
|
+
"rules": ["module-development.md", "security-guidelines.md"],
|
|
46
48
|
"comments": [
|
|
47
49
|
{
|
|
48
50
|
"text": "Started implementation",
|
|
@@ -78,6 +80,8 @@ Beads stores issues in `.beads/issues.jsonl` using JSONL (JSON Lines) format. Ea
|
|
|
78
80
|
- **parent** (string): ID of parent task (for hierarchical IDs)
|
|
79
81
|
- **comments** (array of objects): Comments and updates
|
|
80
82
|
- **closed** (string): ISO 8601 timestamp when closed
|
|
83
|
+
- **spec** (string): OpenSpec specification ID this task implements (e.g., "features/authentication")
|
|
84
|
+
- **rules** (array of strings): `.augment/` rule files that apply to this task (e.g., ["module-development.md"])
|
|
81
85
|
|
|
82
86
|
## ID Format
|
|
83
87
|
|
|
@@ -116,6 +120,46 @@ bd-a3f8.2 # Another task under epic
|
|
|
116
120
|
- **2** - Medium (P2) - default
|
|
117
121
|
- **3** - Low (P3)
|
|
118
122
|
|
|
123
|
+
## Coordination Fields
|
|
124
|
+
|
|
125
|
+
### spec
|
|
126
|
+
|
|
127
|
+
References an OpenSpec specification that this task implements:
|
|
128
|
+
|
|
129
|
+
```json
|
|
130
|
+
{
|
|
131
|
+
"id": "bd-a1b2",
|
|
132
|
+
"title": "Add authentication API",
|
|
133
|
+
"spec": "features/authentication"
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
The `spec` field links the task to an OpenSpec specification file (e.g., `openspec/specs/features/authentication.md`). This enables:
|
|
138
|
+
- Automatic traceability from spec to implementation
|
|
139
|
+
- Discovery of all tasks implementing a spec
|
|
140
|
+
- Coordination manifest integration
|
|
141
|
+
|
|
142
|
+
### rules
|
|
143
|
+
|
|
144
|
+
Lists `.augment/` rule files that apply to this task:
|
|
145
|
+
|
|
146
|
+
```json
|
|
147
|
+
{
|
|
148
|
+
"id": "bd-a1b2",
|
|
149
|
+
"title": "Add authentication API",
|
|
150
|
+
"rules": ["module-development.md", "security-guidelines.md"]
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
The `rules` field helps AI agents:
|
|
155
|
+
- Load relevant coding standards and guidelines
|
|
156
|
+
- Apply appropriate validation rules
|
|
157
|
+
- Maintain consistency across tasks
|
|
158
|
+
|
|
159
|
+
**Note**: These fields are optional and backward compatible. Existing tasks without these fields continue to work normally.
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
119
163
|
## Dependency Types
|
|
120
164
|
|
|
121
165
|
### blocks
|
|
@@ -254,7 +298,7 @@ echo '{"id":"bd-a1b2","title":"New task","status":"open","created":"2024-01-20T1
|
|
|
254
298
|
### Create Task
|
|
255
299
|
|
|
256
300
|
```jsonl
|
|
257
|
-
{"id":"bd-a1b2","title":"Add authentication","status":"open","priority":0,"created":"2024-01-20T10:00:00Z","updated":"2024-01-20T10:00:00Z"}
|
|
301
|
+
{"id":"bd-a1b2","title":"Add authentication","status":"open","priority":0,"spec":"features/authentication","rules":["module-development.md"],"created":"2024-01-20T10:00:00Z","updated":"2024-01-20T10:00:00Z"}
|
|
258
302
|
```
|
|
259
303
|
|
|
260
304
|
### Add Dependency
|
|
@@ -4,6 +4,27 @@
|
|
|
4
4
|
|
|
5
5
|
Beads provides a git-backed issue tracker optimized for AI agents. Issues are stored as JSONL (JSON Lines) in `.beads/issues.jsonl`, making them version-controlled, mergeable, and agent-readable.
|
|
6
6
|
|
|
7
|
+
## Naming Convention
|
|
8
|
+
|
|
9
|
+
All Beads issues in this project use the **"bd-" prefix**.
|
|
10
|
+
|
|
11
|
+
### Standard Format
|
|
12
|
+
|
|
13
|
+
- `bd-<hash>` - Standard hash-based ID (e.g., `bd-a1b2`)
|
|
14
|
+
- `bd-<name>` - Named ID for important tasks (e.g., `bd-init`, `bd-rename1`)
|
|
15
|
+
- `bd-<hash>.<number>` - Hierarchical ID (e.g., `bd-a1b2.1`)
|
|
16
|
+
|
|
17
|
+
### Why "bd"?
|
|
18
|
+
|
|
19
|
+
- **Brevity**: Short and memorable (2 characters)
|
|
20
|
+
- **Clarity**: Clearly identifies Beads issues
|
|
21
|
+
- **Consistency**: Single prefix across all issues
|
|
22
|
+
- **Git-Friendly**: Reduces commit message length
|
|
23
|
+
|
|
24
|
+
### Validation
|
|
25
|
+
|
|
26
|
+
All new issues are validated to ensure they use the "bd-" prefix. See `openspec/specs/beads/naming-convention.md` for complete specification.
|
|
27
|
+
|
|
7
28
|
## Core Workflow
|
|
8
29
|
|
|
9
30
|
```
|
|
@@ -37,6 +58,26 @@ Beads provides a git-backed issue tracker optimized for AI agents. Issues are st
|
|
|
37
58
|
└─────────────────┘
|
|
38
59
|
```
|
|
39
60
|
|
|
61
|
+
## Coordination with OpenSpec and .augment/
|
|
62
|
+
|
|
63
|
+
Beads tasks can reference OpenSpec specifications and `.augment/` rules for better coordination:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# Create task with spec and rules
|
|
67
|
+
bd create "Implement authentication" -p 1
|
|
68
|
+
# Then manually add spec and rules fields to .beads/issues.jsonl:
|
|
69
|
+
# {"id":"bd-xyz","spec":"features/authentication","rules":["security-guidelines.md"],"updated":"..."}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**Benefits**:
|
|
73
|
+
- **Traceability**: Link tasks to specifications
|
|
74
|
+
- **Context**: AI agents load relevant rules automatically
|
|
75
|
+
- **Coordination**: Integration with coordination manifest
|
|
76
|
+
|
|
77
|
+
See `.augment/rules/coordination-system.md` for details.
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
40
81
|
## Step 1: Initialize Beads
|
|
41
82
|
|
|
42
83
|
### With CLI
|