@contextgit/store 0.1.9 → 0.2.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/dist/interface.d.ts +26 -1
- package/dist/interface.d.ts.map +1 -1
- package/dist/local/index.d.ts +26 -1
- package/dist/local/index.d.ts.map +1 -1
- package/dist/local/index.js +216 -6
- package/dist/local/index.js.map +1 -1
- package/dist/local/local-store.test.js +642 -2
- package/dist/local/local-store.test.js.map +1 -1
- package/dist/local/migrations.d.ts +11 -0
- package/dist/local/migrations.d.ts.map +1 -1
- package/dist/local/migrations.js +118 -1
- package/dist/local/migrations.js.map +1 -1
- package/dist/local/plan-nodes.test.d.ts +2 -0
- package/dist/local/plan-nodes.test.d.ts.map +1 -0
- package/dist/local/plan-nodes.test.js +291 -0
- package/dist/local/plan-nodes.test.js.map +1 -0
- package/dist/local/queries.d.ts +103 -2
- package/dist/local/queries.d.ts.map +1 -1
- package/dist/local/queries.js +506 -16
- package/dist/local/queries.js.map +1 -1
- package/dist/local/schema.d.ts +8 -0
- package/dist/local/schema.d.ts.map +1 -1
- package/dist/local/schema.js +88 -0
- package/dist/local/schema.js.map +1 -1
- package/dist/local/thread-archive.test.d.ts +2 -0
- package/dist/local/thread-archive.test.d.ts.map +1 -0
- package/dist/local/thread-archive.test.js +203 -0
- package/dist/local/thread-archive.test.js.map +1 -0
- package/dist/remote/index.d.ts +15 -0
- package/dist/remote/index.d.ts.map +1 -1
- package/dist/remote/index.js +44 -0
- package/dist/remote/index.js.map +1 -1
- package/dist/supabase/index.d.ts +15 -0
- package/dist/supabase/index.d.ts.map +1 -1
- package/dist/supabase/index.js +45 -2
- package/dist/supabase/index.js.map +1 -1
- package/package.json +2 -2
package/dist/local/queries.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Database } from 'better-sqlite3';
|
|
2
|
-
import type { Agent, AgentInput, Branch, BranchInput, Claim, ClaimInput, Commit, CommitInput, Pagination, Project, ProjectInput, SearchResult, SessionSnapshot, Thread } from '@contextgit/core';
|
|
2
|
+
import type { Agent, AgentInput, ArchivedThread, Branch, BranchInput, Claim, ClaimInput, Commit, CommitInput, Pagination, PlanNode, PlanNodeInput, PlanNodeStatus, Project, ProjectInput, SearchResult, SessionSnapshot, Thread, TraceEntry } from '@contextgit/core';
|
|
3
3
|
export declare class Queries {
|
|
4
4
|
private readonly db;
|
|
5
5
|
private readonly stmts;
|
|
@@ -20,13 +20,72 @@ export declare class Queries {
|
|
|
20
20
|
getCommit(id: string): Commit | null;
|
|
21
21
|
listCommits(branchId: string, pagination: Pagination): Commit[];
|
|
22
22
|
getLastCommit(branchId: string): Commit | null;
|
|
23
|
-
insertThread(id: string, description: string, projectId: string, branchId: string, openedInCommit: string, workflowType: string | null): Thread;
|
|
23
|
+
insertThread(id: string, description: string, projectId: string, branchId: string, openedInCommit: string, workflowType: string | null, kind?: Thread['kind']): Thread;
|
|
24
24
|
syncThread(thread: Thread): Thread;
|
|
25
25
|
closeThread(threadId: string, closedInCommit: string, note: string): void;
|
|
26
|
+
/**
|
|
27
|
+
* Move an open thread from `threads` to `thread_archive`. Single transaction.
|
|
28
|
+
* `closedInCommit` is the commit triggering the archive (the save's new commit
|
|
29
|
+
* for manual closes; the last-touched commit for sweep-based archival).
|
|
30
|
+
*/
|
|
31
|
+
archiveThread(threadId: string, reason: ArchivedThread['archivedReason'], closedInCommit: string | null): ArchivedThread;
|
|
32
|
+
/**
|
|
33
|
+
* Move a row from `thread_archive` back to `threads` with `status='open'`,
|
|
34
|
+
* clearing closed_in_commit and closed_note (the restore semantically reopens it).
|
|
35
|
+
*/
|
|
36
|
+
restoreThread(threadId: string): Thread;
|
|
37
|
+
listArchivedThreads(projectId: string): ArchivedThread[];
|
|
38
|
+
/**
|
|
39
|
+
* Bulk restore: move every archived row matching one of the given reasons back
|
|
40
|
+
* to `threads`. Returns the number of rows moved. Used to recover from a wrong
|
|
41
|
+
* one-time-sweep (e.g. the 0.2.1 calibration bug that archived live threads on
|
|
42
|
+
* long-lived branches via the old OR-of-distance rule).
|
|
43
|
+
*/
|
|
44
|
+
restoreAllArchivedByReason(projectId: string, reasons: ArchivedThread['archivedReason'][]): number;
|
|
45
|
+
/**
|
|
46
|
+
* Find an open thread on this project whose normalized description matches.
|
|
47
|
+
* Used by dedupe-on-save (02 DELTA spec §A) — open-thread count per project is
|
|
48
|
+
* bounded by the decay system being built, so a JS-side scan is acceptable.
|
|
49
|
+
*/
|
|
50
|
+
findOpenThreadByNormalizedDescription(projectId: string, normalized: string): Thread | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* Resolve a 6-char handle to an open thread on the project.
|
|
53
|
+
* Returns undefined if no match; throws if multiple match (collision).
|
|
54
|
+
*/
|
|
55
|
+
findOpenThreadByHandle(projectId: string, handle: string): Thread | undefined;
|
|
56
|
+
findArchivedThreadByHandle(projectId: string, handle: string): ArchivedThread | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Project-scoped sweep run by createCommit at the end of every save: any open
|
|
59
|
+
* thread on this project that classifies as `stale` or `expired` is moved to
|
|
60
|
+
* `thread_archive`. Returns counts by reason for the save response.
|
|
61
|
+
*/
|
|
62
|
+
sweepStaleThreads(projectId: string, now: number): {
|
|
63
|
+
archived: number;
|
|
64
|
+
byReason: {
|
|
65
|
+
'stale-age': number;
|
|
66
|
+
'stale-distance': number;
|
|
67
|
+
'watch-expired': number;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
updateThreadLastTouched(threadId: string, commitId: string): void;
|
|
26
71
|
listOpenThreads(projectId: string): Thread[];
|
|
27
72
|
listOpenThreadsByBranch(branchId: string): Thread[];
|
|
73
|
+
/**
|
|
74
|
+
* Set the derived `stale` (open) or `expired` (watch) flag on a thread by
|
|
75
|
+
* looking up the touched commit's timestamp and counting project/branch
|
|
76
|
+
* commits since. Returns a new Thread — never mutates the input.
|
|
77
|
+
*/
|
|
78
|
+
private attachDecayFlags;
|
|
28
79
|
/** Move open threads from source branch to target (called during merge). */
|
|
29
80
|
reassignOpenThreads(fromBranchId: string, toBranchId: string): void;
|
|
81
|
+
insertTraceEntry(input: {
|
|
82
|
+
id: string;
|
|
83
|
+
projectId: string;
|
|
84
|
+
branchId: string;
|
|
85
|
+
note: string;
|
|
86
|
+
gitCommitSha?: string;
|
|
87
|
+
}): TraceEntry;
|
|
88
|
+
listTraceEntries(projectId: string, pagination: Pagination): TraceEntry[];
|
|
30
89
|
upsertAgent(input: AgentInput): Agent;
|
|
31
90
|
incrementAgentCommits(agentId: string): void;
|
|
32
91
|
listAgents(projectId: string): Agent[];
|
|
@@ -38,9 +97,51 @@ export declare class Queries {
|
|
|
38
97
|
listThreadChangesSince(projectId: string, since: number): Thread[];
|
|
39
98
|
getSessionSnapshot(projectId: string, branchId: string, options?: {
|
|
40
99
|
agentRole?: string;
|
|
100
|
+
commitWindow?: number;
|
|
41
101
|
}): SessionSnapshot;
|
|
42
102
|
semanticSearch(db: Database, embeddingVector: Float32Array, projectId: string, limit: number): SearchResult[];
|
|
43
103
|
fullTextSearch(db: Database, query: string, projectId: string): SearchResult[];
|
|
44
104
|
insertEmbedding(db: Database, commitId: string, embedding: Float32Array): void;
|
|
105
|
+
/**
|
|
106
|
+
* Insert a plan tree of arbitrary depth atomically. `level` is semantic:
|
|
107
|
+
* - root (parent_id IS NULL) → 'plan'
|
|
108
|
+
* - has children at insert time → 'step' (container)
|
|
109
|
+
* - no children at insert time → 'task' (leaf)
|
|
110
|
+
*
|
|
111
|
+
* Hierarchy is determined by parent_id, not by depth. The depth-based
|
|
112
|
+
* mapping from earlier 04 DELTA versions was wrong on trees deeper than 3
|
|
113
|
+
* (Slice at depth 2 would get labeled 'task' but actually had children).
|
|
114
|
+
* Content-based labeling is correct at any depth.
|
|
115
|
+
*/
|
|
116
|
+
insertPlanTree(projectId: string, input: PlanNodeInput): PlanNode;
|
|
117
|
+
/**
|
|
118
|
+
* Read the active plan tree for a project. Top-level plans with full child
|
|
119
|
+
* trees and derived `progress = { done, total }` per node — DIRECT-CHILD
|
|
120
|
+
* semantics: progress.total = number of direct children; progress.done =
|
|
121
|
+
* number of direct children that are effectively-done. Effectively-done
|
|
122
|
+
* propagates recursively: a node is effectively-done if (it has no children
|
|
123
|
+
* AND status='done') OR (it has children AND every child is effectively-done).
|
|
124
|
+
*
|
|
125
|
+
* Plans that are effectively-done are excluded from the active view — they
|
|
126
|
+
* belong in listCompletedPlans.
|
|
127
|
+
*/
|
|
128
|
+
getPlanTree(projectId: string): PlanNode[];
|
|
129
|
+
/**
|
|
130
|
+
* List plans (parent_id IS NULL) that are effectively-done. The completed
|
|
131
|
+
* delivery record — kept indefinitely, never archived.
|
|
132
|
+
*/
|
|
133
|
+
listCompletedPlans(projectId: string): PlanNode[];
|
|
134
|
+
/** Shared tree builder for getPlanTree / listCompletedPlans. */
|
|
135
|
+
private buildPlanTrees;
|
|
136
|
+
/**
|
|
137
|
+
* Set a plan node's status. When transitioning to 'done', stamps completed_at
|
|
138
|
+
* and optionally git_commit_sha (the commit that completed it).
|
|
139
|
+
*/
|
|
140
|
+
updatePlanNodeStatus(id: string, status: PlanNodeStatus, gitCommitSha: string | null): void;
|
|
141
|
+
updatePlanNodeTitle(id: string, title: string): void;
|
|
142
|
+
/** Resolve a 6-char handle to a plan node. Throws on prefix collision. */
|
|
143
|
+
findPlanNodeByHandle(projectId: string, handle: string): PlanNode | undefined;
|
|
144
|
+
/** Resolve an exact title match. Throws when the title is ambiguous across nodes. */
|
|
145
|
+
findPlanNodeByTitle(projectId: string, title: string): PlanNode | undefined;
|
|
45
146
|
}
|
|
46
147
|
//# sourceMappingURL=queries.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../src/local/queries.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAa,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../src/local/queries.ts"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