@fingerskier/augment 0.3.1 → 0.5.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 (67) hide show
  1. package/README.md +37 -20
  2. package/dist/cli.d.ts +9 -6
  3. package/dist/cli.js +9 -43
  4. package/dist/cli.js.map +1 -1
  5. package/dist/config.d.ts +2 -0
  6. package/dist/config.js +2 -1
  7. package/dist/config.js.map +1 -1
  8. package/dist/constants.d.ts +1 -0
  9. package/dist/constants.js +7 -0
  10. package/dist/constants.js.map +1 -1
  11. package/dist/daemon/client.d.ts +10 -2
  12. package/dist/daemon/client.js +30 -4
  13. package/dist/daemon/client.js.map +1 -1
  14. package/dist/daemon/http.js +163 -28
  15. package/dist/daemon/http.js.map +1 -1
  16. package/dist/db.d.ts +1 -0
  17. package/dist/db.js +35 -4
  18. package/dist/db.js.map +1 -1
  19. package/dist/decoction.d.ts +51 -0
  20. package/dist/decoction.js +184 -0
  21. package/dist/decoction.js.map +1 -0
  22. package/dist/install.d.ts +2 -0
  23. package/dist/install.js +68 -5
  24. package/dist/install.js.map +1 -1
  25. package/dist/mcp/apps.js +0 -16
  26. package/dist/mcp/apps.js.map +1 -1
  27. package/dist/mcp/insights.d.ts +4 -6
  28. package/dist/mcp/insights.js +4 -11
  29. package/dist/mcp/insights.js.map +1 -1
  30. package/dist/mcp/server.js +124 -21
  31. package/dist/mcp/server.js.map +1 -1
  32. package/dist/memory/files.js +32 -2
  33. package/dist/memory/files.js.map +1 -1
  34. package/dist/memory/git.d.ts +5 -1
  35. package/dist/memory/git.js +7 -3
  36. package/dist/memory/git.js.map +1 -1
  37. package/dist/memory/project.d.ts +3 -0
  38. package/dist/memory/project.js +20 -0
  39. package/dist/memory/project.js.map +1 -1
  40. package/dist/pi/extension.d.ts +10 -2
  41. package/dist/pi/extension.js +82 -46
  42. package/dist/pi/extension.js.map +1 -1
  43. package/dist/proposals.d.ts +42 -0
  44. package/dist/proposals.js +180 -0
  45. package/dist/proposals.js.map +1 -0
  46. package/dist/recall-log.d.ts +21 -0
  47. package/dist/recall-log.js +24 -0
  48. package/dist/recall-log.js.map +1 -0
  49. package/dist/recall.d.ts +1 -1
  50. package/dist/service.d.ts +197 -2
  51. package/dist/service.js +770 -42
  52. package/dist/service.js.map +1 -1
  53. package/dist/types.d.ts +26 -2
  54. package/docs/FEATURES.md +247 -33
  55. package/docs/verify-memory-flow.md +132 -131
  56. package/integrations/claude/skills/augment-context/SKILL.md +74 -0
  57. package/integrations/claude/skills/augment-decoction/SKILL.md +36 -0
  58. package/integrations/claude/skills/augment-dream/SKILL.md +34 -0
  59. package/integrations/claude/skills/augment-dream/agents/openai.yaml +4 -0
  60. package/integrations/claude/skills/augment-sleep/SKILL.md +26 -0
  61. package/integrations/codex/SKILL.md +33 -0
  62. package/integrations/pi/skills/augment-decoction/SKILL.md +37 -0
  63. package/integrations/pi/skills/augment-dream/SKILL.md +36 -0
  64. package/package.json +16 -15
  65. package/dist/tally.d.ts +0 -46
  66. package/dist/tally.js +0 -94
  67. package/dist/tally.js.map +0 -1
package/dist/service.d.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  import type { AugmentConfig } from "./config.js";
2
2
  import { AugmentDatabase } from "./db.js";
3
+ import { type DecoctionDiscoveryCluster } from "./decoction.js";
3
4
  import type { EmbeddingProvider } from "./embeddings.js";
5
+ import type { LinkType, MemoryKind } from "./constants.js";
6
+ import { type Proposal, type ProposalStatus } from "./proposals.js";
4
7
  import { type SleepCluster } from "./sleep.js";
5
8
  import type { LinkRecord, MemoryRecord, ProjectGraph, ProjectRecord, SearchInput, SearchResult, UpsertInput } from "./types.js";
6
9
  export interface InitProjectInput {
@@ -15,6 +18,58 @@ export interface SearchOutput {
15
18
  text: string;
16
19
  results: SearchResult[];
17
20
  }
21
+ export interface DecoctionRemovalSuggestion {
22
+ path: string;
23
+ reason: string;
24
+ }
25
+ export interface DecoctionGleanDiscoverInput {
26
+ action: "discover";
27
+ min_cosine?: number;
28
+ limit?: number;
29
+ }
30
+ export interface DecoctionGleanWriteInput {
31
+ action: "write";
32
+ kind: "SPEC" | "ARCH";
33
+ name: string;
34
+ content: string;
35
+ tags?: string[];
36
+ derived_from: string[];
37
+ suggested_removals?: DecoctionRemovalSuggestion[];
38
+ expected_content_hash?: string;
39
+ expected_frontmatter_hash?: string;
40
+ }
41
+ export type DecoctionGleanInput = DecoctionGleanDiscoverInput | DecoctionGleanWriteInput;
42
+ export interface DecoctionGleanDiscoverOutput {
43
+ action: "discover";
44
+ text: string;
45
+ eligible: number;
46
+ embedded: number;
47
+ min_cosine: number;
48
+ min_projects: number;
49
+ clusters: DecoctionDiscoveryCluster[];
50
+ }
51
+ export interface DecoctionGleanWriteOutput {
52
+ action: "write";
53
+ memory: MemoryRecord;
54
+ upsert_action: UpsertResult["action"];
55
+ suggested_removals: DecoctionRemovalSuggestion[];
56
+ warnings: string[];
57
+ text: string;
58
+ }
59
+ export interface DecoctionCleanupInput {
60
+ generic_path: string;
61
+ source_paths: string[];
62
+ }
63
+ export interface DecoctionCleanupResult {
64
+ generic_path: string;
65
+ results: Array<{
66
+ source_path: string;
67
+ status: "deleted" | "failed";
68
+ retargeted_links: number;
69
+ error?: string;
70
+ }>;
71
+ text: string;
72
+ }
18
73
  export interface SleepCandidatesInput {
19
74
  /** Restrict to one project; omit to preview candidates in every project (clusters never span projects). */
20
75
  project_name?: string;
@@ -28,6 +83,64 @@ export interface SleepCandidatesOutput {
28
83
  clusters: SleepCluster[];
29
84
  eligible: number;
30
85
  }
86
+ /** Draft a sleep consolidation: >=2 WORK sources fold into one new SPEC/ARCH.
87
+ * The proposal is written OUTSIDE the corpus for review; nothing is consolidated
88
+ * until {@link AugmentService.sleepApply}. */
89
+ export interface SleepProposeInput {
90
+ project_name: string;
91
+ kind: "SPEC" | "ARCH";
92
+ name: string;
93
+ content: string;
94
+ derived_from: string[];
95
+ rationale?: string;
96
+ }
97
+ export interface SleepApplyInput {
98
+ filename: string;
99
+ }
100
+ export interface SleepApplyOutput {
101
+ memory: MemoryRecord;
102
+ archived: string[];
103
+ proposal: Proposal;
104
+ text: string;
105
+ }
106
+ /** Draft a speculative memory in the active project from one or more existing
107
+ * inspirations. Inspirations are deliberately global: they may belong to the
108
+ * active project, the reserved generic project, or any foreign project. */
109
+ export interface DreamMemoryProposeInput {
110
+ project_name: string;
111
+ kind: MemoryKind;
112
+ name: string;
113
+ content: string;
114
+ derived_from: string[];
115
+ rationale?: string;
116
+ link?: never;
117
+ }
118
+ /** Draft a speculative link. Applying it may only rewrite a source in the
119
+ * active project, while the target may be current, generic, or foreign. */
120
+ export interface DreamLinkProposeInput {
121
+ project_name: string;
122
+ link: {
123
+ from: string;
124
+ to: string;
125
+ type: LinkType;
126
+ };
127
+ rationale?: string;
128
+ kind?: never;
129
+ name?: never;
130
+ content?: never;
131
+ derived_from?: never;
132
+ }
133
+ export type DreamProposeInput = DreamMemoryProposeInput | DreamLinkProposeInput;
134
+ export interface DreamApplyInput {
135
+ filename: string;
136
+ }
137
+ export interface DreamApplyOutput {
138
+ type: "dream-memory" | "dream-link";
139
+ proposal: Proposal;
140
+ memory?: MemoryRecord;
141
+ link?: LinkRecord;
142
+ text: string;
143
+ }
31
144
  export declare class AugmentService {
32
145
  private readonly config;
33
146
  private readonly embeddingProvider;
@@ -44,6 +157,10 @@ export declare class AugmentService {
44
157
  * searches. */
45
158
  private corpusPromise?;
46
159
  private readonly queryEmbeddingCache;
160
+ /** FIFO critical section for every corpus mutation. Compound operations use
161
+ * their private `*Core` helpers while holding this lock so their validation,
162
+ * frontmatter rewrites, and deletes cannot interleave with another request. */
163
+ private mutationTail;
47
164
  constructor(config: AugmentConfig, embeddingProvider?: EmbeddingProvider);
48
165
  useStateDir(stateDir: string): void;
49
166
  close(): Promise<void>;
@@ -72,6 +189,7 @@ export declare class AugmentService {
72
189
  */
73
190
  consumeSelfWrite(relativePath: string): boolean;
74
191
  private recordSelfWrite;
192
+ private memoryFileExists;
75
193
  upsert(input: UpsertInput): Promise<UpsertResult>;
76
194
  private upsertCore;
77
195
  read(id: number): Promise<MemoryRecord>;
@@ -101,17 +219,94 @@ export declare class AugmentService {
101
219
  }>;
102
220
  private unlinkCore;
103
221
  private invalidateCorpusSnapshot;
222
+ /** Queue one corpus mutation after the previous request, keeping the queue
223
+ * usable after failures. Assignment happens synchronously before any caller
224
+ * can enqueue the next request. */
225
+ private serializeMutation;
104
226
  private corpus;
105
227
  /** Query vectors depend only on the query text and the (process-pinned) model,
106
228
  * so unlike the corpus snapshot they never need invalidating on writes. */
107
229
  private embedQuery;
108
230
  search(input: SearchInput): Promise<SearchOutput>;
231
+ decoctionGlean(input: DecoctionGleanDiscoverInput): Promise<DecoctionGleanDiscoverOutput>;
232
+ decoctionGlean(input: DecoctionGleanWriteInput): Promise<DecoctionGleanWriteOutput>;
233
+ private decoctionGleanWrite;
234
+ decoctionCleanup(input: DecoctionCleanupInput): Promise<DecoctionCleanupResult>;
235
+ private decoctionCleanupCore;
109
236
  /**
110
237
  * READ-ONLY sleep preview: which settled WORK memories WOULD consolidate.
111
- * Performs zero writes the actual write-back (`sleep_apply`) is deferred
112
- * behind the Phase-2 go/no-go and does not exist.
238
+ * Performs zero writes; an agent must draft a proposal and receive explicit
239
+ * user approval before `sleep_apply` changes the corpus.
113
240
  */
114
241
  sleepCandidates(input?: SleepCandidatesInput, now?: number): Promise<SleepCandidatesOutput>;
242
+ /**
243
+ * Draft a sleep consolidation as a review artifact OUTSIDE the corpus. Writes
244
+ * nothing to the memory store: the corpus is only mutated by {@link sleepApply}
245
+ * on an explicitly approved proposal. Validates the sources up front (same
246
+ * checks apply re-runs against the live corpus) so an impossible proposal fails
247
+ * loudly at draft time.
248
+ */
249
+ sleepPropose(input: SleepProposeInput): Promise<{
250
+ proposal: Proposal;
251
+ text: string;
252
+ }>;
253
+ sleepProposals(status?: ProposalStatus): Promise<{
254
+ proposals: Proposal[];
255
+ text: string;
256
+ }>;
257
+ /**
258
+ * Apply an approved sleep proposal — the ONLY corpus mutation in the flow. The
259
+ * sequence is a contract: read the proposal fresh from disk (user edits count),
260
+ * require it still be `proposed`, re-validate against the LIVE corpus (drafts
261
+ * sit while the corpus moves underneath them), upsert the consolidated record
262
+ * (provenance threaded into frontmatter), archive each source in place (body
263
+ * untouched, verbatim), then flip the proposal to `applied`. Does NOT commit
264
+ * git: the route commits the whole pass as one revertible commit.
265
+ */
266
+ sleepApply(input: SleepApplyInput): Promise<SleepApplyOutput>;
267
+ private sleepApplyCore;
268
+ sleepReject(filename: string): Promise<{
269
+ proposal: Proposal;
270
+ text: string;
271
+ }>;
272
+ /**
273
+ * Draft one speculative memory or link outside the corpus. The daemon never
274
+ * synthesizes a dream: an agent supplies the complete candidate and this
275
+ * method only validates its live references and writes a review artifact.
276
+ */
277
+ dreamPropose(input: DreamProposeInput): Promise<{
278
+ proposal: Proposal;
279
+ text: string;
280
+ }>;
281
+ /** List the whole dreams/ proposal family, including both dream-memory and
282
+ * dream-link records. `dream-memory` is intentionally only the directory
283
+ * selector used by the shared proposal store. */
284
+ dreamProposals(status?: ProposalStatus): Promise<{
285
+ proposals: Proposal[];
286
+ text: string;
287
+ }>;
288
+ /** Apply the explicitly approved proposal after re-reading and re-validating
289
+ * it against the live corpus. The HTTP route owns the single git commit. */
290
+ dreamApply(input: DreamApplyInput): Promise<DreamApplyOutput>;
291
+ private dreamApplyCore;
292
+ dreamReject(filename: string): Promise<{
293
+ proposal: Proposal;
294
+ text: string;
295
+ }>;
296
+ private validateDreamMemory;
297
+ private validateDreamLink;
298
+ /**
299
+ * Shared sleep validation, run at propose time and re-run against the live
300
+ * corpus at apply time. Every source must resolve, be a WORK memory in
301
+ * `projectName` (single-project constraint), and be unarchived; there must be
302
+ * >=2 of them; and the consolidation target must not already exist. Every
303
+ * violation names the offending path.
304
+ */
305
+ private validateSleepSources;
306
+ /** Rewrite one source's frontmatter to archived + consolidated_into, leaving
307
+ * the body verbatim, and reindex it. Mirrors {@link scrubInboundLinks}. Returns
308
+ * the source's relative path. */
309
+ private archiveSource;
115
310
  private findSimilarMemory;
116
311
  private ensureEmbedding;
117
312
  }