@nuanst-one/ngitdb 0.1.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.
Files changed (29) hide show
  1. package/README.md +155 -0
  2. package/dist/action.cjs +49 -0
  3. package/dist/action.d.ts +38 -0
  4. package/dist/errors.d.ts +38 -0
  5. package/dist/gitdb.d.ts +11 -0
  6. package/dist/github-backend.d.ts +36 -0
  7. package/dist/index.d.ts +6 -0
  8. package/dist/index.js +1 -0
  9. package/dist/ownership.d.ts +2 -0
  10. package/dist/patch.d.ts +2 -0
  11. package/dist/resource-path.d.ts +10 -0
  12. package/dist/types.d.ts +78 -0
  13. package/docs/wiki/prompt-recipes.md +188 -0
  14. package/package.json +52 -0
  15. package/plugins/ngitdb/.codex-plugin/plugin.json +37 -0
  16. package/plugins/ngitdb/skills/ngitdb-integrator/SKILL.md +35 -0
  17. package/plugins/ngitdb/skills/ngitdb-integrator/agents/openai.yaml +4 -0
  18. package/plugins/ngitdb/skills/ngitdb-integrator/references/api.md +93 -0
  19. package/plugins/ngitdb/skills/ngitdb-integrator/references/migration-patterns.md +44 -0
  20. package/plugins/ngitdb/skills/ngitdb-integrator/references/testing.md +12 -0
  21. package/plugins/ngitdb/skills/ngitdb-reviewer/SKILL.md +34 -0
  22. package/plugins/ngitdb/skills/ngitdb-reviewer/agents/openai.yaml +4 -0
  23. package/plugins/ngitdb/skills/ngitdb-reviewer/references/checklist.md +17 -0
  24. package/plugins/ngitdb/skills/ngitdb-reviewer/references/risk-patterns.md +35 -0
  25. package/plugins/ngitdb/skills/ngitdb-starter/SKILL.md +35 -0
  26. package/plugins/ngitdb/skills/ngitdb-starter/agents/openai.yaml +4 -0
  27. package/plugins/ngitdb/skills/ngitdb-starter/references/resource-model.md +36 -0
  28. package/plugins/ngitdb/skills/ngitdb-starter/references/safety-model.md +40 -0
  29. package/plugins/ngitdb/skills/ngitdb-starter/references/testing.md +13 -0
package/README.md ADDED
@@ -0,0 +1,155 @@
1
+ # nGitDB
2
+
3
+ nGitDB is a TypeScript library for teams that keep structured JSON data in Git repositories and need safe, reviewable updates.
4
+
5
+ It provides a small workflow-aware API for:
6
+
7
+ - reading JSON resources by canonical resource path
8
+ - applying deterministic partial patches
9
+ - validating staged changes before commit
10
+ - protecting human-owned fields from machine overwrite
11
+ - isolating edits in branch-backed sessions
12
+ - creating GitHub commits and pull requests for review workflows
13
+
14
+ ## Install
15
+
16
+ ```bash
17
+ npm install @nuanst-one/ngitdb
18
+ ```
19
+
20
+ ## GitHub Action
21
+
22
+ For Python-first or non-TypeScript workflows, run your generator first and let the nGitDB Action publish the review PR.
23
+
24
+ ```yaml
25
+ permissions:
26
+ contents: write
27
+ pull-requests: write
28
+
29
+ steps:
30
+ - uses: actions/checkout@v4
31
+
32
+ - name: Build nGitDB batch
33
+ run: python scripts/build_ngitdb_batch.py --output tmp/ngitdb.batch.json
34
+
35
+ - name: Publish nGitDB updates
36
+ uses: nuanst-gmbh/nGitDB@v0
37
+ with:
38
+ batch-file: tmp/ngitdb.batch.json
39
+ session-key: company-enrichment
40
+ commit-message: Update generated company data
41
+ pr-title: Update generated company data
42
+ pr-body: Generated by nGitDB.
43
+ resource-config: |
44
+ {
45
+ "baseBranch": "main",
46
+ "resourceRoot": "data",
47
+ "resources": {
48
+ "companies": {
49
+ "fileName": "company.json",
50
+ "ownership": {
51
+ "legalName": "human-owned",
52
+ "machine": "machine-owned"
53
+ }
54
+ }
55
+ }
56
+ }
57
+ ```
58
+
59
+ The batch file contains patch operations:
60
+
61
+ ```json
62
+ {
63
+ "resources": [
64
+ {
65
+ "resourcePath": "companies/acme-gmbh",
66
+ "patch": {
67
+ "machine.summary": "Industrial supplier with operations in Berlin"
68
+ }
69
+ }
70
+ ]
71
+ }
72
+ ```
73
+
74
+ When this repository is private, enable GitHub Actions access for same-organization client repositories before using `nuanst-gmbh/nGitDB@v0`.
75
+
76
+ ## Example
77
+
78
+ ```ts
79
+ import { createGitDB } from "@nuanst-one/ngitdb";
80
+
81
+ const db = createGitDB({
82
+ repositoryRoot: process.cwd(),
83
+ backend: { type: "github" },
84
+ baseBranch: "main",
85
+ resources: {
86
+ companies: {
87
+ fileName: "company.json",
88
+ ownership: {
89
+ legalName: "human-owned",
90
+ machine: "machine-owned",
91
+ },
92
+ },
93
+ },
94
+ });
95
+
96
+ await db.startSession("acme-gmbh");
97
+
98
+ await db.patch("companies/acme-gmbh", {
99
+ "machine.summary": "Industrial supplier with operations in Berlin",
100
+ "machine.lastEnrichedAt": "2026-04-21",
101
+ });
102
+
103
+ await db.commit("Enrich company profile for acme-gmbh");
104
+
105
+ const pullRequest = await db.createPullRequest({
106
+ title: "Enrich acme-gmbh company profile",
107
+ });
108
+ ```
109
+
110
+ In GitHub Actions, `backend: { type: "github" }` reads `GITHUB_REPOSITORY` and `GITHUB_TOKEN` by default. The workflow needs:
111
+
112
+ ```yaml
113
+ permissions:
114
+ contents: write
115
+ pull-requests: write
116
+ ```
117
+
118
+ Install nGitDB as a package dependency in consumer repositories and run `npm ci` in CI. Directly cloning this repository is for nGitDB development, not the supported consumer install path. See the [GitHub Actions guide](docs/wiki/github-actions.md) for a minimal workflow, reusable workflow notes, and current resource-creation limits.
119
+
120
+ ## Documentation
121
+
122
+ - [Documentation wiki](docs/wiki/index.md)
123
+ - [Getting started](docs/wiki/getting-started.md)
124
+ - [GitHub Actions](docs/wiki/github-actions.md)
125
+ - [API reference](docs/wiki/api-reference.md)
126
+ - [Prompt recipes](docs/wiki/prompt-recipes.md)
127
+ - [Roadmap and limits](docs/wiki/roadmap-and-limits.md)
128
+
129
+ ## AI Assistant Support
130
+
131
+ nGitDB ships consumer prompt recipes and a Codex plugin with reusable skills:
132
+
133
+ - `ngitdb-starter`: start a new TypeScript project with nGitDB
134
+ - `ngitdb-integrator`: add nGitDB to an existing JSON workflow
135
+ - `ngitdb-reviewer`: review an nGitDB integration for safety gaps
136
+
137
+ The plugin source is available under `plugins/ngitdb`.
138
+
139
+ ## Current Status
140
+
141
+ The current implementation provides the V1 library surface with two supported backends:
142
+
143
+ - `backend: { type: "github" }` creates or resumes a GitHub session branch, creates commits with the Git database API, and creates or updates a pull request.
144
+ - `backend: { type: "local" }` or an omitted backend writes committed session artifacts under `.ngitdb/sessions/...` for offline development and tests.
145
+
146
+ ## Development
147
+
148
+ ```bash
149
+ npm install
150
+ npm run build
151
+ npm run build:action
152
+ npm test
153
+ ```
154
+
155
+ The package build emits TypeScript declarations plus an obfuscated/minified runtime bundle. The GitHub Action bundle is minified and verified before publish.