@gitgov/core 1.0.0 โ†’ 1.0.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.
Files changed (2) hide show
  1. package/README.md +130 -126
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -4,66 +4,86 @@
4
4
  [![License: MPL-2.0](https://img.shields.io/badge/License-MPL%202.0-brightgreen.svg)](https://opensource.org/licenses/MPL-2.0)
5
5
  [![TypeScript](https://img.shields.io/badge/TypeScript-strict-blue.svg)](./tsconfig.json)
6
6
 
7
- `@gitgov/core` is the **universal SDK** for the GitGovernance ecosystem. It provides a type-safe, local-first, and schema-driven API to manage identities, agents, and workflows in software projects.
7
+ `@gitgov/core` is the **SDK** for the GitGovernance ecosystem. It provides a type-safe, local-first, and schema-driven API to manage identities, agents, and workflows in software projects.
8
8
 
9
9
  ## ๐Ÿš€ Quick Start
10
10
 
11
- This example initializes a complete GitGovernance project in a new directory, creating the necessary configuration, the first user actor, and a root cycle for tasks.
11
+ This example shows how to create a new task using the `BacklogAdapter`. The SDK uses dependency injection - each adapter requires its dependencies to be explicitly provided.
12
12
 
13
- ```typescript
14
- import {
15
- ProjectAdapter,
16
- ConfigManager,
17
- RecordStore,
18
- IdentityAdapter,
19
- BacklogAdapter,
20
- WorkflowMethodologyAdapter,
21
- } from "@gitgov/core";
22
- import path from "path";
23
- import fs from "fs/promises";
13
+ *Note: This example assumes it is run inside an initialized GitGovernance project.*
24
14
 
25
- // 1. Instantiate all core adapters and their dependencies
26
- const identityAdapter = new IdentityAdapter();
27
- const backlogAdapter = new BacklogAdapter({
28
- taskStore: new RecordStore("tasks"),
29
- cycleStore: new RecordStore("cycles"),
30
- workflowMethodology: new WorkflowMethodologyAdapter(),
31
- identity: identityAdapter,
32
- });
33
- const projectAdapter = new ProjectAdapter({
34
- identityAdapter,
35
- backlogAdapter,
36
- workflowMethodologyAdapter: new WorkflowMethodologyAdapter(),
37
- configManager: new ConfigManager(),
38
- taskStore: new RecordStore("tasks"),
39
- cycleStore: new RecordStore("cycles"),
15
+ ```typescript
16
+ import { Adapters, Store, EventBus } from "@gitgov/core";
17
+ import type { TaskRecord, CycleRecord, ActorRecord, AgentRecord } from "@gitgov/core";
18
+
19
+ // Extract classes from namespaces
20
+ const { IdentityAdapter, BacklogAdapter, WorkflowMethodologyAdapter } = Adapters;
21
+ const { RecordStore } = Store;
22
+ const { EventBus: EventBusClass } = EventBus;
23
+
24
+ // 1. Setup core infrastructure
25
+ const eventBus = new EventBusClass();
26
+ const actorStore = new RecordStore<ActorRecord>("actors");
27
+ const agentStore = new RecordStore<AgentRecord>("agents");
28
+ const taskStore = new RecordStore<TaskRecord>("tasks");
29
+ const cycleStore = new RecordStore<CycleRecord>("cycles");
30
+
31
+ // 2. Setup identity adapter
32
+ const identity = new IdentityAdapter({
33
+ actorStore,
34
+ agentStore,
40
35
  });
41
36
 
42
- // 2. Validate environment and initialize the project
43
- const validation = await projectAdapter.validateEnvironment();
44
- if (!validation.isValid) {
45
- console.error("Environment issues:", validation.warnings);
46
- process.exit(1);
47
- }
37
+ // 3. Setup workflow methodology
38
+ const workflowMethodology = WorkflowMethodologyAdapter.createDefault();
48
39
 
49
- const result = await projectAdapter.initializeProject({
50
- name: "My GitGovernance Project",
51
- actorName: "Project Owner",
40
+ // 4. Setup BacklogAdapter with minimal dependencies for basic task creation
41
+ const backlogAdapter = new BacklogAdapter({
42
+ taskStore,
43
+ cycleStore,
44
+ identity,
45
+ eventBus,
46
+ workflowMethodologyAdapter: workflowMethodology,
47
+ // Optional dependencies (can be undefined for basic usage)
48
+ feedbackStore: undefined,
49
+ executionStore: undefined,
50
+ changelogStore: undefined,
51
+ feedbackAdapter: undefined,
52
+ executionAdapter: undefined,
53
+ changelogAdapter: undefined,
54
+ metricsAdapter: undefined,
52
55
  });
53
56
 
54
- // 3. Project is now ready!
55
- console.log(`โœ… Project initialized: ${result.projectId}`);
56
- console.log(`๐Ÿ”— Root cycle: ${result.rootCycle}`);
57
- console.log(
58
- `๐Ÿ‘ค Actor created: ${result.actor.displayName} (${result.actor.id})`
57
+ // 5. Create a new task
58
+ const newTaskPayload = {
59
+ title: "Implement user authentication",
60
+ priority: "high",
61
+ description: "Add OAuth2 integration for Google and GitHub.",
62
+ };
63
+
64
+ const taskRecord = await backlogAdapter.createTask(
65
+ newTaskPayload,
66
+ "human:project-lead" // The actor performing the action
59
67
  );
60
68
 
69
+ console.log("โœ… Task Created Successfully:");
70
+ console.log({
71
+ id: taskRecord.id,
72
+ title: taskRecord.title,
73
+ status: taskRecord.status, // The adapter sets the default status
74
+ });
75
+
61
76
  // Expected output:
62
- // โœ… Project initialized: my-gitgovernance-project
63
- // ๐Ÿ”— Root cycle: cycle:my-gitgovernance-project.root
64
- // ๐Ÿ‘ค Actor created: Project Owner (human:project-owner)
77
+ // โœ… Task Created Successfully:
78
+ // {
79
+ // id: 'task:1727445600000-implement-user-authentication',
80
+ // title: 'Implement user authentication',
81
+ // status: 'draft'
82
+ // }
65
83
  ```
66
84
 
85
+ > **๐Ÿ’ก For production usage:** See the [complete setup example](../../blueprints/03_products/core/core_reference.md#quick-start) with all adapters and dependencies properly configured.
86
+
67
87
  ## โœ… What's Implemented (v1.0)
68
88
 
69
89
  ### Identity Management (Complete)
@@ -74,17 +94,19 @@ console.log(
74
94
  - **Schema Validation**: JSON Schema-driven with detailed errors
75
95
  - **Performance**: Schema validation caching
76
96
 
77
- ### Complete Adapter Ecosystem (7/7 Adapters)
97
+ ### Complete Adapter Ecosystem (9/9 Adapters)
78
98
 
79
- - **ProjectAdapter**: Project initialization engine with 3-adapter orchestration (โœ… Implemented)
80
- - **BacklogAdapter**: Task and cycle lifecycle management with workflow validation (โœ… Implemented)
81
- - **MetricsAdapter**: Pure calculation engine for system analytics (โœ… Implemented)
82
- - **ChangelogAdapter**: System historian for change documentation (โœ… Implemented)
83
- - **ExecutionAdapter**: Immutable audit log for work execution (โœ… Implemented)
84
- - **FeedbackAdapter**: Structured communication and blocking management (โœ… Implemented)
85
- - **IdentityAdapter**: Cryptographic identity and agent management (โœ… Implemented)
99
+ - **ProjectAdapter**: Project initialization engine with 3-adapter orchestration (โœ… Implemented - 18 tests)
100
+ - **BacklogAdapter**: Task and cycle lifecycle management with workflow validation (โœ… Implemented - 43 tests)
101
+ - **MetricsAdapter**: Pure calculation engine for system analytics (โœ… Implemented - 32 tests)
102
+ - **ChangelogAdapter**: System historian for change documentation (โœ… Implemented - 31 tests)
103
+ - **ExecutionAdapter**: Immutable audit log for work execution (โœ… Implemented - 13 tests)
104
+ - **FeedbackAdapter**: Structured communication and blocking management (โœ… Implemented - 15 tests)
105
+ - **IdentityAdapter**: Cryptographic identity and agent management (โœ… Implemented - 25 tests)
106
+ - **WorkflowMethodologyAdapter**: Configurable workflow validation engine (โœ… Implemented - 51 tests)
107
+ - **IndexerAdapter**: Local cache optimization for performance (โœ… Implemented - 5 tests)
86
108
 
87
- ### Complete Record System (7/7 Records)
109
+ ### Complete Record System (8/8 Records)
88
110
 
89
111
  - **TaskRecord**: Factory and validation for task management
90
112
  - **CycleRecord**: Factory and validation for cycle organization
@@ -100,42 +122,8 @@ console.log(
100
122
  - **Integration Testing**: Cross-module validation framework
101
123
  - **WorkflowMethodologyAdapter**: Configurable workflow validation engine (โœ… Implemented)
102
124
  - **EventBusModule**: Event-driven architecture foundation with 9 event types (โœ… Implemented)
103
-
104
- ```typescript
105
- // Complete project initialization workflow
106
- const projectAdapter = new ProjectAdapter({
107
- identityAdapter: new IdentityAdapter(),
108
- backlogAdapter: new BacklogAdapter(/* dependencies */),
109
- workflowMethodologyAdapter: new WorkflowMethodologyAdapter(),
110
- configManager: new ConfigManager(),
111
- taskStore: new RecordStore("tasks"),
112
- cycleStore: new RecordStore("cycles"),
113
- });
114
-
115
- // 1. Validate environment
116
- const validation = await projectAdapter.validateEnvironment();
117
- if (!validation.isValid) {
118
- console.error("Environment issues:", validation.warnings);
119
- process.exit(1);
120
- }
121
-
122
- // 2. Initialize complete project
123
- const result = await projectAdapter.initializeProject({
124
- name: "My GitGovernance Project",
125
- actorName: "Project Owner",
126
- template: "./templates/basic.json",
127
- methodology: "scrum",
128
- });
129
-
130
- // 3. Project is now ready
131
- console.log(`โœ… Project initialized: ${result.projectId}`);
132
- console.log(`๐Ÿ”— Root cycle: ${result.rootCycle}`);
133
- console.log(`๐Ÿ‘ค Actor: ${result.actor.displayName}`);
134
-
135
- // 4. Get project information
136
- const projectInfo = await projectAdapter.getProjectInfo();
137
- console.log(`๐Ÿ“Š Project: ${projectInfo?.name}`);
138
- ```
125
+ - **DiagramGenerator**: Automatic Mermaid diagram generation with deduplication and data quality warnings (โœ… Implemented)
126
+ - **Schema Generation Pipeline**: Automatic YAMLโ†’JSONโ†’TypeScript transformation with build-time validation (โœ… Implemented)
139
127
 
140
128
  ## ๐Ÿ—๏ธ Architecture
141
129
 
@@ -171,11 +159,12 @@ graph TD
171
159
  ### Core Principles
172
160
 
173
161
  1. **Protocol-Driven**: The canonical JSON Schemas that define the governance protocol are bundled with the package and are the single source of truth for all data validation.
174
- 2. **Type Safety**: Strict TypeScript with no `any` to prevent compile-time errors.
175
- 3. **Event Coherence Guarantee**: Event payloads are derived from canonical records using TypeScript Utility Types, ensuring 100% consistency between system state and system events.
176
- 4. **Rich Errors**: Detailed, field-level validation errors to make debugging easier.
177
- 5. **Performance**: A compiled schema cache (`SchemaValidationCache`) minimizes I/O and accelerates repetitive validations.
178
- 6. **Local-First**: Designed to operate directly on a Git repository as its database.
162
+ 2. **Build-Time Generation**: Schemas and types are automatically generated from YAML protocols using `npm run prebuild` (complete pipeline) or individual commands, ensuring 100% coherence.
163
+ 3. **Type Safety**: Strict TypeScript with no `any` to prevent compile-time errors.
164
+ 4. **Event Coherence Guarantee**: Event payloads are derived from canonical records using TypeScript Utility Types, ensuring 100% consistency between system state and system events.
165
+ 5. **Rich Errors**: Detailed, field-level validation errors to make debugging easier.
166
+ 6. **Performance**: A compiled schema cache (`SchemaValidationCache`) minimizes I/O and accelerates repetitive validations.
167
+ 7. **Local-First**: Designed to operate directly on a Git repository as its database.
179
168
 
180
169
  ## ๐Ÿ”ง Advanced Usage
181
170
 
@@ -230,11 +219,43 @@ console.log(`Cache hit ratio: ${stats.cachedSchemas} schemas loaded`);
230
219
  SchemaValidationCache.clearCache();
231
220
  ```
232
221
 
222
+ ### Diagram Generation
223
+
224
+ ```typescript
225
+ import { DiagramGenerator } from "@gitgov/core";
226
+
227
+ const generator = new DiagramGenerator();
228
+
229
+ // Generate Mermaid diagrams from GitGovernance records
230
+ const result = await generator.generateFromRecords(cycles, tasks, {
231
+ cycleId: "1704067200-cycle-identity-adapter",
232
+ layout: 'TD',
233
+ showWarnings: true,
234
+ });
235
+
236
+ console.log(result.mermaidCode);
237
+ // Automatic deduplication and data quality warnings included
238
+ ```
239
+
233
240
  ## ๐Ÿงช Testing & Development
234
241
 
235
242
  ```bash
236
- # Run all tests (500+ passing)
243
+ # Run all tests (704 tests total)
237
244
  npm test
245
+ npm run test:coverage # Run tests with coverage report
246
+
247
+ # Build-time schema and type generation
248
+ npm run sync:schemas # Generate JSON schemas from YAML protocols
249
+ npm run sync:workflow-configs # Sync workflow methodology configurations
250
+ npm run compile:types # Generate TypeScript types from JSON schemas
251
+ npm run generate:indexes # Generate organized export indexes
252
+ npm run validate:schemas # Validate all generated schemas
253
+
254
+ # Development workflow
255
+ npm run prebuild # Complete pipeline: sync โ†’ compile โ†’ generate
256
+ npm run build # Clean build with TypeScript compilation
257
+ npm run clean # Remove dist directory
258
+ npm run clean:generated # Remove all generated schemas and types
238
259
 
239
260
  # Type checking
240
261
  npx tsc --noEmit
@@ -245,7 +266,7 @@ npm test -- --watch
245
266
 
246
267
  ### Test Coverage
247
268
 
248
- - **711 tests total** with EARS methodology
269
+ - **704 tests total** with EARS methodology
249
270
  - **ProjectAdapter**: 18 tests (complete project initialization + template processing + error recovery)
250
271
  - **BacklogAdapter**: 43 tests (complete workflow lifecycle + event handlers + E2E simulation)
251
272
  - **MetricsAdapter**: 32 tests (Tier 1+2 calculations + performance validation)
@@ -260,43 +281,26 @@ npm test -- --watch
260
281
  - **Store**: 26 tests (generic CRUD for all record types)
261
282
  - **Crypto**: 23 tests (signatures + checksums for all 7 record types)
262
283
  - **ConfigManager**: 20 tests (configuration + session state + project utilities)
284
+ - **IndexerAdapter**: 5 tests (cache generation, validation, and retrieval)
263
285
  - **Utils**: 10 tests (ID generation utilities)
264
- - **Integration**: 18 tests (cross-module validation)
286
+ - **Integration**: 74 tests (cross-module validation)
265
287
 
266
288
  ## ๐Ÿ”ฎ Roadmap
267
289
 
268
- ### Next: CLI Integration & Polish
290
+ ### Next Steps
269
291
 
270
- - CLI init command integration with ProjectAdapter
271
- - Real adapter integration tests (replace mocks with actual adapters)
272
- - IndexerModule for local cache optimization
273
- - Performance benchmarking with enterprise datasets
274
- - ConfigManager write methods (architectural improvement)
292
+ - **Git Adapter**: Development of a low-level adapter for direct Git operations.
293
+ - **Platform Adapters**: Integration with platform-specific features (e.g., GitHub Adapter).
294
+ - **Advanced Validation**: Creation of `lint` and `audit` modules for structural and protocol validation.
275
295
 
276
296
  ### Recently Completed
277
297
 
278
- - โœ… **ProjectAdapter**: Complete implementation with 3-adapter orchestration
279
- - โœ… **BacklogAdapter**: Complete implementation with event-driven coordination
280
- - โœ… **MetricsAdapter**: Complete calculation engine with Tier 1+2 functions
281
- - โœ… **ChangelogAdapter**: Complete implementation with conditional validation
282
- - โœ… **ExecutionAdapter**: Complete implementation with traceability
283
- - โœ… **FeedbackAdapter**: Complete implementation with dual event emission
284
-
285
- ## ๐Ÿ“š Documentation
286
-
287
- - **[Protocol Specs](./src/schemas/)**: Canonical schemas and rules
288
-
289
- ## ๐Ÿค Contributing
290
-
291
- This package follows **a protocol-first approach**. Every feature must:
292
-
293
- 1. Have a corresponding specification (blueprint) in `specs/`
294
- 2. Include comprehensive tests with EARS references
295
- 3. Follow the established architectural patterns
296
- 4. Pass TypeScript strict compilation
297
- 5. Update relevant documentation
298
-
299
- See [CONTRIBUTING.md](../../CONTRIBUTING.md) for detailed guidelines.
298
+ - โœ… **Complete Adapter Ecosystem**: All 9 core adapters for the foundational domains have been implemented and tested.
299
+ - โœ… **IndexerAdapter**: A dedicated module for local cache optimization to enhance performance is now available.
300
+ - โœ… **EventBusModule**: The foundational event-driven architecture is in place, enabling decoupled communication between modules.
301
+ - โœ… **ProjectAdapter**: The project initialization and orchestration logic is fully functional.
302
+ - โœ… **DiagramGenerator Module**: Automatic Mermaid diagram generation with deduplication, data quality warnings, and advanced filtering.
303
+ - โœ… **Schema Generation Pipeline**: Complete YAMLโ†’JSONโ†’TypeScript build-time transformation with automatic synchronization.
300
304
 
301
305
  ---
302
306
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gitgov/core",
3
- "version": "1.0.0",
4
- "description": "Universal SDK for the GitGovernance ecosystem, providing a type-safe, local-first API to manage identities, agents, and workflows.",
3
+ "version": "1.0.1",
4
+ "description": "SDK for the GitGovernance ecosystem, providing a type-safe, local-first API to manage identities, agents, and workflows.",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",
7
7
  "types": "dist/src/index.d.ts",
@@ -60,4 +60,4 @@
60
60
  "tsx": "^4.20.3",
61
61
  "typescript": "^5.8.3"
62
62
  }
63
- }
63
+ }