@gitgov/core 2.1.2 → 2.3.0

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 CHANGED
@@ -16,6 +16,8 @@ pnpm add @gitgov/core
16
16
 
17
17
  The SDK uses dependency injection. Each adapter receives its dependencies via constructor.
18
18
 
19
+ ### Filesystem Backend (CLI, local development)
20
+
19
21
  ```typescript
20
22
  import { Adapters, Store, EventBus } from '@gitgov/core';
21
23
  import { FsRecordStore } from '@gitgov/core/fs';
@@ -42,53 +44,111 @@ const task = await backlog.createTask(
42
44
  );
43
45
  ```
44
46
 
47
+ ### GitHub API Backend
48
+
49
+ For SaaS, Forge apps, or GitHub Actions — no filesystem needed:
50
+
51
+ ```typescript
52
+ import { Octokit } from '@octokit/rest';
53
+ import {
54
+ GitHubRecordStore,
55
+ GitHubConfigStore,
56
+ GitHubGitModule,
57
+ GitHubFileLister,
58
+ } from '@gitgov/core/github';
59
+ import type { TaskRecord } from '@gitgov/core';
60
+
61
+ const octokit = new Octokit({ auth: process.env.GITHUB_TOKEN });
62
+ const repoOpts = { owner: 'my-org', repo: 'my-repo', basePath: '.gitgov/tasks' };
63
+
64
+ const taskStore = new GitHubRecordStore<TaskRecord>(repoOpts, octokit);
65
+
66
+ // Read — returns parsed JSON, caches SHA for subsequent writes
67
+ const task = await taskStore.get('task-001');
68
+
69
+ // Write — returns { commitSha } from the created commit
70
+ const result = await taskStore.put('task-002', newTask);
71
+
72
+ // Atomic batch — single commit for N records (requires GitHubGitModule)
73
+ const gitModule = new GitHubGitModule({ owner: 'my-org', repo: 'my-repo' }, octokit);
74
+ const batchStore = new GitHubRecordStore<TaskRecord>(repoOpts, octokit, gitModule);
75
+ await batchStore.putMany([
76
+ { id: 'task-003', value: task3 },
77
+ { id: 'task-004', value: task4 },
78
+ ]);
79
+ ```
80
+
45
81
  ## Architecture
46
82
 
47
83
  ```mermaid
48
84
  graph LR
49
85
  subgraph "@gitgov/core — Pure Logic"
50
86
  Adapters["Adapters (10)"]
51
- Modules["Modules (24)"]
87
+ Modules["Modules (26)"]
52
88
  Records["Record System"]
89
+ Projection["RecordProjector + IRecordProjection"]
53
90
 
54
91
  Adapters --> Modules
55
92
  Adapters --> Records
56
93
  Modules --> Records
94
+ Modules --> Projection
57
95
  end
58
96
 
59
- subgraph "@gitgov/core/fs — I/O"
97
+ subgraph "@gitgov/core/fs — Local I/O"
60
98
  FsStore["FsRecordStore"]
99
+ FsProjection["FsRecordProjection"]
61
100
  FsGit["LocalGitModule"]
62
101
  FsLint["FsLintModule"]
63
102
  FsOther["FsKeyProvider, FsFileLister, ..."]
64
103
  end
65
104
 
105
+ subgraph "@gitgov/core/github — GitHub API"
106
+ GhStore["GitHubRecordStore"]
107
+ GhGit["GitHubGitModule"]
108
+ GhConfig["GitHubConfigStore"]
109
+ GhFiles["GitHubFileLister"]
110
+ end
111
+
66
112
  subgraph "@gitgov/core/memory — Testing"
67
113
  MemStore["MemoryRecordStore"]
114
+ MemProjection["MemoryRecordProjection"]
68
115
  MemGit["MemoryGitModule"]
69
116
  MemOther["MockKeyProvider, MemoryFileLister"]
70
117
  end
71
118
 
119
+ subgraph "@gitgov/core/prisma — Database"
120
+ PrismaProjection["PrismaRecordProjection"]
121
+ end
122
+
72
123
  Adapters -.->|DI| FsStore
124
+ Adapters -.->|DI| GhStore
73
125
  Adapters -.->|DI| MemStore
126
+ Projection -.->|sink| FsProjection
127
+ Projection -.->|sink| MemProjection
128
+ Projection -.->|sink| PrismaProjection
74
129
 
75
130
  CLI["@gitgov/cli"] --> Adapters
76
131
  SaaS["@gitgov/saas-api"] --> Adapters
132
+ Forge["Forge Apps"] --> Adapters
77
133
 
78
134
  style Adapters fill:#e8f5e8,stroke:#4caf50,stroke-width:2px
79
135
  style FsStore fill:#e3f2fd,stroke:#1976d2
136
+ style GhStore fill:#f3e5f5,stroke:#7b1fa2
80
137
  style MemStore fill:#fff3e0,stroke:#f57c00
138
+ style PrismaProjection fill:#fce4ec,stroke:#c62828
81
139
  ```
82
140
 
83
- ### 3 Export Paths
141
+ ### 5 Export Paths
84
142
 
85
143
  | Import | Contents | I/O |
86
144
  |--------|----------|-----|
87
145
  | `@gitgov/core` | Interfaces, types, pure logic, factories, validators | No |
88
- | `@gitgov/core/fs` | Filesystem implementations (FsRecordStore, LocalGitModule, FsLintModule, ...) | Yes |
89
- | `@gitgov/core/memory` | In-memory implementations for testing (MemoryRecordStore, MemoryGitModule, ...) | No |
146
+ | `@gitgov/core/fs` | Filesystem implementations (FsRecordStore, FsRecordProjection, LocalGitModule, FsLintModule, ...) | Local |
147
+ | `@gitgov/core/github` | GitHub API implementations (GitHubRecordStore, GitHubGitModule, GitHubConfigStore, GitHubFileLister) | Remote |
148
+ | `@gitgov/core/memory` | In-memory implementations for testing (MemoryRecordStore, MemoryRecordProjection, MemoryGitModule, ...) | No |
149
+ | `@gitgov/core/prisma` | Database-backed implementations via Prisma-compatible client (PrismaRecordProjection) | Remote |
90
150
 
91
- The root import (`@gitgov/core`) never imports `fs`, `path`, or `child_process`.
151
+ The root import (`@gitgov/core`) never imports `fs`, `path`, `child_process`, `@octokit/rest`, or `@prisma/client`.
92
152
 
93
153
  ### Record Symmetry
94
154
 
@@ -128,8 +188,10 @@ Adapters are orchestrators that compose modules. All receive dependencies via co
128
188
  | `record_factories/` | Factories with defaults for creating records |
129
189
  | `record_validations/` | Business validators (above schema) |
130
190
  | `record_schemas/` | JSON Schemas + schema cache + errors |
131
- | `record_store/` | `RecordStore<T>` interface (impl in fs/memory) |
132
- | `config_store/` | Storage for project config.json |
191
+ | `record_store/` | `RecordStore<V, R, O>` interface (impl in fs/memory/github) |
192
+ | `record_projection/` | `IRecordProjection` interface + RecordProjector engine (drivers: fs/memory/prisma) |
193
+ | `record_metrics/` | RecordMetrics calculation engine (system status, productivity, collaboration) |
194
+ | `config_store/` | Storage for project config.json (impl in fs/github) |
133
195
  | `config_manager/` | Typed access to config.json (versioned in git) |
134
196
  | `session_store/` | Storage for .session.json |
135
197
  | `session_manager/` | Typed access to .session.json (ephemeral, not versioned) |