pi-anchor 0.2.4 → 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.
package/dist/index.d.cts CHANGED
@@ -1,248 +1,42 @@
1
- import { a as AnchorStatus, b as Anchor, A as AnchorStore, T as TouchMatchResult, S as SettlementProposal } from './store-BNKjzhS_.cjs';
2
- export { c as AnchorDecayPolicy, d as AnchorDurability, e as AnchorEvidence, f as AnchorPriority, g as AnchorStoreState, D as DEFAULT_DECAY_POLICY, h as DURABLE_DECAY_POLICY, E as EPHEMERAL_DECAY_POLICY, i as acquireSyncLock, j as atomicRenameWithRetry, k as detectDurability, l as detectRecurrence, m as detectTargetDate, n as getDefaultStorageDir, o as getEphemeralDecayPolicy, p as getTodayDateString } from './store-BNKjzhS_.cjs';
1
+ import { A as Anchor, a as AnchorStore } from './extension-B1-fzCox.cjs';
2
+ export { b as AnchorEvidence, c as AnchorPriority, d as AnchorStatus, e as AnchorStoreState, C as COMMENT_FORMATS, M as MS_PER_DAY, Q as QUIET_AFTER_DAYS, T as TouchMatchResult, f as acquireSyncLock, g as atomicRenameWithRetry, h as extractPathsFromText, i as findMatchedAnchors, j as getDefaultStorageDir, k as globToRegExp, l as isAnchorTargetingWorkspace, m as isSameOrSubPath, n as makeSafeTaskAnnotation, o as matchAnchorAgainstTouchedFiles, p as matchesCommitMessage, q as normalizePath, r as parseAnchorCommandInput, s as renderActiveAnchorsContext, t as renderColdStartAnchorsContext, u as resolveAnchorTarget, v as sweepQuietNotes } from './extension-B1-fzCox.cjs';
3
3
  import { ExtensionContext } from '@earendil-works/pi-coding-agent';
4
4
 
5
- interface DecayEvaluation {
6
- currentStatus: AnchorStatus;
7
- nextStatus: AnchorStatus;
8
- daysUntouched: number;
9
- remainingActiveDays: number;
10
- remainingSleepDays: number;
11
- }
12
- /**
13
- * Calculate precise decay status based on elapsed time since last touch
14
- */
15
- declare function evaluateAnchorDecay(anchor: Anchor, now?: number): DecayEvaluation;
16
- interface SweepResult {
17
- transitionedToSleeping: string[];
18
- wokenToActive: string[];
19
- evictedToGraveyard: string[];
20
- }
21
- /**
22
- * Run decay sweep across store: transitions statuses and evicts expired anchors
23
- */
24
- declare function sweepStore(store: AnchorStore, now?: number): SweepResult;
25
-
26
- /**
27
- * Convert simple glob pattern (e.g. *.ts, src/**\/*.ts, src/auth/*.ts) to RegExp
28
- */
29
- declare function globToRegExp(pattern: string): RegExp;
30
- /**
31
- * Normalize path separators to POSIX forward slashes and optionally relative to baseCwd
32
- */
33
- declare function normalizePath(filePath: string, baseCwd?: string): string;
34
- /**
35
- * Compare two workspace CWDs safely (case-insensitive on Windows, supports subdirectory scoping)
36
- */
37
- declare function isSameOrSubPath(anchorCwd?: string, targetCwd?: string): boolean;
38
- /**
39
- * Match touched files against an anchor's registered physical patterns
40
- * Only anchors with explicit files/globs/prefixes are matched against file touches.
41
- * Anchors with files: [] (pure mental notes or macro tasks) NEVER trigger on file operations.
42
- */
43
- declare function matchAnchorAgainstTouchedFiles(anchor: Anchor, touchedFiles: string[]): TouchMatchResult | null;
44
- /**
45
- * Filter and sort anchors that match a set of touched files
46
- * Prioritizes high confidence (exact > prefix > keyword) and priority (P0 > P1 > P2).
47
- */
48
- declare function findMatchedAnchors(anchors: Anchor[], touchedFiles: string[]): TouchMatchResult[];
49
-
50
- /**
51
- * Execute physical verification test command for an anchor
52
- */
53
- declare function runPhysicalVerification(anchor: Anchor, cwd: string): {
54
- success: boolean;
55
- output: string;
56
- };
57
- /**
58
- * Generate settlement candidates based on files touched during the session
59
- */
60
- declare function generateSettlementProposals(store: AnchorStore, touchedFiles: string[], cwd?: string): SettlementProposal[];
61
- /**
62
- * Format settlement proposal into terminal-ready card
63
- */
64
- declare function formatSettlementCard(proposal: SettlementProposal): string;
65
-
66
- type AnchorQuadrant = 'Today' | 'Upcoming' | 'Habits' | 'Backlog';
67
- interface GroupedAnchors {
68
- today: Anchor[];
69
- upcoming: Anchor[];
70
- habits: Anchor[];
71
- backlog: Anchor[];
72
- }
73
- /**
74
- * Classify anchor into one of four cognitive quadrants:
75
- * - 'Today': Due today or overdue
76
- * - 'Upcoming': Due in the future (tomorrow, in 2d, specific dates)
77
- * - 'Habits': Daily recurring habits
78
- * - 'Backlog': Open-ended long-term vision
79
- */
80
- declare function classifyAnchor(anchor: Anchor, now?: number): AnchorQuadrant;
81
- /**
82
- * Group active anchors by cognitive quadrant
83
- */
84
- declare function groupAnchorsByQuadrant(anchors: Anchor[], now?: number): GroupedAnchors;
85
- /**
86
- * Strip ANSI escape codes from string
87
- */
88
5
  declare function stripAnsi(str: string): string;
89
6
  /**
90
- * Calculate display width in terminal columns, accounting for:
91
- * - ANSI escape codes (width 0)
92
- * - CJK ideographs & fullwidth forms (width 2)
93
- * - Japanese Kana (width 2)
94
- * - Korean Hangul syllables & Jamo (width 2)
95
- * - Emojis & Pictographs (width 2)
96
- * - Zero-width characters & joiners (width 0)
97
- * - Standard ASCII (width 1)
7
+ * Calculate visual terminal column width (CJK/Kana/Hangul/Emoji = 2 cells, ASCII = 1 cell)
98
8
  */
99
9
  declare function getDisplayWidth(str: string): number;
100
10
  declare function hasActiveUI(ctx: ExtensionContext | null | undefined): ctx is ExtensionContext;
101
- /**
102
- * Truncate string to target terminal visual width with ellipsis
103
- */
104
11
  declare function truncateToWidth(str: string, maxWidth: number, ellipsis?: string): string;
105
- /**
106
- * Pad and/or truncate string to exact visual column width, eliminating column tearing
107
- */
108
12
  declare function padToWidth(str: string, targetWidth: number): string;
109
13
  /**
110
- * Format expected completion date in human-intuitive terms:
111
- * - 'Daily' for daily recurring habits
112
- * - 'Today' if targetDate is today
113
- * - 'Tomorrow' if targetDate is tomorrow
114
- * - 'In 2d' / 'In 3d' for near-term dates
115
- * - 'MM-DD' for future dates
116
- * - 'Overdue' if targetDate is past
117
- * - 'Someday' for open-ended architecture/long-term vision
14
+ * Format relative sticky-note age cleanly: 'just now', '15m ago', '3h ago', '2d ago'
118
15
  */
119
- declare function formatTargetDate(anchor: Anchor, now?: number): string;
16
+ declare function formatRelativeAge(timestamp: number, now?: number): string;
120
17
  /**
121
- * Format creation timestamp as concise date/time:
122
- * - 'Today HH:MM' if created today
123
- * - 'Yesterday HH:MM' if created yesterday
124
- * - 'MM-DD HH:MM' if created this year
125
- * - 'YYYY-MM-DD' if older
18
+ * Format workspace & first file context concisely (e.g. 'anchor · src/auth.ts' or 'College/优化')
126
19
  */
127
- declare function formatCreationTime(timestamp: number, now?: number): string;
128
- /**
129
- * Backward compatibility alias
130
- */
131
- declare function formatRelativeTime(timestamp: number, now?: number): string;
132
- /**
133
- * Backward compatibility alias (now returns target date representation)
134
- */
135
- declare function formatRemainingTtl(anchor: Anchor, now?: number): string | undefined;
20
+ declare function formatOrigin(anchor: Anchor | string): string;
136
21
  /**
137
- * Format origin creation workspace folder (provenance: where the task was born/created)
22
+ * Sort sticky notes naturally:
23
+ * 1. Active notes before quiet (>7d untouched) notes
24
+ * 2. Notes belonging to current workspace first
25
+ * 3. Most recently touched first
138
26
  */
139
- declare function formatOrigin(anchor: Anchor | string): string;
27
+ declare function sortAnchorsForDisplay(anchors: Anchor[], cwd?: string): Anchor[];
140
28
  /**
141
- * Update footer status bar capsule: `⌖ 1`
29
+ * Update status bar badge: `⌖ 2` (invisible when 0 active notes)
142
30
  */
143
31
  declare function updateAnchorStatusBar(ctx: ExtensionContext, store: AnchorStore): void;
144
32
  /**
145
- * Render lightweight startup banner widget above the editor.
146
- * Features 3-4 lines with quadrant badges and target date hints.
147
- * Automatically cleared on agent_start (when user sends first message).
33
+ * Render clean sticky-note card above editor on session startup.
34
+ * Automatically disappears as soon as the user sends their first message.
148
35
  */
149
36
  declare function updateStartupBanner(ctx: ExtensionContext, store: AnchorStore): void;
150
37
  /**
151
- * Clean, columnar-aligned checklist with Target Date and Creation Time columns
38
+ * Interactive `/anchor` sticky-note board
152
39
  */
153
40
  declare function openAnchorDashboard(ctx: ExtensionContext, store: AnchorStore): Promise<void>;
154
41
 
155
- declare class SessionTouchObserver {
156
- private touchedFiles;
157
- private modifiedFiles;
158
- private inspectedFiles;
159
- private committed;
160
- private commitMessages;
161
- clear(): void;
162
- /**
163
- * Observe and record a tool call invocation, separating inspection from mutation
164
- */
165
- recordToolCall(toolName: string, input: Record<string, unknown>): void;
166
- /**
167
- * Add a file path manually (e.g. from git status diff)
168
- */
169
- addTouchedFile(filePath: string, isModified?: boolean): void;
170
- getModifiedFiles(): string[];
171
- getInspectedFiles(): string[];
172
- getTouchedFiles(): string[];
173
- hasCommitted(): boolean;
174
- getCommitMessages(): string[];
175
- /**
176
- * Check if any commit message explicitly references or resolves an anchor
177
- */
178
- matchesCommit(anchor: Anchor): {
179
- matched: boolean;
180
- message?: string;
181
- };
182
- }
183
-
184
- /**
185
- * Universal multi-language comment generator.
186
- * Maps file extension to safe comment syntax.
187
- * Formats that do not safely support comments (e.g. .json, .env, binary) return null.
188
- */
189
- declare const COMMENT_FORMATS: Record<string, (msg: string) => string>;
190
- /**
191
- * Format safe task context comment for a specific file.
192
- * Returns null for formats that do not safely support comments (e.g. .json, .env, .lock)
193
- */
194
- declare function makeSafeTaskAnnotation(filePath: string, anchor: Anchor): string | null;
195
- /**
196
- * Render ultra-compact cold-start context block for session turn 1.
197
- * Only active anchors for the current project context are injected.
198
- * From turn 2 onwards, this returns empty string (0 tokens).
199
- */
200
- declare function renderColdStartAnchorsContext(store: AnchorStore, cwdOrNow?: string | number, nowArg?: number, preflightFailures?: Map<string, string>): string;
201
- /** Legacy alias for backwards compatibility */
202
- declare const renderActiveAnchorsContext: typeof renderColdStartAnchorsContext;
203
-
204
- /**
205
- * Universal Agent Adapter Interface.
206
- * Any AI coding harness (Pi, Claude Code, Cursor, Aider, custom MCP server) implements this thin layer.
207
- */
208
- interface AgentAdapter {
209
- readonly name: string;
210
- getCwd(): string;
211
- notify?(message: string, level: 'info' | 'warn' | 'error'): void;
212
- }
213
- /**
214
- * Anchor protocol engine for cross-session task management.
215
- * Decoupled, harness-agnostic core managing state, decay, JIT annotations, and settlement.
216
- */
217
- declare class AnchorProtocol {
218
- readonly store: AnchorStore;
219
- readonly observer: SessionTouchObserver;
220
- private readonly annotatedThisSession;
221
- constructor(store: AnchorStore);
222
- /**
223
- * Run session initialization lifecycle: sweeps stale anchors and resets session state
224
- */
225
- handleSessionStart(now?: number): {
226
- sleepingCount: number;
227
- };
228
- /**
229
- * Handle turn lifecycle: injects cold-start prompt on turn 1, returns null (0 tokens) on turn 2+
230
- */
231
- handleBeforeTurn(turnCount: number, cwd: string, now?: number): string | null;
232
- /**
233
- * Handle tool execution result: detects touched paths, refreshes mutation touch timers,
234
- * and returns safe language-specific JIT annotation (or null if syntax incompatible/already annotated).
235
- */
236
- handleToolResult(input: {
237
- toolName: string;
238
- filePath?: string;
239
- isError?: boolean;
240
- isMutation?: boolean;
241
- cwd: string;
242
- }): {
243
- annotation: string | null;
244
- matchedAnchors: Anchor[];
245
- };
246
- }
247
-
248
- export { type AgentAdapter, Anchor, AnchorProtocol, type AnchorQuadrant, AnchorStatus, AnchorStore, COMMENT_FORMATS, type DecayEvaluation, type GroupedAnchors, SessionTouchObserver, SettlementProposal, type SweepResult, TouchMatchResult, classifyAnchor, evaluateAnchorDecay, findMatchedAnchors, formatCreationTime, formatOrigin, formatRelativeTime, formatRemainingTtl, formatSettlementCard, formatTargetDate, generateSettlementProposals, getDisplayWidth, globToRegExp, groupAnchorsByQuadrant, hasActiveUI, isSameOrSubPath, makeSafeTaskAnnotation, matchAnchorAgainstTouchedFiles, normalizePath, openAnchorDashboard, padToWidth, renderActiveAnchorsContext, renderColdStartAnchorsContext, runPhysicalVerification, stripAnsi, sweepStore, truncateToWidth, updateAnchorStatusBar, updateStartupBanner };
42
+ export { Anchor, AnchorStore, formatOrigin, formatRelativeAge, getDisplayWidth, hasActiveUI, openAnchorDashboard, padToWidth, sortAnchorsForDisplay, stripAnsi, truncateToWidth, updateAnchorStatusBar, updateStartupBanner };
package/dist/index.d.ts CHANGED
@@ -1,248 +1,42 @@
1
- import { a as AnchorStatus, b as Anchor, A as AnchorStore, T as TouchMatchResult, S as SettlementProposal } from './store-BNKjzhS_.js';
2
- export { c as AnchorDecayPolicy, d as AnchorDurability, e as AnchorEvidence, f as AnchorPriority, g as AnchorStoreState, D as DEFAULT_DECAY_POLICY, h as DURABLE_DECAY_POLICY, E as EPHEMERAL_DECAY_POLICY, i as acquireSyncLock, j as atomicRenameWithRetry, k as detectDurability, l as detectRecurrence, m as detectTargetDate, n as getDefaultStorageDir, o as getEphemeralDecayPolicy, p as getTodayDateString } from './store-BNKjzhS_.js';
1
+ import { A as Anchor, a as AnchorStore } from './extension-B1-fzCox.js';
2
+ export { b as AnchorEvidence, c as AnchorPriority, d as AnchorStatus, e as AnchorStoreState, C as COMMENT_FORMATS, M as MS_PER_DAY, Q as QUIET_AFTER_DAYS, T as TouchMatchResult, f as acquireSyncLock, g as atomicRenameWithRetry, h as extractPathsFromText, i as findMatchedAnchors, j as getDefaultStorageDir, k as globToRegExp, l as isAnchorTargetingWorkspace, m as isSameOrSubPath, n as makeSafeTaskAnnotation, o as matchAnchorAgainstTouchedFiles, p as matchesCommitMessage, q as normalizePath, r as parseAnchorCommandInput, s as renderActiveAnchorsContext, t as renderColdStartAnchorsContext, u as resolveAnchorTarget, v as sweepQuietNotes } from './extension-B1-fzCox.js';
3
3
  import { ExtensionContext } from '@earendil-works/pi-coding-agent';
4
4
 
5
- interface DecayEvaluation {
6
- currentStatus: AnchorStatus;
7
- nextStatus: AnchorStatus;
8
- daysUntouched: number;
9
- remainingActiveDays: number;
10
- remainingSleepDays: number;
11
- }
12
- /**
13
- * Calculate precise decay status based on elapsed time since last touch
14
- */
15
- declare function evaluateAnchorDecay(anchor: Anchor, now?: number): DecayEvaluation;
16
- interface SweepResult {
17
- transitionedToSleeping: string[];
18
- wokenToActive: string[];
19
- evictedToGraveyard: string[];
20
- }
21
- /**
22
- * Run decay sweep across store: transitions statuses and evicts expired anchors
23
- */
24
- declare function sweepStore(store: AnchorStore, now?: number): SweepResult;
25
-
26
- /**
27
- * Convert simple glob pattern (e.g. *.ts, src/**\/*.ts, src/auth/*.ts) to RegExp
28
- */
29
- declare function globToRegExp(pattern: string): RegExp;
30
- /**
31
- * Normalize path separators to POSIX forward slashes and optionally relative to baseCwd
32
- */
33
- declare function normalizePath(filePath: string, baseCwd?: string): string;
34
- /**
35
- * Compare two workspace CWDs safely (case-insensitive on Windows, supports subdirectory scoping)
36
- */
37
- declare function isSameOrSubPath(anchorCwd?: string, targetCwd?: string): boolean;
38
- /**
39
- * Match touched files against an anchor's registered physical patterns
40
- * Only anchors with explicit files/globs/prefixes are matched against file touches.
41
- * Anchors with files: [] (pure mental notes or macro tasks) NEVER trigger on file operations.
42
- */
43
- declare function matchAnchorAgainstTouchedFiles(anchor: Anchor, touchedFiles: string[]): TouchMatchResult | null;
44
- /**
45
- * Filter and sort anchors that match a set of touched files
46
- * Prioritizes high confidence (exact > prefix > keyword) and priority (P0 > P1 > P2).
47
- */
48
- declare function findMatchedAnchors(anchors: Anchor[], touchedFiles: string[]): TouchMatchResult[];
49
-
50
- /**
51
- * Execute physical verification test command for an anchor
52
- */
53
- declare function runPhysicalVerification(anchor: Anchor, cwd: string): {
54
- success: boolean;
55
- output: string;
56
- };
57
- /**
58
- * Generate settlement candidates based on files touched during the session
59
- */
60
- declare function generateSettlementProposals(store: AnchorStore, touchedFiles: string[], cwd?: string): SettlementProposal[];
61
- /**
62
- * Format settlement proposal into terminal-ready card
63
- */
64
- declare function formatSettlementCard(proposal: SettlementProposal): string;
65
-
66
- type AnchorQuadrant = 'Today' | 'Upcoming' | 'Habits' | 'Backlog';
67
- interface GroupedAnchors {
68
- today: Anchor[];
69
- upcoming: Anchor[];
70
- habits: Anchor[];
71
- backlog: Anchor[];
72
- }
73
- /**
74
- * Classify anchor into one of four cognitive quadrants:
75
- * - 'Today': Due today or overdue
76
- * - 'Upcoming': Due in the future (tomorrow, in 2d, specific dates)
77
- * - 'Habits': Daily recurring habits
78
- * - 'Backlog': Open-ended long-term vision
79
- */
80
- declare function classifyAnchor(anchor: Anchor, now?: number): AnchorQuadrant;
81
- /**
82
- * Group active anchors by cognitive quadrant
83
- */
84
- declare function groupAnchorsByQuadrant(anchors: Anchor[], now?: number): GroupedAnchors;
85
- /**
86
- * Strip ANSI escape codes from string
87
- */
88
5
  declare function stripAnsi(str: string): string;
89
6
  /**
90
- * Calculate display width in terminal columns, accounting for:
91
- * - ANSI escape codes (width 0)
92
- * - CJK ideographs & fullwidth forms (width 2)
93
- * - Japanese Kana (width 2)
94
- * - Korean Hangul syllables & Jamo (width 2)
95
- * - Emojis & Pictographs (width 2)
96
- * - Zero-width characters & joiners (width 0)
97
- * - Standard ASCII (width 1)
7
+ * Calculate visual terminal column width (CJK/Kana/Hangul/Emoji = 2 cells, ASCII = 1 cell)
98
8
  */
99
9
  declare function getDisplayWidth(str: string): number;
100
10
  declare function hasActiveUI(ctx: ExtensionContext | null | undefined): ctx is ExtensionContext;
101
- /**
102
- * Truncate string to target terminal visual width with ellipsis
103
- */
104
11
  declare function truncateToWidth(str: string, maxWidth: number, ellipsis?: string): string;
105
- /**
106
- * Pad and/or truncate string to exact visual column width, eliminating column tearing
107
- */
108
12
  declare function padToWidth(str: string, targetWidth: number): string;
109
13
  /**
110
- * Format expected completion date in human-intuitive terms:
111
- * - 'Daily' for daily recurring habits
112
- * - 'Today' if targetDate is today
113
- * - 'Tomorrow' if targetDate is tomorrow
114
- * - 'In 2d' / 'In 3d' for near-term dates
115
- * - 'MM-DD' for future dates
116
- * - 'Overdue' if targetDate is past
117
- * - 'Someday' for open-ended architecture/long-term vision
14
+ * Format relative sticky-note age cleanly: 'just now', '15m ago', '3h ago', '2d ago'
118
15
  */
119
- declare function formatTargetDate(anchor: Anchor, now?: number): string;
16
+ declare function formatRelativeAge(timestamp: number, now?: number): string;
120
17
  /**
121
- * Format creation timestamp as concise date/time:
122
- * - 'Today HH:MM' if created today
123
- * - 'Yesterday HH:MM' if created yesterday
124
- * - 'MM-DD HH:MM' if created this year
125
- * - 'YYYY-MM-DD' if older
18
+ * Format workspace & first file context concisely (e.g. 'anchor · src/auth.ts' or 'College/优化')
126
19
  */
127
- declare function formatCreationTime(timestamp: number, now?: number): string;
128
- /**
129
- * Backward compatibility alias
130
- */
131
- declare function formatRelativeTime(timestamp: number, now?: number): string;
132
- /**
133
- * Backward compatibility alias (now returns target date representation)
134
- */
135
- declare function formatRemainingTtl(anchor: Anchor, now?: number): string | undefined;
20
+ declare function formatOrigin(anchor: Anchor | string): string;
136
21
  /**
137
- * Format origin creation workspace folder (provenance: where the task was born/created)
22
+ * Sort sticky notes naturally:
23
+ * 1. Active notes before quiet (>7d untouched) notes
24
+ * 2. Notes belonging to current workspace first
25
+ * 3. Most recently touched first
138
26
  */
139
- declare function formatOrigin(anchor: Anchor | string): string;
27
+ declare function sortAnchorsForDisplay(anchors: Anchor[], cwd?: string): Anchor[];
140
28
  /**
141
- * Update footer status bar capsule: `⌖ 1`
29
+ * Update status bar badge: `⌖ 2` (invisible when 0 active notes)
142
30
  */
143
31
  declare function updateAnchorStatusBar(ctx: ExtensionContext, store: AnchorStore): void;
144
32
  /**
145
- * Render lightweight startup banner widget above the editor.
146
- * Features 3-4 lines with quadrant badges and target date hints.
147
- * Automatically cleared on agent_start (when user sends first message).
33
+ * Render clean sticky-note card above editor on session startup.
34
+ * Automatically disappears as soon as the user sends their first message.
148
35
  */
149
36
  declare function updateStartupBanner(ctx: ExtensionContext, store: AnchorStore): void;
150
37
  /**
151
- * Clean, columnar-aligned checklist with Target Date and Creation Time columns
38
+ * Interactive `/anchor` sticky-note board
152
39
  */
153
40
  declare function openAnchorDashboard(ctx: ExtensionContext, store: AnchorStore): Promise<void>;
154
41
 
155
- declare class SessionTouchObserver {
156
- private touchedFiles;
157
- private modifiedFiles;
158
- private inspectedFiles;
159
- private committed;
160
- private commitMessages;
161
- clear(): void;
162
- /**
163
- * Observe and record a tool call invocation, separating inspection from mutation
164
- */
165
- recordToolCall(toolName: string, input: Record<string, unknown>): void;
166
- /**
167
- * Add a file path manually (e.g. from git status diff)
168
- */
169
- addTouchedFile(filePath: string, isModified?: boolean): void;
170
- getModifiedFiles(): string[];
171
- getInspectedFiles(): string[];
172
- getTouchedFiles(): string[];
173
- hasCommitted(): boolean;
174
- getCommitMessages(): string[];
175
- /**
176
- * Check if any commit message explicitly references or resolves an anchor
177
- */
178
- matchesCommit(anchor: Anchor): {
179
- matched: boolean;
180
- message?: string;
181
- };
182
- }
183
-
184
- /**
185
- * Universal multi-language comment generator.
186
- * Maps file extension to safe comment syntax.
187
- * Formats that do not safely support comments (e.g. .json, .env, binary) return null.
188
- */
189
- declare const COMMENT_FORMATS: Record<string, (msg: string) => string>;
190
- /**
191
- * Format safe task context comment for a specific file.
192
- * Returns null for formats that do not safely support comments (e.g. .json, .env, .lock)
193
- */
194
- declare function makeSafeTaskAnnotation(filePath: string, anchor: Anchor): string | null;
195
- /**
196
- * Render ultra-compact cold-start context block for session turn 1.
197
- * Only active anchors for the current project context are injected.
198
- * From turn 2 onwards, this returns empty string (0 tokens).
199
- */
200
- declare function renderColdStartAnchorsContext(store: AnchorStore, cwdOrNow?: string | number, nowArg?: number, preflightFailures?: Map<string, string>): string;
201
- /** Legacy alias for backwards compatibility */
202
- declare const renderActiveAnchorsContext: typeof renderColdStartAnchorsContext;
203
-
204
- /**
205
- * Universal Agent Adapter Interface.
206
- * Any AI coding harness (Pi, Claude Code, Cursor, Aider, custom MCP server) implements this thin layer.
207
- */
208
- interface AgentAdapter {
209
- readonly name: string;
210
- getCwd(): string;
211
- notify?(message: string, level: 'info' | 'warn' | 'error'): void;
212
- }
213
- /**
214
- * Anchor protocol engine for cross-session task management.
215
- * Decoupled, harness-agnostic core managing state, decay, JIT annotations, and settlement.
216
- */
217
- declare class AnchorProtocol {
218
- readonly store: AnchorStore;
219
- readonly observer: SessionTouchObserver;
220
- private readonly annotatedThisSession;
221
- constructor(store: AnchorStore);
222
- /**
223
- * Run session initialization lifecycle: sweeps stale anchors and resets session state
224
- */
225
- handleSessionStart(now?: number): {
226
- sleepingCount: number;
227
- };
228
- /**
229
- * Handle turn lifecycle: injects cold-start prompt on turn 1, returns null (0 tokens) on turn 2+
230
- */
231
- handleBeforeTurn(turnCount: number, cwd: string, now?: number): string | null;
232
- /**
233
- * Handle tool execution result: detects touched paths, refreshes mutation touch timers,
234
- * and returns safe language-specific JIT annotation (or null if syntax incompatible/already annotated).
235
- */
236
- handleToolResult(input: {
237
- toolName: string;
238
- filePath?: string;
239
- isError?: boolean;
240
- isMutation?: boolean;
241
- cwd: string;
242
- }): {
243
- annotation: string | null;
244
- matchedAnchors: Anchor[];
245
- };
246
- }
247
-
248
- export { type AgentAdapter, Anchor, AnchorProtocol, type AnchorQuadrant, AnchorStatus, AnchorStore, COMMENT_FORMATS, type DecayEvaluation, type GroupedAnchors, SessionTouchObserver, SettlementProposal, type SweepResult, TouchMatchResult, classifyAnchor, evaluateAnchorDecay, findMatchedAnchors, formatCreationTime, formatOrigin, formatRelativeTime, formatRemainingTtl, formatSettlementCard, formatTargetDate, generateSettlementProposals, getDisplayWidth, globToRegExp, groupAnchorsByQuadrant, hasActiveUI, isSameOrSubPath, makeSafeTaskAnnotation, matchAnchorAgainstTouchedFiles, normalizePath, openAnchorDashboard, padToWidth, renderActiveAnchorsContext, renderColdStartAnchorsContext, runPhysicalVerification, stripAnsi, sweepStore, truncateToWidth, updateAnchorStatusBar, updateStartupBanner };
42
+ export { Anchor, AnchorStore, formatOrigin, formatRelativeAge, getDisplayWidth, hasActiveUI, openAnchorDashboard, padToWidth, sortAnchorsForDisplay, stripAnsi, truncateToWidth, updateAnchorStatusBar, updateStartupBanner };