contextgit 0.0.2 → 0.0.3

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 (163) hide show
  1. package/dist/bootstrap.d.ts +10 -0
  2. package/dist/bootstrap.d.ts.map +1 -0
  3. package/dist/bootstrap.js +43 -0
  4. package/dist/bootstrap.js.map +1 -0
  5. package/dist/commands/branch.d.ts +13 -0
  6. package/dist/commands/branch.d.ts.map +1 -0
  7. package/dist/commands/branch.js +52 -0
  8. package/dist/commands/branch.js.map +1 -0
  9. package/dist/commands/claim.d.ts +13 -0
  10. package/dist/commands/claim.d.ts.map +1 -0
  11. package/dist/commands/claim.js +50 -0
  12. package/dist/commands/claim.js.map +1 -0
  13. package/dist/commands/commit.d.ts +14 -0
  14. package/dist/commands/commit.d.ts.map +1 -0
  15. package/dist/commands/commit.js +71 -0
  16. package/dist/commands/commit.js.map +1 -0
  17. package/dist/commands/context.d.ts +9 -0
  18. package/dist/commands/context.d.ts.map +1 -0
  19. package/dist/commands/context.js +38 -0
  20. package/dist/commands/context.js.map +1 -0
  21. package/dist/commands/doctor.d.ts +6 -0
  22. package/dist/commands/doctor.d.ts.map +1 -0
  23. package/dist/commands/doctor.js +84 -0
  24. package/dist/commands/doctor.js.map +1 -0
  25. package/dist/commands/init.d.ts +10 -0
  26. package/dist/commands/init.d.ts.map +1 -0
  27. package/dist/commands/init.js +126 -0
  28. package/dist/commands/init.js.map +1 -0
  29. package/dist/commands/keygen.d.ts +10 -0
  30. package/dist/commands/keygen.d.ts.map +1 -0
  31. package/dist/commands/keygen.js +57 -0
  32. package/dist/commands/keygen.js.map +1 -0
  33. package/dist/commands/log.d.ts +13 -0
  34. package/dist/commands/log.d.ts.map +1 -0
  35. package/dist/commands/log.js +91 -0
  36. package/dist/commands/log.js.map +1 -0
  37. package/dist/commands/merge.d.ts +12 -0
  38. package/dist/commands/merge.d.ts.map +1 -0
  39. package/dist/commands/merge.js +29 -0
  40. package/dist/commands/merge.js.map +1 -0
  41. package/dist/commands/pull.d.ts +10 -0
  42. package/dist/commands/pull.d.ts.map +1 -0
  43. package/dist/commands/pull.js +123 -0
  44. package/dist/commands/pull.js.map +1 -0
  45. package/dist/commands/push.d.ts +10 -0
  46. package/dist/commands/push.d.ts.map +1 -0
  47. package/dist/commands/push.js +141 -0
  48. package/dist/commands/push.js.map +1 -0
  49. package/dist/commands/remote-show.d.ts +6 -0
  50. package/dist/commands/remote-show.d.ts.map +1 -0
  51. package/dist/commands/remote-show.js +71 -0
  52. package/dist/commands/remote-show.js.map +1 -0
  53. package/dist/commands/search.d.ts +11 -0
  54. package/dist/commands/search.d.ts.map +1 -0
  55. package/dist/commands/search.js +47 -0
  56. package/dist/commands/search.js.map +1 -0
  57. package/dist/commands/serve.d.ts +9 -0
  58. package/dist/commands/serve.d.ts.map +1 -0
  59. package/dist/commands/serve.js +51 -0
  60. package/dist/commands/serve.js.map +1 -0
  61. package/dist/commands/set-remote.d.ts +9 -0
  62. package/dist/commands/set-remote.d.ts.map +1 -0
  63. package/dist/commands/set-remote.js +26 -0
  64. package/dist/commands/set-remote.js.map +1 -0
  65. package/dist/commands/status.d.ts +6 -0
  66. package/dist/commands/status.d.ts.map +1 -0
  67. package/dist/commands/status.js +54 -0
  68. package/dist/commands/status.js.map +1 -0
  69. package/dist/commands/unclaim.d.ts +9 -0
  70. package/dist/commands/unclaim.d.ts.map +1 -0
  71. package/dist/commands/unclaim.js +22 -0
  72. package/dist/commands/unclaim.js.map +1 -0
  73. package/dist/config.d.ts +19 -0
  74. package/dist/config.d.ts.map +1 -0
  75. package/dist/config.js +58 -0
  76. package/dist/config.js.map +1 -0
  77. package/dist/git-hooks.d.ts +6 -0
  78. package/dist/git-hooks.d.ts.map +1 -0
  79. package/dist/git-hooks.js +58 -0
  80. package/dist/git-hooks.js.map +1 -0
  81. package/package.json +22 -19
  82. package/.claude/settings.local.json +0 -41
  83. package/.contextgit/config.json +0 -10
  84. package/.contextgit/system-prompt.md +0 -4
  85. package/.github/workflows/contextgit-ci.yml +0 -40
  86. package/CLAUDE.md +0 -123
  87. package/CLAUDE.md.next +0 -65
  88. package/docs/ContextGit_ARCHITECTURE_v3.md +0 -1141
  89. package/docs/ContextGit_DELTA.md +0 -84
  90. package/docs/ContextGit_PHASE1_PLAN.md +0 -177
  91. package/docs/ContextGit_PHASE2_PLAN.md +0 -535
  92. package/docs/ContextGit_PRD_v4.md +0 -488
  93. package/docs/decisions.md +0 -370
  94. package/packages/api/package.json +0 -25
  95. package/packages/api/src/bootstrap.ts +0 -64
  96. package/packages/api/src/config.ts +0 -45
  97. package/packages/api/src/index.ts +0 -17
  98. package/packages/api/src/middleware/auth.test.ts +0 -83
  99. package/packages/api/src/middleware/auth.ts +0 -41
  100. package/packages/api/src/remote-store.test.ts +0 -301
  101. package/packages/api/src/router.ts +0 -121
  102. package/packages/api/src/server-config.ts +0 -34
  103. package/packages/api/src/server.ts +0 -38
  104. package/packages/api/src/store-router.ts +0 -241
  105. package/packages/api/tsconfig.json +0 -8
  106. package/packages/cli/package.json +0 -29
  107. package/packages/cli/src/bootstrap.ts +0 -68
  108. package/packages/cli/src/commands/branch.ts +0 -58
  109. package/packages/cli/src/commands/claim.ts +0 -58
  110. package/packages/cli/src/commands/commit.ts +0 -79
  111. package/packages/cli/src/commands/context.ts +0 -46
  112. package/packages/cli/src/commands/doctor.ts +0 -99
  113. package/packages/cli/src/commands/init.ts +0 -141
  114. package/packages/cli/src/commands/keygen.ts +0 -65
  115. package/packages/cli/src/commands/log.ts +0 -103
  116. package/packages/cli/src/commands/merge.ts +0 -36
  117. package/packages/cli/src/commands/pull.ts +0 -145
  118. package/packages/cli/src/commands/push.ts +0 -158
  119. package/packages/cli/src/commands/remote-show.ts +0 -87
  120. package/packages/cli/src/commands/search.ts +0 -54
  121. package/packages/cli/src/commands/serve.ts +0 -61
  122. package/packages/cli/src/commands/set-remote.ts +0 -30
  123. package/packages/cli/src/commands/status.ts +0 -62
  124. package/packages/cli/src/commands/unclaim.ts +0 -28
  125. package/packages/cli/src/config.ts +0 -64
  126. package/packages/cli/src/git-hooks.ts +0 -61
  127. package/packages/cli/tsconfig.json +0 -9
  128. package/packages/core/package.json +0 -28
  129. package/packages/core/src/embeddings.test.ts +0 -58
  130. package/packages/core/src/embeddings.ts +0 -75
  131. package/packages/core/src/engine.ts +0 -274
  132. package/packages/core/src/index.ts +0 -6
  133. package/packages/core/src/snapshot.ts +0 -82
  134. package/packages/core/src/summarizer.test.ts +0 -120
  135. package/packages/core/src/summarizer.ts +0 -113
  136. package/packages/core/src/threads.ts +0 -29
  137. package/packages/core/src/types.ts +0 -240
  138. package/packages/core/tsconfig.json +0 -9
  139. package/packages/mcp/package.json +0 -31
  140. package/packages/mcp/src/auto-snapshot.ts +0 -83
  141. package/packages/mcp/src/config.ts +0 -53
  142. package/packages/mcp/src/git-sync.ts +0 -94
  143. package/packages/mcp/src/index.ts +0 -19
  144. package/packages/mcp/src/server.ts +0 -377
  145. package/packages/mcp/tsconfig.json +0 -9
  146. package/packages/store/package.json +0 -30
  147. package/packages/store/src/branch-merge.test.ts +0 -127
  148. package/packages/store/src/engine-integration.test.ts +0 -93
  149. package/packages/store/src/index.ts +0 -3
  150. package/packages/store/src/interface.ts +0 -62
  151. package/packages/store/src/local/claims.test.ts +0 -190
  152. package/packages/store/src/local/index.ts +0 -380
  153. package/packages/store/src/local/local-store.test.ts +0 -164
  154. package/packages/store/src/local/migrations.ts +0 -99
  155. package/packages/store/src/local/queries.ts +0 -760
  156. package/packages/store/src/local/schema.ts +0 -157
  157. package/packages/store/src/remote/index.ts +0 -300
  158. package/packages/store/tsconfig.json +0 -9
  159. package/pnpm-workspace.yaml +0 -2
  160. package/scripts/build.sh +0 -28
  161. package/tsconfig.base.json +0 -14
  162. package/vitest.config.ts +0 -15
  163. /package/{packages/cli/bin → bin}/run.js +0 -0
@@ -1,164 +0,0 @@
1
- import { describe, it, expect, beforeEach, afterEach } from 'vitest'
2
- import { LocalStore } from './index.js'
3
-
4
- describe('LocalStore (in-memory)', () => {
5
- let store: LocalStore
6
-
7
- beforeEach(() => {
8
- store = new LocalStore(':memory:')
9
- })
10
-
11
- afterEach(() => {
12
- store.close()
13
- })
14
-
15
- it('creates and retrieves a project', async () => {
16
- const project = await store.createProject({ name: 'test-project', description: 'A test' })
17
- expect(project.id).toBeTruthy()
18
- expect(project.name).toBe('test-project')
19
-
20
- const fetched = await store.getProject(project.id)
21
- expect(fetched).toBeTruthy()
22
- expect(fetched!.name).toBe('test-project')
23
- })
24
-
25
- it('creates and retrieves a branch', async () => {
26
- const project = await store.createProject({ name: 'p' })
27
- const branch = await store.createBranch({
28
- projectId: project.id,
29
- name: 'main',
30
- gitBranch: 'main',
31
- })
32
- expect(branch.id).toBeTruthy()
33
- expect(branch.gitBranch).toBe('main')
34
-
35
- const byGit = await store.getBranchByGitName(project.id, 'main')
36
- expect(byGit!.id).toBe(branch.id)
37
- })
38
-
39
- it('creates a commit, opens a thread, closes it', async () => {
40
- const project = await store.createProject({ name: 'p' })
41
- const branch = await store.createBranch({ projectId: project.id, name: 'main', gitBranch: 'main' })
42
-
43
- // Upsert agent first (required for commit attribution)
44
- await store.upsertAgent({
45
- id: 'agent-1',
46
- projectId: project.id,
47
- role: 'dev',
48
- tool: 'claude-code',
49
- workflowType: 'interactive',
50
- })
51
-
52
- const commit1 = await store.createCommit({
53
- branchId: branch.id,
54
- agentId: 'agent-1',
55
- agentRole: 'dev',
56
- tool: 'claude-code',
57
- workflowType: 'interactive',
58
- message: 'Initial commit',
59
- content: 'Set up project structure',
60
- summary: 'Project scaffolded',
61
- commitType: 'manual',
62
- threads: { open: ['Authentication approach not decided'] },
63
- })
64
- expect(commit1.id).toBeTruthy()
65
- expect(commit1.message).toBe('Initial commit')
66
-
67
- // Thread should be open
68
- const openThreads = await store.listOpenThreads(project.id)
69
- expect(openThreads).toHaveLength(1)
70
- expect(openThreads[0].description).toBe('Authentication approach not decided')
71
- const threadId = openThreads[0].id
72
-
73
- // Second commit closes the thread
74
- const commit2 = await store.createCommit({
75
- branchId: branch.id,
76
- agentId: 'agent-1',
77
- agentRole: 'dev',
78
- tool: 'claude-code',
79
- workflowType: 'interactive',
80
- message: 'Choose JWT auth',
81
- content: 'Implemented JWT RS256',
82
- summary: 'JWT RS256 chosen, implemented',
83
- commitType: 'manual',
84
- threads: { close: [{ id: threadId, note: 'Using JWT RS256' }] },
85
- })
86
- expect(commit2.id).toBeTruthy()
87
-
88
- const stillOpen = await store.listOpenThreads(project.id)
89
- expect(stillOpen).toHaveLength(0)
90
- })
91
-
92
- it('getSessionSnapshot returns project/branch summaries and threads', async () => {
93
- const project = await store.createProject({ name: 'snap-test' })
94
- const main = await store.createBranch({ projectId: project.id, name: 'main', gitBranch: 'main' })
95
- const feature = await store.createBranch({
96
- projectId: project.id,
97
- name: 'feature/auth',
98
- gitBranch: 'feature/auth',
99
- parentBranchId: main.id,
100
- })
101
-
102
- await store.upsertAgent({ id: 'ag', projectId: project.id, role: 'dev', tool: 'cli', workflowType: 'interactive' })
103
-
104
- await store.createCommit({
105
- branchId: main.id, agentId: 'ag', agentRole: 'dev', tool: 'cli',
106
- workflowType: 'interactive', message: 'main commit', content: 'content',
107
- summary: 'Main branch summary', commitType: 'manual',
108
- })
109
- await store.createCommit({
110
- branchId: feature.id, agentId: 'ag', agentRole: 'dev', tool: 'cli',
111
- workflowType: 'interactive', message: 'feature commit', content: 'feature content',
112
- summary: 'Feature branch summary', commitType: 'manual',
113
- threads: { open: ['Open thread on feature'] },
114
- })
115
-
116
- const snapshot = await store.getSessionSnapshot(project.id, feature.id)
117
- expect(snapshot.projectSummary).toBe('Main branch summary')
118
- expect(snapshot.branchSummary).toBe('Feature branch summary')
119
- expect(snapshot.branchName).toBe('feature/auth')
120
- expect(snapshot.recentCommits).toHaveLength(1)
121
- expect(snapshot.openThreads).toHaveLength(1)
122
- expect(snapshot.openThreads[0].description).toBe('Open thread on feature')
123
- })
124
-
125
- it('getFormattedSnapshot returns text format', async () => {
126
- const project = await store.createProject({ name: 'fmt-test' })
127
- const branch = await store.createBranch({ projectId: project.id, name: 'main', gitBranch: 'main' })
128
- const text = await store.getFormattedSnapshot(project.id, branch.id, 'text')
129
- expect(text).toContain('=== PROJECT STATE ===')
130
- expect(text).toContain('=== CURRENT BRANCH: main ===')
131
- expect(text).toContain('=== OPEN THREADS ===')
132
- })
133
-
134
- it('mergeBranch carries open threads to target and marks source merged', async () => {
135
- const project = await store.createProject({ name: 'merge-test' })
136
- const main = await store.createBranch({ projectId: project.id, name: 'main', gitBranch: 'main' })
137
- const feat = await store.createBranch({ projectId: project.id, name: 'feat', gitBranch: 'feat', parentBranchId: main.id })
138
-
139
- await store.upsertAgent({ id: 'ag', projectId: project.id, role: 'dev', tool: 'cli', workflowType: 'interactive' })
140
-
141
- await store.createCommit({
142
- branchId: main.id, agentId: 'ag', agentRole: 'dev', tool: 'cli',
143
- workflowType: 'interactive', message: 'main init', content: 'c', summary: 's', commitType: 'branch-init',
144
- })
145
- await store.createCommit({
146
- branchId: feat.id, agentId: 'ag', agentRole: 'dev', tool: 'cli',
147
- workflowType: 'interactive', message: 'feat work', content: 'c', summary: 's', commitType: 'manual',
148
- threads: { open: ['Thread from feat'] },
149
- })
150
-
151
- const mergeCommit = await store.mergeBranch(feat.id, main.id, 'Merged feat into main')
152
- expect(mergeCommit.commitType).toBe('merge')
153
- expect(mergeCommit.branchId).toBe(main.id)
154
-
155
- // Source branch is merged
156
- const updatedFeat = await store.getBranch(feat.id)
157
- expect(updatedFeat!.status).toBe('merged')
158
-
159
- // Thread carried to main
160
- const mainThreads = await store.listOpenThreadsByBranch(main.id)
161
- expect(mainThreads).toHaveLength(1)
162
- expect(mainThreads[0].description).toBe('Thread from feat')
163
- })
164
- })
@@ -1,99 +0,0 @@
1
- import type { Database } from 'better-sqlite3'
2
- import { SCHEMA_V1_DDL, SCHEMA_V2_DDL, SCHEMA_V3_DDL, SCHEMA_V4_DDL, CREATE_COMMIT_EMBEDDINGS } from './schema.js'
3
-
4
- interface MigrationRow {
5
- version: number
6
- name: string
7
- applied_at: number
8
- }
9
-
10
- const MIGRATIONS_TABLE = `
11
- CREATE TABLE IF NOT EXISTS _migrations (
12
- version INTEGER PRIMARY KEY,
13
- name TEXT NOT NULL,
14
- applied_at INTEGER NOT NULL
15
- )
16
- `
17
-
18
- interface Migration {
19
- version: number
20
- name: string
21
- run(db: Database): void
22
- }
23
-
24
- const MIGRATIONS: Migration[] = [
25
- {
26
- version: 1,
27
- name: 'initial_schema',
28
- run(db) {
29
- for (const sql of SCHEMA_V1_DDL) {
30
- db.exec(sql)
31
- }
32
- },
33
- },
34
- {
35
- version: 2,
36
- name: 'fts5_and_vectors',
37
- run(db) {
38
- // FTS5 full-text index
39
- for (const sql of SCHEMA_V2_DDL) {
40
- db.exec(sql)
41
- }
42
-
43
- // sqlite-vec virtual table — optional, skipped if extension not loaded
44
- try {
45
- db.exec(CREATE_COMMIT_EMBEDDINGS)
46
- } catch {
47
- // sqlite-vec not loaded; semantic search will return empty results
48
- }
49
- },
50
- },
51
- {
52
- version: 3,
53
- name: 'fts_trigger',
54
- run(db) {
55
- // Add INSERT trigger to keep commits_fts in sync with commits table.
56
- // Then rebuild the index to pick up any rows inserted before this migration.
57
- for (const sql of SCHEMA_V3_DDL) {
58
- db.exec(sql)
59
- }
60
- try {
61
- db.exec(`INSERT INTO commits_fts(commits_fts) VALUES('rebuild')`)
62
- } catch {
63
- // FTS5 table not available — skip rebuild
64
- }
65
- },
66
- },
67
- {
68
- version: 4,
69
- name: 'claims_table',
70
- run(db) {
71
- for (const sql of SCHEMA_V4_DDL) {
72
- db.exec(sql)
73
- }
74
- },
75
- },
76
- ]
77
-
78
- export function runMigrations(db: Database): void {
79
- // Ensure migrations table exists
80
- db.exec(MIGRATIONS_TABLE)
81
-
82
- const getApplied = db.prepare<[], MigrationRow>(
83
- 'SELECT version, name, applied_at FROM _migrations ORDER BY version'
84
- )
85
- const insertMigration = db.prepare(
86
- 'INSERT INTO _migrations (version, name, applied_at) VALUES (?, ?, ?)'
87
- )
88
-
89
- const applied = new Set(getApplied.all().map((r) => r.version))
90
-
91
- for (const migration of MIGRATIONS) {
92
- if (applied.has(migration.version)) continue
93
-
94
- db.transaction(() => {
95
- migration.run(db)
96
- insertMigration.run(migration.version, migration.name, Date.now())
97
- })()
98
- }
99
- }