pi-anchor 0.3.0 → 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/README.md +33 -170
- package/README_zh.md +32 -176
- package/assets/hero-en.svg +23 -39
- package/assets/hero-zh.svg +23 -39
- package/bin/anchor.js +36 -69
- package/dist/chunk-LKY6WIKH.js +1100 -0
- package/dist/extension-B1-fzCox.d.cts +167 -0
- package/dist/extension-B1-fzCox.d.ts +167 -0
- package/dist/extension.cjs +369 -1315
- package/dist/extension.d.cts +2 -20
- package/dist/extension.d.ts +2 -20
- package/dist/extension.js +4 -536
- package/dist/index.cjs +317 -1143
- package/dist/index.d.cts +17 -250
- package/dist/index.d.ts +17 -250
- package/dist/index.js +15 -103
- package/package.json +2 -2
- package/src/extension.ts +124 -362
- package/src/index.ts +1 -6
- package/src/store.ts +294 -424
- package/src/tui.ts +102 -297
- package/src/types.ts +24 -65
- package/dist/chunk-Q7IILJFA.js +0 -1563
- package/dist/store-t2_TDhJn.d.cts +0 -210
- package/dist/store-t2_TDhJn.d.ts +0 -210
- package/src/context_injector.ts +0 -166
- package/src/decay.ts +0 -125
- package/src/matcher.ts +0 -202
- package/src/observer.ts +0 -141
- package/src/protocol.ts +0 -95
- package/src/settlement.ts +0 -140
package/dist/index.js
CHANGED
|
@@ -1,156 +1,68 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AnchorStore,
|
|
3
3
|
COMMENT_FORMATS,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
EPHEMERAL_DECAY_POLICY,
|
|
7
|
-
SessionTouchObserver,
|
|
4
|
+
MS_PER_DAY,
|
|
5
|
+
QUIET_AFTER_DAYS,
|
|
8
6
|
acquireSyncLock,
|
|
9
7
|
atomicRenameWithRetry,
|
|
10
|
-
classifyAnchor,
|
|
11
|
-
detectDurability,
|
|
12
|
-
detectRecurrence,
|
|
13
|
-
detectTargetDate,
|
|
14
|
-
evaluateAnchorDecay,
|
|
15
8
|
extractPathsFromText,
|
|
16
9
|
findMatchedAnchors,
|
|
17
|
-
formatCreationTime,
|
|
18
10
|
formatOrigin,
|
|
19
|
-
|
|
20
|
-
formatRemainingTtl,
|
|
21
|
-
formatSettlementCard,
|
|
22
|
-
formatTargetDate,
|
|
23
|
-
generateSettlementProposals,
|
|
11
|
+
formatRelativeAge,
|
|
24
12
|
getDefaultStorageDir,
|
|
25
13
|
getDisplayWidth,
|
|
26
|
-
getEphemeralDecayPolicy,
|
|
27
|
-
getTodayDateString,
|
|
28
14
|
globToRegExp,
|
|
29
|
-
groupAnchorsByQuadrant,
|
|
30
15
|
hasActiveUI,
|
|
31
16
|
isAnchorTargetingWorkspace,
|
|
32
17
|
isSameOrSubPath,
|
|
33
18
|
makeSafeTaskAnnotation,
|
|
34
19
|
matchAnchorAgainstTouchedFiles,
|
|
20
|
+
matchesCommitMessage,
|
|
35
21
|
normalizePath,
|
|
36
22
|
openAnchorDashboard,
|
|
37
23
|
padToWidth,
|
|
24
|
+
parseAnchorCommandInput,
|
|
38
25
|
renderActiveAnchorsContext,
|
|
39
26
|
renderColdStartAnchorsContext,
|
|
40
|
-
|
|
27
|
+
resolveAnchorTarget,
|
|
41
28
|
sortAnchorsForDisplay,
|
|
42
29
|
stripAnsi,
|
|
43
|
-
|
|
30
|
+
sweepQuietNotes,
|
|
44
31
|
truncateToWidth,
|
|
45
|
-
tryRealtimeAutoSettle,
|
|
46
32
|
updateAnchorStatusBar,
|
|
47
33
|
updateStartupBanner
|
|
48
|
-
} from "./chunk-
|
|
49
|
-
|
|
50
|
-
// src/protocol.ts
|
|
51
|
-
var AnchorProtocol = class {
|
|
52
|
-
store;
|
|
53
|
-
observer;
|
|
54
|
-
annotatedThisSession = /* @__PURE__ */ new Set();
|
|
55
|
-
constructor(store) {
|
|
56
|
-
this.store = store;
|
|
57
|
-
this.observer = new SessionTouchObserver();
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Run session initialization lifecycle: sweeps stale anchors and resets session state
|
|
61
|
-
*/
|
|
62
|
-
handleSessionStart(now = Date.now()) {
|
|
63
|
-
this.observer.clear();
|
|
64
|
-
this.annotatedThisSession.clear();
|
|
65
|
-
const sweep = sweepStore(this.store, now);
|
|
66
|
-
return { sleepingCount: sweep.transitionedToSleeping.length };
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Handle turn lifecycle: injects cold-start prompt on turn 1, returns null (0 tokens) on turn 2+
|
|
70
|
-
*/
|
|
71
|
-
handleBeforeTurn(turnCount, cwd, now = Date.now()) {
|
|
72
|
-
if (turnCount <= 1) {
|
|
73
|
-
return renderColdStartAnchorsContext(this.store, cwd, now) || null;
|
|
74
|
-
}
|
|
75
|
-
return null;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Handle tool execution result: detects touched paths, refreshes mutation touch timers,
|
|
79
|
-
* and returns safe language-specific JIT annotation (or null if syntax incompatible/already annotated).
|
|
80
|
-
*/
|
|
81
|
-
handleToolResult(input) {
|
|
82
|
-
if (!input.isError) {
|
|
83
|
-
this.observer.recordToolCall(input.toolName, input.filePath ? { path: input.filePath } : {});
|
|
84
|
-
}
|
|
85
|
-
if (!input.filePath) {
|
|
86
|
-
return { annotation: null, matchedAnchors: [] };
|
|
87
|
-
}
|
|
88
|
-
const touchedPath = normalizePath(input.filePath);
|
|
89
|
-
const anchors = this.store.list({ cwd: input.cwd }).filter((a2) => a2.status === "active" || a2.status === "sleeping");
|
|
90
|
-
const matches = findMatchedAnchors(anchors, [touchedPath]);
|
|
91
|
-
if (matches.length === 0) {
|
|
92
|
-
return { annotation: null, matchedAnchors: [] };
|
|
93
|
-
}
|
|
94
|
-
if (input.isMutation && !input.isError) {
|
|
95
|
-
for (const m of matches) {
|
|
96
|
-
this.store.touch(m.anchor.id);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
const a = matches[0].anchor;
|
|
100
|
-
if (!this.annotatedThisSession.has(a.id)) {
|
|
101
|
-
this.annotatedThisSession.add(a.id);
|
|
102
|
-
const annotation = makeSafeTaskAnnotation(touchedPath, a);
|
|
103
|
-
return { annotation, matchedAnchors: matches.map((m) => m.anchor) };
|
|
104
|
-
}
|
|
105
|
-
return { annotation: null, matchedAnchors: matches.map((m) => m.anchor) };
|
|
106
|
-
}
|
|
107
|
-
};
|
|
34
|
+
} from "./chunk-LKY6WIKH.js";
|
|
108
35
|
export {
|
|
109
|
-
AnchorProtocol,
|
|
110
36
|
AnchorStore,
|
|
111
37
|
COMMENT_FORMATS,
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
EPHEMERAL_DECAY_POLICY,
|
|
115
|
-
SessionTouchObserver,
|
|
38
|
+
MS_PER_DAY,
|
|
39
|
+
QUIET_AFTER_DAYS,
|
|
116
40
|
acquireSyncLock,
|
|
117
41
|
atomicRenameWithRetry,
|
|
118
|
-
classifyAnchor,
|
|
119
|
-
detectDurability,
|
|
120
|
-
detectRecurrence,
|
|
121
|
-
detectTargetDate,
|
|
122
|
-
evaluateAnchorDecay,
|
|
123
42
|
extractPathsFromText,
|
|
124
43
|
findMatchedAnchors,
|
|
125
|
-
formatCreationTime,
|
|
126
44
|
formatOrigin,
|
|
127
|
-
|
|
128
|
-
formatRemainingTtl,
|
|
129
|
-
formatSettlementCard,
|
|
130
|
-
formatTargetDate,
|
|
131
|
-
generateSettlementProposals,
|
|
45
|
+
formatRelativeAge,
|
|
132
46
|
getDefaultStorageDir,
|
|
133
47
|
getDisplayWidth,
|
|
134
|
-
getEphemeralDecayPolicy,
|
|
135
|
-
getTodayDateString,
|
|
136
48
|
globToRegExp,
|
|
137
|
-
groupAnchorsByQuadrant,
|
|
138
49
|
hasActiveUI,
|
|
139
50
|
isAnchorTargetingWorkspace,
|
|
140
51
|
isSameOrSubPath,
|
|
141
52
|
makeSafeTaskAnnotation,
|
|
142
53
|
matchAnchorAgainstTouchedFiles,
|
|
54
|
+
matchesCommitMessage,
|
|
143
55
|
normalizePath,
|
|
144
56
|
openAnchorDashboard,
|
|
145
57
|
padToWidth,
|
|
58
|
+
parseAnchorCommandInput,
|
|
146
59
|
renderActiveAnchorsContext,
|
|
147
60
|
renderColdStartAnchorsContext,
|
|
148
|
-
|
|
61
|
+
resolveAnchorTarget,
|
|
149
62
|
sortAnchorsForDisplay,
|
|
150
63
|
stripAnsi,
|
|
151
|
-
|
|
64
|
+
sweepQuietNotes,
|
|
152
65
|
truncateToWidth,
|
|
153
|
-
tryRealtimeAutoSettle,
|
|
154
66
|
updateAnchorStatusBar,
|
|
155
67
|
updateStartupBanner
|
|
156
68
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-anchor",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "A digital sticky note for Pi — stick a quick note across sessions (/pin), get a 1-line whisper when touching matching files, and auto-tear off on git commit with 0 TODO.md clutter.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|