@fabersep/memory 0.2.1 → 0.4.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.
@@ -5,6 +5,7 @@ import { compileGlobalL0 } from './compiler.js';
5
5
  import { parseMarkdownWithFrontmatter, serializeEntryMarkdown, slugify, } from './frontmatter.js';
6
6
  import { buildCompareUrl, createThrowawayWorktree, getDefaultBranch, getRemoteUrl, gitCommitFiles, gitPullFfOnly, gitSync, isBranchProtectionRejection, readHeadFile, removeThrowawayWorktree, } from './git.js';
7
7
  import { formatHygieneErrors, scanHygiene } from './hygiene.js';
8
+ import { isReadOnlyRoot, pullRebaseBeforeCommit, READ_ONLY_MESSAGE } from './personal-remote.js';
8
9
  import { appendMetric } from './metrics.js';
9
10
  import { PROJECT_MEMORY_REL_DIR } from './store.js';
10
11
  export const CACHE_GUIDANCE_NOTE = 'Note: Updated L0 applies to new sessions; batching reviews at session end maximizes prompt-cache reuse.';
@@ -179,6 +180,7 @@ export async function approveProposalsBatch(config, proposals, options = {}) {
179
180
  const approvedIds = [];
180
181
  let compareUrl;
181
182
  let recompiledL0 = false;
183
+ let personalCommitted = false;
182
184
  if (proposals.length === 0) {
183
185
  return { ok: true, approvedIds: [], messages: ['No proposals to approve.'], errors: [] };
184
186
  }
@@ -207,6 +209,13 @@ export async function approveProposalsBatch(config, proposals, options = {}) {
207
209
  errors.push('Personal memory root is not configured.');
208
210
  return { ok: false, approvedIds, messages, errors };
209
211
  }
212
+ if (isReadOnlyRoot(root)) {
213
+ errors.push(READ_ONLY_MESSAGE);
214
+ return { ok: false, approvedIds, messages, errors };
215
+ }
216
+ const pullWarning = await pullRebaseBeforeCommit(root);
217
+ if (pullWarning)
218
+ messages.push(pullWarning);
210
219
  const touched = [];
211
220
  for (const p of personalProps) {
212
221
  touched.push(...applyProposalFilesToDir(root.path, '', p));
@@ -231,6 +240,7 @@ export async function approveProposalsBatch(config, proposals, options = {}) {
231
240
  return { ok: false, approvedIds, messages, errors };
232
241
  }
233
242
  recompiledL0 = true;
243
+ personalCommitted = true;
234
244
  messages.push(`Approved ${personalProps.length} personal proposal(s) in 1 commit and recompiled L0 (${comp.estimatedTokens}/${comp.budget} tokens).`);
235
245
  }
236
246
  // 2. Project scope: write uncommitted file(s) and mark awaiting_commit
@@ -288,6 +298,7 @@ export async function approveProposalsBatch(config, proposals, options = {}) {
288
298
  errors: [],
289
299
  compareUrl,
290
300
  recompiledL0,
301
+ personalCommitted,
291
302
  };
292
303
  }
293
304
  async function approveTeamBatch(config, root, teamProps, homeDir, overrideMode) {
package/dist/src/sync.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { getHomeDir } from './config.js';
2
2
  import { compileGlobalL0 } from './compiler.js';
3
3
  import { getHeadSha, gitPullFfOnly, hasRemote } from './git.js';
4
+ import { recordSuccessfulPull } from './personal-remote.js';
4
5
  export async function syncAllRoots(config, options = {}) {
5
6
  const homeDir = options.homeDir || getHomeDir();
6
7
  const timeoutMs = options.timeoutMs ?? 5000;
@@ -22,6 +23,8 @@ export async function syncAllRoots(config, options = {}) {
22
23
  warnings.push(msg);
23
24
  continue;
24
25
  }
26
+ if (root.scope === 'personal')
27
+ recordSuccessfulPull(homeDir);
25
28
  const afterSha = getHeadSha(root.path);
26
29
  if (beforeSha !== afterSha) {
27
30
  advanced = true;
@@ -3,6 +3,7 @@ export type EntryType = 'rule' | 'decision' | 'lesson' | 'preference' | 'referen
3
3
  export type EntryStatus = 'active' | 'deprecated' | 'superseded';
4
4
  export type L0Mode = 'none' | 'line' | 'body';
5
5
  export type TeamSubmitMode = 'auto' | 'pr';
6
+ export type PushMode = 'ask' | 'auto' | 'never';
6
7
  export type ProposalAction = 'create' | 'update' | 'supersede';
7
8
  export type ProposalStatus = 'pending' | 'awaiting_commit' | 'push_failed';
8
9
  export type ProjectRootSource = 'mcp-roots' | 'cwd' | 'none';
@@ -10,6 +11,7 @@ export declare const COMPILER_VERSION: string;
10
11
  export declare const DEFAULT_TOKEN_BUDGET = 1500;
11
12
  export declare const DEFAULT_STALE_DAYS = 14;
12
13
  export declare const DEFAULT_SIMILARITY_THRESHOLD = 0.45;
14
+ export declare const DEFAULT_SIMILARITY_HINT_FLOOR = 0.25;
13
15
  export declare const VALID_TYPES: readonly EntryType[];
14
16
  export declare const VALID_STATUSES: readonly EntryStatus[];
15
17
  export declare const VALID_L0_MODES: readonly L0Mode[];
@@ -20,6 +22,10 @@ export interface RootConfig {
20
22
  remote?: string;
21
23
  defaultBranch?: string;
22
24
  submitMode?: TeamSubmitMode;
25
+ /** Personal root only: what happens after an approve commits (feature 03 `FR-02`). */
26
+ pushMode?: PushMode;
27
+ /** Personal root only: a host that only reads (feature 03 `FR-05`). */
28
+ readOnly?: boolean;
23
29
  }
24
30
  export interface UserConfig {
25
31
  version: 1;
@@ -27,6 +33,8 @@ export interface UserConfig {
27
33
  tokenBudget: number;
28
34
  staleDays: number;
29
35
  similarityThreshold: number;
36
+ /** Lower bound for the related-entry notice on a staged create (01 FR-04 amendment). */
37
+ similarityHintFloor?: number;
30
38
  roots: {
31
39
  personal?: RootConfig;
32
40
  team?: RootConfig;
package/dist/src/types.js CHANGED
@@ -3,6 +3,7 @@ export const COMPILER_VERSION = getPackageVersion();
3
3
  export const DEFAULT_TOKEN_BUDGET = 1500;
4
4
  export const DEFAULT_STALE_DAYS = 14;
5
5
  export const DEFAULT_SIMILARITY_THRESHOLD = 0.45;
6
+ export const DEFAULT_SIMILARITY_HINT_FLOOR = 0.25;
6
7
  export const VALID_TYPES = [
7
8
  'rule',
8
9
  'decision',
@@ -0,0 +1,4 @@
1
+ export declare function getWebFaviconSvg(): string;
2
+ export declare function getWebIndexHtml(): string;
3
+ export declare function getWebCss(): string;
4
+ export declare function getWebClientJs(): string;