contextgit 0.0.2 → 0.0.4
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/dist/bootstrap.d.ts +10 -0
- package/dist/bootstrap.d.ts.map +1 -0
- package/dist/bootstrap.js +43 -0
- package/dist/bootstrap.js.map +1 -0
- package/dist/commands/branch.d.ts +13 -0
- package/dist/commands/branch.d.ts.map +1 -0
- package/dist/commands/branch.js +52 -0
- package/dist/commands/branch.js.map +1 -0
- package/dist/commands/claim.d.ts +15 -0
- package/dist/commands/claim.d.ts.map +1 -0
- package/dist/commands/claim.js +60 -0
- package/dist/commands/claim.js.map +1 -0
- package/dist/commands/commit.d.ts +17 -0
- package/dist/commands/commit.d.ts.map +1 -0
- package/dist/commands/commit.js +83 -0
- package/dist/commands/commit.js.map +1 -0
- package/dist/commands/context.d.ts +9 -0
- package/dist/commands/context.d.ts.map +1 -0
- package/dist/commands/context.js +38 -0
- package/dist/commands/context.js.map +1 -0
- package/dist/commands/doctor.d.ts +6 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +84 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/init.d.ts +10 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +184 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/keygen.d.ts +10 -0
- package/dist/commands/keygen.d.ts.map +1 -0
- package/dist/commands/keygen.js +57 -0
- package/dist/commands/keygen.js.map +1 -0
- package/dist/commands/log.d.ts +13 -0
- package/dist/commands/log.d.ts.map +1 -0
- package/dist/commands/log.js +91 -0
- package/dist/commands/log.js.map +1 -0
- package/dist/commands/merge.d.ts +12 -0
- package/dist/commands/merge.d.ts.map +1 -0
- package/dist/commands/merge.js +29 -0
- package/dist/commands/merge.js.map +1 -0
- package/dist/commands/pull.d.ts +10 -0
- package/dist/commands/pull.d.ts.map +1 -0
- package/dist/commands/pull.js +123 -0
- package/dist/commands/pull.js.map +1 -0
- package/dist/commands/push.d.ts +10 -0
- package/dist/commands/push.d.ts.map +1 -0
- package/dist/commands/push.js +141 -0
- package/dist/commands/push.js.map +1 -0
- package/dist/commands/remote-show.d.ts +6 -0
- package/dist/commands/remote-show.d.ts.map +1 -0
- package/dist/commands/remote-show.js +71 -0
- package/dist/commands/remote-show.js.map +1 -0
- package/dist/commands/search.d.ts +11 -0
- package/dist/commands/search.d.ts.map +1 -0
- package/dist/commands/search.js +47 -0
- package/dist/commands/search.js.map +1 -0
- package/dist/commands/serve.d.ts +9 -0
- package/dist/commands/serve.d.ts.map +1 -0
- package/dist/commands/serve.js +51 -0
- package/dist/commands/serve.js.map +1 -0
- package/dist/commands/set-remote.d.ts +9 -0
- package/dist/commands/set-remote.d.ts.map +1 -0
- package/dist/commands/set-remote.js +26 -0
- package/dist/commands/set-remote.js.map +1 -0
- package/dist/commands/status.d.ts +6 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +54 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/unclaim.d.ts +9 -0
- package/dist/commands/unclaim.d.ts.map +1 -0
- package/dist/commands/unclaim.js +22 -0
- package/dist/commands/unclaim.js.map +1 -0
- package/dist/config.d.ts +19 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +58 -0
- package/dist/config.js.map +1 -0
- package/dist/git-hooks.d.ts +6 -0
- package/dist/git-hooks.d.ts.map +1 -0
- package/dist/git-hooks.js +58 -0
- package/dist/git-hooks.js.map +1 -0
- package/package.json +24 -18
- package/.claude/settings.local.json +0 -41
- package/.contextgit/config.json +0 -10
- package/.contextgit/system-prompt.md +0 -4
- package/.github/workflows/contextgit-ci.yml +0 -40
- package/CLAUDE.md +0 -123
- package/CLAUDE.md.next +0 -65
- package/docs/ContextGit_ARCHITECTURE_v3.md +0 -1141
- package/docs/ContextGit_DELTA.md +0 -84
- package/docs/ContextGit_PHASE1_PLAN.md +0 -177
- package/docs/ContextGit_PHASE2_PLAN.md +0 -535
- package/docs/ContextGit_PRD_v4.md +0 -488
- package/docs/decisions.md +0 -370
- package/packages/api/package.json +0 -25
- package/packages/api/src/bootstrap.ts +0 -64
- package/packages/api/src/config.ts +0 -45
- package/packages/api/src/index.ts +0 -17
- package/packages/api/src/middleware/auth.test.ts +0 -83
- package/packages/api/src/middleware/auth.ts +0 -41
- package/packages/api/src/remote-store.test.ts +0 -301
- package/packages/api/src/router.ts +0 -121
- package/packages/api/src/server-config.ts +0 -34
- package/packages/api/src/server.ts +0 -38
- package/packages/api/src/store-router.ts +0 -241
- package/packages/api/tsconfig.json +0 -8
- package/packages/cli/package.json +0 -29
- package/packages/cli/src/bootstrap.ts +0 -68
- package/packages/cli/src/commands/branch.ts +0 -58
- package/packages/cli/src/commands/claim.ts +0 -58
- package/packages/cli/src/commands/commit.ts +0 -79
- package/packages/cli/src/commands/context.ts +0 -46
- package/packages/cli/src/commands/doctor.ts +0 -99
- package/packages/cli/src/commands/init.ts +0 -141
- package/packages/cli/src/commands/keygen.ts +0 -65
- package/packages/cli/src/commands/log.ts +0 -103
- package/packages/cli/src/commands/merge.ts +0 -36
- package/packages/cli/src/commands/pull.ts +0 -145
- package/packages/cli/src/commands/push.ts +0 -158
- package/packages/cli/src/commands/remote-show.ts +0 -87
- package/packages/cli/src/commands/search.ts +0 -54
- package/packages/cli/src/commands/serve.ts +0 -61
- package/packages/cli/src/commands/set-remote.ts +0 -30
- package/packages/cli/src/commands/status.ts +0 -62
- package/packages/cli/src/commands/unclaim.ts +0 -28
- package/packages/cli/src/config.ts +0 -64
- package/packages/cli/src/git-hooks.ts +0 -61
- package/packages/cli/tsconfig.json +0 -9
- package/packages/core/package.json +0 -28
- package/packages/core/src/embeddings.test.ts +0 -58
- package/packages/core/src/embeddings.ts +0 -75
- package/packages/core/src/engine.ts +0 -274
- package/packages/core/src/index.ts +0 -6
- package/packages/core/src/snapshot.ts +0 -82
- package/packages/core/src/summarizer.test.ts +0 -120
- package/packages/core/src/summarizer.ts +0 -113
- package/packages/core/src/threads.ts +0 -29
- package/packages/core/src/types.ts +0 -240
- package/packages/core/tsconfig.json +0 -9
- package/packages/mcp/package.json +0 -31
- package/packages/mcp/src/auto-snapshot.ts +0 -83
- package/packages/mcp/src/config.ts +0 -53
- package/packages/mcp/src/git-sync.ts +0 -94
- package/packages/mcp/src/index.ts +0 -19
- package/packages/mcp/src/server.ts +0 -377
- package/packages/mcp/tsconfig.json +0 -9
- package/packages/store/package.json +0 -30
- package/packages/store/src/branch-merge.test.ts +0 -127
- package/packages/store/src/engine-integration.test.ts +0 -93
- package/packages/store/src/index.ts +0 -3
- package/packages/store/src/interface.ts +0 -62
- package/packages/store/src/local/claims.test.ts +0 -190
- package/packages/store/src/local/index.ts +0 -380
- package/packages/store/src/local/local-store.test.ts +0 -164
- package/packages/store/src/local/migrations.ts +0 -99
- package/packages/store/src/local/queries.ts +0 -760
- package/packages/store/src/local/schema.ts +0 -157
- package/packages/store/src/remote/index.ts +0 -300
- package/packages/store/tsconfig.json +0 -9
- package/pnpm-workspace.yaml +0 -2
- package/scripts/build.sh +0 -28
- package/tsconfig.base.json +0 -14
- package/vitest.config.ts +0 -15
- /package/{packages/cli/bin → bin}/run.js +0 -0
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
// DDL for LocalStore (SQLite + sqlite-vec)
|
|
2
|
-
// Dates stored as INTEGER (Unix milliseconds).
|
|
3
|
-
// All primary keys are TEXT (nanoid).
|
|
4
|
-
|
|
5
|
-
export const CREATE_PROJECTS = `
|
|
6
|
-
CREATE TABLE IF NOT EXISTS projects (
|
|
7
|
-
id TEXT PRIMARY KEY,
|
|
8
|
-
name TEXT NOT NULL,
|
|
9
|
-
description TEXT,
|
|
10
|
-
github_url TEXT,
|
|
11
|
-
created_at INTEGER NOT NULL
|
|
12
|
-
)
|
|
13
|
-
`
|
|
14
|
-
|
|
15
|
-
export const CREATE_BRANCHES = `
|
|
16
|
-
CREATE TABLE IF NOT EXISTS branches (
|
|
17
|
-
id TEXT PRIMARY KEY,
|
|
18
|
-
project_id TEXT NOT NULL REFERENCES projects(id),
|
|
19
|
-
name TEXT NOT NULL,
|
|
20
|
-
git_branch TEXT NOT NULL,
|
|
21
|
-
github_pr_url TEXT,
|
|
22
|
-
parent_branch_id TEXT REFERENCES branches(id),
|
|
23
|
-
head_commit_id TEXT,
|
|
24
|
-
status TEXT NOT NULL DEFAULT 'active',
|
|
25
|
-
created_at INTEGER NOT NULL,
|
|
26
|
-
merged_at INTEGER
|
|
27
|
-
)
|
|
28
|
-
`
|
|
29
|
-
|
|
30
|
-
export const CREATE_COMMITS = `
|
|
31
|
-
CREATE TABLE IF NOT EXISTS commits (
|
|
32
|
-
id TEXT PRIMARY KEY,
|
|
33
|
-
branch_id TEXT NOT NULL REFERENCES branches(id),
|
|
34
|
-
parent_id TEXT REFERENCES commits(id),
|
|
35
|
-
merge_source_branch_id TEXT REFERENCES branches(id),
|
|
36
|
-
agent_id TEXT NOT NULL,
|
|
37
|
-
agent_role TEXT NOT NULL DEFAULT 'solo',
|
|
38
|
-
tool TEXT NOT NULL,
|
|
39
|
-
workflow_type TEXT NOT NULL DEFAULT 'interactive',
|
|
40
|
-
loop_iteration INTEGER,
|
|
41
|
-
ci_run_id TEXT,
|
|
42
|
-
pipeline_name TEXT,
|
|
43
|
-
message TEXT NOT NULL,
|
|
44
|
-
content TEXT NOT NULL,
|
|
45
|
-
summary TEXT NOT NULL,
|
|
46
|
-
commit_type TEXT NOT NULL DEFAULT 'manual',
|
|
47
|
-
git_commit_sha TEXT,
|
|
48
|
-
created_at INTEGER NOT NULL
|
|
49
|
-
)
|
|
50
|
-
`
|
|
51
|
-
|
|
52
|
-
export const CREATE_THREADS = `
|
|
53
|
-
CREATE TABLE IF NOT EXISTS threads (
|
|
54
|
-
id TEXT PRIMARY KEY,
|
|
55
|
-
project_id TEXT NOT NULL REFERENCES projects(id),
|
|
56
|
-
branch_id TEXT NOT NULL REFERENCES branches(id),
|
|
57
|
-
description TEXT NOT NULL,
|
|
58
|
-
status TEXT NOT NULL DEFAULT 'open',
|
|
59
|
-
workflow_type TEXT,
|
|
60
|
-
opened_in_commit TEXT NOT NULL REFERENCES commits(id),
|
|
61
|
-
closed_in_commit TEXT REFERENCES commits(id),
|
|
62
|
-
closed_note TEXT,
|
|
63
|
-
created_at INTEGER NOT NULL
|
|
64
|
-
)
|
|
65
|
-
`
|
|
66
|
-
|
|
67
|
-
export const CREATE_AGENTS = `
|
|
68
|
-
CREATE TABLE IF NOT EXISTS agents (
|
|
69
|
-
id TEXT PRIMARY KEY,
|
|
70
|
-
project_id TEXT NOT NULL REFERENCES projects(id),
|
|
71
|
-
role TEXT NOT NULL DEFAULT 'solo',
|
|
72
|
-
tool TEXT NOT NULL,
|
|
73
|
-
workflow_type TEXT NOT NULL DEFAULT 'interactive',
|
|
74
|
-
display_name TEXT,
|
|
75
|
-
total_commits INTEGER NOT NULL DEFAULT 0,
|
|
76
|
-
last_seen INTEGER NOT NULL,
|
|
77
|
-
created_at INTEGER NOT NULL
|
|
78
|
-
)
|
|
79
|
-
`
|
|
80
|
-
|
|
81
|
-
// sqlite-vec virtual table — created only when sqlite-vec extension is loaded.
|
|
82
|
-
// Migration runner wraps this in try/catch and skips gracefully if unavailable.
|
|
83
|
-
export const CREATE_COMMIT_EMBEDDINGS = `
|
|
84
|
-
CREATE VIRTUAL TABLE IF NOT EXISTS commit_embeddings USING vec0(
|
|
85
|
-
commit_id TEXT PRIMARY KEY,
|
|
86
|
-
embedding FLOAT[384]
|
|
87
|
-
)
|
|
88
|
-
`
|
|
89
|
-
|
|
90
|
-
// FTS5 full-text search — migration v2 (added in Week 4)
|
|
91
|
-
export const CREATE_COMMITS_FTS = `
|
|
92
|
-
CREATE VIRTUAL TABLE IF NOT EXISTS commits_fts USING fts5(
|
|
93
|
-
commit_id UNINDEXED,
|
|
94
|
-
message,
|
|
95
|
-
content,
|
|
96
|
-
summary,
|
|
97
|
-
content='commits',
|
|
98
|
-
content_rowid='rowid'
|
|
99
|
-
)
|
|
100
|
-
`
|
|
101
|
-
|
|
102
|
-
export const CREATE_INDEXES = [
|
|
103
|
-
`CREATE INDEX IF NOT EXISTS idx_commits_branch ON commits(branch_id, created_at DESC)`,
|
|
104
|
-
`CREATE INDEX IF NOT EXISTS idx_commits_workflow ON commits(branch_id, workflow_type, created_at DESC)`,
|
|
105
|
-
`CREATE INDEX IF NOT EXISTS idx_threads_project ON threads(project_id, status)`,
|
|
106
|
-
`CREATE INDEX IF NOT EXISTS idx_branches_git ON branches(project_id, git_branch)`,
|
|
107
|
-
]
|
|
108
|
-
|
|
109
|
-
// Ordered list used by migration v1
|
|
110
|
-
export const SCHEMA_V1_DDL = [
|
|
111
|
-
CREATE_PROJECTS,
|
|
112
|
-
CREATE_BRANCHES,
|
|
113
|
-
CREATE_COMMITS,
|
|
114
|
-
CREATE_THREADS,
|
|
115
|
-
CREATE_AGENTS,
|
|
116
|
-
...CREATE_INDEXES,
|
|
117
|
-
]
|
|
118
|
-
|
|
119
|
-
// Trigger to keep commits_fts in sync when rows are inserted into commits.
|
|
120
|
-
// The FTS5 content table does NOT auto-index — the index must be maintained explicitly.
|
|
121
|
-
export const CREATE_FTS_TRIGGER = `
|
|
122
|
-
CREATE TRIGGER IF NOT EXISTS commits_ai AFTER INSERT ON commits BEGIN
|
|
123
|
-
INSERT INTO commits_fts(rowid, commit_id, message, content, summary)
|
|
124
|
-
VALUES (new.rowid, new.id, new.message, new.content, new.summary);
|
|
125
|
-
END
|
|
126
|
-
`
|
|
127
|
-
|
|
128
|
-
// Migration v2 adds FTS5 + the vec0 table (attempted separately)
|
|
129
|
-
export const SCHEMA_V2_DDL = [
|
|
130
|
-
CREATE_COMMITS_FTS,
|
|
131
|
-
]
|
|
132
|
-
|
|
133
|
-
// Migration v3 adds the FTS trigger and rebuilds the index for any pre-existing rows
|
|
134
|
-
export const SCHEMA_V3_DDL = [
|
|
135
|
-
CREATE_FTS_TRIGGER,
|
|
136
|
-
]
|
|
137
|
-
|
|
138
|
-
// Migration v4 adds the claims table for coordination primitives (claim/unclaim)
|
|
139
|
-
export const CREATE_CLAIMS = `
|
|
140
|
-
CREATE TABLE IF NOT EXISTS claims (
|
|
141
|
-
id TEXT PRIMARY KEY,
|
|
142
|
-
project_id TEXT NOT NULL REFERENCES projects(id),
|
|
143
|
-
branch_id TEXT NOT NULL REFERENCES branches(id),
|
|
144
|
-
task TEXT NOT NULL,
|
|
145
|
-
agent_id TEXT NOT NULL,
|
|
146
|
-
role TEXT NOT NULL,
|
|
147
|
-
claimed_at INTEGER NOT NULL,
|
|
148
|
-
status TEXT NOT NULL DEFAULT 'proposed',
|
|
149
|
-
ttl INTEGER NOT NULL,
|
|
150
|
-
released_at INTEGER
|
|
151
|
-
)
|
|
152
|
-
`
|
|
153
|
-
|
|
154
|
-
export const SCHEMA_V4_DDL = [
|
|
155
|
-
CREATE_CLAIMS,
|
|
156
|
-
`CREATE INDEX IF NOT EXISTS idx_claims_project ON claims(project_id, status)`,
|
|
157
|
-
]
|
|
@@ -1,300 +0,0 @@
|
|
|
1
|
-
// RemoteStore — ContextStore backed by HTTP fetch against the ContextGit store API.
|
|
2
|
-
//
|
|
3
|
-
// All ContextStore methods map to endpoints on the /v1/store router.
|
|
4
|
-
// Float32Array is serialized as number[] in JSON for transport.
|
|
5
|
-
// Date fields are parsed from ISO strings returned by the API.
|
|
6
|
-
|
|
7
|
-
import type {
|
|
8
|
-
Agent,
|
|
9
|
-
AgentInput,
|
|
10
|
-
Branch,
|
|
11
|
-
BranchInput,
|
|
12
|
-
Claim,
|
|
13
|
-
ClaimInput,
|
|
14
|
-
Commit,
|
|
15
|
-
CommitInput,
|
|
16
|
-
Pagination,
|
|
17
|
-
Project,
|
|
18
|
-
ProjectInput,
|
|
19
|
-
SearchResult,
|
|
20
|
-
SessionSnapshot,
|
|
21
|
-
SnapshotFormat,
|
|
22
|
-
Thread,
|
|
23
|
-
} from '@contextgit/core'
|
|
24
|
-
import type { ContextStore } from '../interface.js'
|
|
25
|
-
|
|
26
|
-
// ─── Date parsers ─────────────────────────────────────────────────────────────
|
|
27
|
-
|
|
28
|
-
type Raw = Record<string, unknown>
|
|
29
|
-
|
|
30
|
-
function d(s: unknown): Date {
|
|
31
|
-
return typeof s === 'string' ? new Date(s) : new Date(0)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function parseProject(raw: Raw): Project {
|
|
35
|
-
return { ...(raw as unknown as Project), createdAt: d(raw['createdAt']) }
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function parseBranch(raw: Raw): Branch {
|
|
39
|
-
return {
|
|
40
|
-
...(raw as unknown as Branch),
|
|
41
|
-
createdAt: d(raw['createdAt']),
|
|
42
|
-
mergedAt: raw['mergedAt'] ? d(raw['mergedAt']) : undefined,
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function parseCommit(raw: Raw): Commit {
|
|
47
|
-
return { ...(raw as unknown as Commit), createdAt: d(raw['createdAt']) }
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function parseThread(raw: Raw): Thread {
|
|
51
|
-
return { ...(raw as unknown as Thread), createdAt: d(raw['createdAt']) }
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function parseClaim(raw: Raw): Claim {
|
|
55
|
-
return {
|
|
56
|
-
...(raw as unknown as Claim),
|
|
57
|
-
claimedAt: d(raw['claimedAt']),
|
|
58
|
-
releasedAt: raw['releasedAt'] ? d(raw['releasedAt']) : undefined,
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function parseAgent(raw: Raw): Agent {
|
|
63
|
-
return {
|
|
64
|
-
...(raw as unknown as Agent),
|
|
65
|
-
createdAt: d(raw['createdAt']),
|
|
66
|
-
lastSeen: d(raw['lastSeen']),
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// ─── RemoteStore ──────────────────────────────────────────────────────────────
|
|
71
|
-
|
|
72
|
-
export class RemoteStore implements ContextStore {
|
|
73
|
-
private readonly base: string
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* @param baseUrl Root URL of a ContextGit API server, e.g. http://localhost:3141
|
|
77
|
-
* The store router must be mounted at /v1/store on that server.
|
|
78
|
-
*/
|
|
79
|
-
constructor(baseUrl: string) {
|
|
80
|
-
this.base = baseUrl.replace(/\/$/, '') + '/v1/store'
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
private url(path: string): string {
|
|
84
|
-
return `${this.base}${path}`
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
private async req<T>(method: string, path: string, body?: unknown): Promise<T> {
|
|
88
|
-
const res = await fetch(this.url(path), {
|
|
89
|
-
method,
|
|
90
|
-
headers: { 'Content-Type': 'application/json' },
|
|
91
|
-
...(body !== undefined ? { body: JSON.stringify(body) } : {}),
|
|
92
|
-
})
|
|
93
|
-
if (res.status === 204) return undefined as T
|
|
94
|
-
if (!res.ok) {
|
|
95
|
-
const text = await res.text()
|
|
96
|
-
throw new Error(`RemoteStore ${method} ${path} → ${res.status}: ${text}`)
|
|
97
|
-
}
|
|
98
|
-
const ct = res.headers.get('content-type') ?? ''
|
|
99
|
-
if (ct.includes('application/json')) return res.json() as Promise<T>
|
|
100
|
-
return res.text() as Promise<T>
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// ── Projects ────────────────────────────────────────────────────────────────
|
|
104
|
-
|
|
105
|
-
async createProject(project: ProjectInput): Promise<Project> {
|
|
106
|
-
const raw = await this.req<Raw>('POST', '/projects', project)
|
|
107
|
-
return parseProject(raw)
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
async getProject(id: string): Promise<Project | null> {
|
|
111
|
-
try {
|
|
112
|
-
const raw = await this.req<Raw>('GET', `/projects/${id}`)
|
|
113
|
-
return parseProject(raw)
|
|
114
|
-
} catch {
|
|
115
|
-
return null
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// ── Branches ────────────────────────────────────────────────────────────────
|
|
120
|
-
|
|
121
|
-
async createBranch(branch: BranchInput): Promise<Branch> {
|
|
122
|
-
const raw = await this.req<Raw>('POST', '/branches', branch)
|
|
123
|
-
return parseBranch(raw)
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
async getBranch(id: string): Promise<Branch | null> {
|
|
127
|
-
try {
|
|
128
|
-
const raw = await this.req<Raw>('GET', `/branches/${id}`)
|
|
129
|
-
return parseBranch(raw)
|
|
130
|
-
} catch {
|
|
131
|
-
return null
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
async getBranchByGitName(projectId: string, gitBranch: string): Promise<Branch | null> {
|
|
136
|
-
try {
|
|
137
|
-
const raw = await this.req<Raw>(
|
|
138
|
-
'GET',
|
|
139
|
-
`/projects/${projectId}/branches?git=${encodeURIComponent(gitBranch)}`,
|
|
140
|
-
)
|
|
141
|
-
return parseBranch(raw)
|
|
142
|
-
} catch {
|
|
143
|
-
return null
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
async listBranches(projectId: string): Promise<Branch[]> {
|
|
148
|
-
const raw = await this.req<Raw[]>('GET', `/projects/${projectId}/branches`)
|
|
149
|
-
return raw.map(parseBranch)
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
async updateBranchHead(branchId: string, commitId: string): Promise<void> {
|
|
153
|
-
await this.req('PUT', `/branches/${branchId}/head`, { commitId })
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
async mergeBranch(
|
|
157
|
-
sourceBranchId: string,
|
|
158
|
-
targetBranchId: string,
|
|
159
|
-
summary: string,
|
|
160
|
-
): Promise<Commit> {
|
|
161
|
-
const raw = await this.req<Raw>('POST', `/branches/${sourceBranchId}/merge`, {
|
|
162
|
-
targetBranchId,
|
|
163
|
-
summary,
|
|
164
|
-
})
|
|
165
|
-
return parseCommit(raw)
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
// ── Commits ─────────────────────────────────────────────────────────────────
|
|
169
|
-
|
|
170
|
-
async createCommit(commit: CommitInput): Promise<Commit> {
|
|
171
|
-
const raw = await this.req<Raw>('POST', '/commits', commit)
|
|
172
|
-
return parseCommit(raw)
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
async getCommit(id: string): Promise<Commit | null> {
|
|
176
|
-
try {
|
|
177
|
-
const raw = await this.req<Raw>('GET', `/commits/${id}`)
|
|
178
|
-
return parseCommit(raw)
|
|
179
|
-
} catch {
|
|
180
|
-
return null
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
async listCommits(branchId: string, pagination: Pagination): Promise<Commit[]> {
|
|
185
|
-
const qs = `limit=${pagination.limit}&offset=${pagination.offset}`
|
|
186
|
-
const raw = await this.req<Raw[]>('GET', `/branches/${branchId}/commits?${qs}`)
|
|
187
|
-
return raw.map(parseCommit)
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
// ── Snapshots ────────────────────────────────────────────────────────────────
|
|
191
|
-
|
|
192
|
-
async getSessionSnapshot(projectId: string, branchId: string, options?: { agentRole?: string }): Promise<SessionSnapshot> {
|
|
193
|
-
let qs = `branchId=${encodeURIComponent(branchId)}`
|
|
194
|
-
if (options?.agentRole) qs += `&agentRole=${encodeURIComponent(options.agentRole)}`
|
|
195
|
-
const raw = await this.req<{
|
|
196
|
-
projectSummary: string
|
|
197
|
-
branchName: string
|
|
198
|
-
branchSummary: string
|
|
199
|
-
recentCommits: Raw[]
|
|
200
|
-
openThreads: Raw[]
|
|
201
|
-
activeClaims?: Raw[]
|
|
202
|
-
}>('GET', `/projects/${projectId}/session-snapshot?${qs}`)
|
|
203
|
-
return {
|
|
204
|
-
projectSummary: raw.projectSummary,
|
|
205
|
-
branchName: raw.branchName,
|
|
206
|
-
branchSummary: raw.branchSummary,
|
|
207
|
-
recentCommits: raw.recentCommits.map(parseCommit),
|
|
208
|
-
openThreads: raw.openThreads.map(parseThread),
|
|
209
|
-
activeClaims: (raw.activeClaims ?? []).map(parseClaim),
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
async getFormattedSnapshot(
|
|
214
|
-
projectId: string,
|
|
215
|
-
branchId: string,
|
|
216
|
-
format: SnapshotFormat,
|
|
217
|
-
): Promise<string> {
|
|
218
|
-
const qs = `branchId=${encodeURIComponent(branchId)}&format=${format}`
|
|
219
|
-
return this.req<string>('GET', `/projects/${projectId}/snapshot?${qs}`)
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
// ── Threads ──────────────────────────────────────────────────────────────────
|
|
223
|
-
|
|
224
|
-
async listOpenThreads(projectId: string): Promise<Thread[]> {
|
|
225
|
-
const raw = await this.req<Raw[]>('GET', `/projects/${projectId}/threads`)
|
|
226
|
-
return raw.map(parseThread)
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
async listOpenThreadsByBranch(branchId: string): Promise<Thread[]> {
|
|
230
|
-
const raw = await this.req<Raw[]>('GET', `/branches/${branchId}/threads`)
|
|
231
|
-
return raw.map(parseThread)
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
async syncThread(thread: Thread): Promise<Thread> {
|
|
235
|
-
const raw = await this.req<Raw>('POST', `/threads`, thread)
|
|
236
|
-
return parseThread(raw)
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
// ── Embeddings & Search ──────────────────────────────────────────────────────
|
|
240
|
-
|
|
241
|
-
async indexEmbedding(commitId: string, vector: Float32Array): Promise<void> {
|
|
242
|
-
await this.req('POST', `/commits/${commitId}/embedding`, { vector: Array.from(vector) })
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
async semanticSearch(
|
|
246
|
-
vector: Float32Array,
|
|
247
|
-
projectId: string,
|
|
248
|
-
limit: number,
|
|
249
|
-
): Promise<SearchResult[]> {
|
|
250
|
-
const raw = await this.req<Raw[]>('POST', `/projects/${projectId}/search/semantic`, {
|
|
251
|
-
vector: Array.from(vector),
|
|
252
|
-
limit,
|
|
253
|
-
})
|
|
254
|
-
return raw.map(r => ({
|
|
255
|
-
commit: parseCommit(r['commit'] as Raw),
|
|
256
|
-
score: r['score'] as number,
|
|
257
|
-
matchType: r['matchType'] as 'semantic' | 'fulltext',
|
|
258
|
-
}))
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
async fullTextSearch(query: string, projectId: string): Promise<SearchResult[]> {
|
|
262
|
-
const raw = await this.req<Raw[]>(
|
|
263
|
-
'GET',
|
|
264
|
-
`/projects/${projectId}/search?q=${encodeURIComponent(query)}`,
|
|
265
|
-
)
|
|
266
|
-
return raw.map(r => ({
|
|
267
|
-
commit: parseCommit(r['commit'] as Raw),
|
|
268
|
-
score: r['score'] as number,
|
|
269
|
-
matchType: r['matchType'] as 'semantic' | 'fulltext',
|
|
270
|
-
}))
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
// ── Claims ───────────────────────────────────────────────────────────────────
|
|
274
|
-
|
|
275
|
-
async claimTask(projectId: string, branchId: string, input: ClaimInput): Promise<Claim> {
|
|
276
|
-
const raw = await this.req<Raw>('POST', `/projects/${projectId}/claims`, { branchId, ...input })
|
|
277
|
-
return parseClaim(raw)
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
async unclaimTask(claimId: string): Promise<void> {
|
|
281
|
-
await this.req('DELETE', `/claims/${claimId}`)
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
async listActiveClaims(projectId: string): Promise<Claim[]> {
|
|
285
|
-
const raw = await this.req<Raw[]>('GET', `/projects/${projectId}/claims`)
|
|
286
|
-
return raw.map(parseClaim)
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
// ── Agents ───────────────────────────────────────────────────────────────────
|
|
290
|
-
|
|
291
|
-
async upsertAgent(agent: AgentInput): Promise<Agent> {
|
|
292
|
-
const raw = await this.req<Raw>('POST', '/agents', agent)
|
|
293
|
-
return parseAgent(raw)
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
async listAgents(projectId: string): Promise<Agent[]> {
|
|
297
|
-
const raw = await this.req<Raw[]>('GET', `/projects/${projectId}/agents`)
|
|
298
|
-
return raw.map(parseAgent)
|
|
299
|
-
}
|
|
300
|
-
}
|
package/pnpm-workspace.yaml
DELETED
package/scripts/build.sh
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# build.sh — build all ContextGit packages in dependency order
|
|
3
|
-
set -euo pipefail
|
|
4
|
-
|
|
5
|
-
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
6
|
-
cd "$ROOT"
|
|
7
|
-
|
|
8
|
-
echo "==> Installing dependencies"
|
|
9
|
-
pnpm install
|
|
10
|
-
|
|
11
|
-
echo "==> Building @contextgit/core"
|
|
12
|
-
pnpm --filter @contextgit/core build
|
|
13
|
-
|
|
14
|
-
echo "==> Building @contextgit/store"
|
|
15
|
-
pnpm --filter @contextgit/store build
|
|
16
|
-
|
|
17
|
-
echo "==> Building @contextgit/mcp"
|
|
18
|
-
pnpm --filter @contextgit/mcp build
|
|
19
|
-
|
|
20
|
-
echo "==> Building @contextgit/cli"
|
|
21
|
-
pnpm --filter @contextgit/cli build
|
|
22
|
-
|
|
23
|
-
echo "==> Building @contextgit/api"
|
|
24
|
-
pnpm --filter @contextgit/api build
|
|
25
|
-
|
|
26
|
-
echo ""
|
|
27
|
-
echo "Build complete. Run 'contextgit --help' via:"
|
|
28
|
-
echo " node packages/cli/bin/run.js --help"
|
package/tsconfig.base.json
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2022",
|
|
4
|
-
"module": "NodeNext",
|
|
5
|
-
"moduleResolution": "NodeNext",
|
|
6
|
-
"strict": true,
|
|
7
|
-
"esModuleInterop": true,
|
|
8
|
-
"skipLibCheck": true,
|
|
9
|
-
"declaration": true,
|
|
10
|
-
"declarationMap": true,
|
|
11
|
-
"sourceMap": true,
|
|
12
|
-
"outDir": "./dist"
|
|
13
|
-
}
|
|
14
|
-
}
|
package/vitest.config.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'vitest/config'
|
|
2
|
-
|
|
3
|
-
export default defineConfig({
|
|
4
|
-
test: {
|
|
5
|
-
globals: true,
|
|
6
|
-
environment: 'node',
|
|
7
|
-
include: ['packages/*/src/**/*.test.ts', 'packages/*/src/**/*.spec.ts'],
|
|
8
|
-
coverage: {
|
|
9
|
-
provider: 'v8',
|
|
10
|
-
reporter: ['text', 'lcov'],
|
|
11
|
-
include: ['packages/*/src/**/*.ts'],
|
|
12
|
-
exclude: ['**/*.test.ts', '**/*.spec.ts', '**/index.ts'],
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
})
|
|
File without changes
|