@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.
- package/README.md +130 -126
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -4,66 +4,86 @@
|
|
|
4
4
|
[](https://opensource.org/licenses/MPL-2.0)
|
|
5
5
|
[](./tsconfig.json)
|
|
6
6
|
|
|
7
|
-
`@gitgov/core` is the **
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
//
|
|
43
|
-
const
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
//
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
// โ
|
|
63
|
-
//
|
|
64
|
-
//
|
|
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 (
|
|
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 (
|
|
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
|
-
|
|
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. **
|
|
175
|
-
3. **
|
|
176
|
-
4. **
|
|
177
|
-
5. **
|
|
178
|
-
6. **
|
|
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 (
|
|
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
|
-
- **
|
|
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**:
|
|
286
|
+
- **Integration**: 74 tests (cross-module validation)
|
|
265
287
|
|
|
266
288
|
## ๐ฎ Roadmap
|
|
267
289
|
|
|
268
|
-
### Next
|
|
290
|
+
### Next Steps
|
|
269
291
|
|
|
270
|
-
-
|
|
271
|
-
-
|
|
272
|
-
-
|
|
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
|
-
- โ
**
|
|
279
|
-
- โ
**
|
|
280
|
-
- โ
**
|
|
281
|
-
- โ
**
|
|
282
|
-
- โ
**
|
|
283
|
-
- โ
**
|
|
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.
|
|
4
|
-
"description": "
|
|
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
|
+
}
|