pi-anchor 0.3.0 → 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.
- package/README.md +38 -174
- package/README_zh.md +36 -184
- package/assets/hero-en.svg +48 -47
- package/assets/hero-zh.svg +48 -47
- package/bin/anchor.js +68 -70
- package/dist/chunk-VXEQDTK4.js +1310 -0
- package/dist/extension-Cq1NH1jT.d.cts +205 -0
- package/dist/extension-Cq1NH1jT.d.ts +205 -0
- package/dist/extension.cjs +617 -1354
- package/dist/extension.d.cts +2 -20
- package/dist/extension.d.ts +2 -20
- package/dist/extension.js +6 -536
- package/dist/index.cjs +452 -1152
- package/dist/index.d.cts +22 -250
- package/dist/index.d.ts +22 -250
- package/dist/index.js +21 -103
- package/package.json +2 -2
- package/src/extension.ts +265 -376
- package/src/index.ts +1 -6
- package/src/pi-types.d.ts +5 -1
- package/src/store.ts +385 -427
- package/src/tui.ts +166 -307
- package/src/types.ts +35 -63
- 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,74 @@
|
|
|
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,
|
|
9
|
+
extractProgressFromText,
|
|
16
10
|
findMatchedAnchors,
|
|
17
|
-
formatCreationTime,
|
|
18
11
|
formatOrigin,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
formatSettlementCard,
|
|
22
|
-
formatTargetDate,
|
|
23
|
-
generateSettlementProposals,
|
|
12
|
+
formatProgressBar,
|
|
13
|
+
formatRelativeAge,
|
|
24
14
|
getDefaultStorageDir,
|
|
25
15
|
getDisplayWidth,
|
|
26
|
-
getEphemeralDecayPolicy,
|
|
27
|
-
getTodayDateString,
|
|
28
16
|
globToRegExp,
|
|
29
|
-
groupAnchorsByQuadrant,
|
|
30
17
|
hasActiveUI,
|
|
31
18
|
isAnchorTargetingWorkspace,
|
|
32
19
|
isSameOrSubPath,
|
|
33
20
|
makeSafeTaskAnnotation,
|
|
34
21
|
matchAnchorAgainstTouchedFiles,
|
|
22
|
+
matchesCommitMessage,
|
|
35
23
|
normalizePath,
|
|
36
24
|
openAnchorDashboard,
|
|
37
25
|
padToWidth,
|
|
26
|
+
parseAnchorCommandInput,
|
|
27
|
+
parseQuickNoteInput,
|
|
38
28
|
renderActiveAnchorsContext,
|
|
39
29
|
renderColdStartAnchorsContext,
|
|
40
|
-
|
|
30
|
+
resolveAnchorTarget,
|
|
41
31
|
sortAnchorsForDisplay,
|
|
42
32
|
stripAnsi,
|
|
43
|
-
|
|
33
|
+
sweepQuietNotes,
|
|
44
34
|
truncateToWidth,
|
|
45
|
-
tryRealtimeAutoSettle,
|
|
46
35
|
updateAnchorStatusBar,
|
|
47
36
|
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
|
-
};
|
|
37
|
+
} from "./chunk-VXEQDTK4.js";
|
|
108
38
|
export {
|
|
109
|
-
AnchorProtocol,
|
|
110
39
|
AnchorStore,
|
|
111
40
|
COMMENT_FORMATS,
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
EPHEMERAL_DECAY_POLICY,
|
|
115
|
-
SessionTouchObserver,
|
|
41
|
+
MS_PER_DAY,
|
|
42
|
+
QUIET_AFTER_DAYS,
|
|
116
43
|
acquireSyncLock,
|
|
117
44
|
atomicRenameWithRetry,
|
|
118
|
-
classifyAnchor,
|
|
119
|
-
detectDurability,
|
|
120
|
-
detectRecurrence,
|
|
121
|
-
detectTargetDate,
|
|
122
|
-
evaluateAnchorDecay,
|
|
123
45
|
extractPathsFromText,
|
|
46
|
+
extractProgressFromText,
|
|
124
47
|
findMatchedAnchors,
|
|
125
|
-
formatCreationTime,
|
|
126
48
|
formatOrigin,
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
formatSettlementCard,
|
|
130
|
-
formatTargetDate,
|
|
131
|
-
generateSettlementProposals,
|
|
49
|
+
formatProgressBar,
|
|
50
|
+
formatRelativeAge,
|
|
132
51
|
getDefaultStorageDir,
|
|
133
52
|
getDisplayWidth,
|
|
134
|
-
getEphemeralDecayPolicy,
|
|
135
|
-
getTodayDateString,
|
|
136
53
|
globToRegExp,
|
|
137
|
-
groupAnchorsByQuadrant,
|
|
138
54
|
hasActiveUI,
|
|
139
55
|
isAnchorTargetingWorkspace,
|
|
140
56
|
isSameOrSubPath,
|
|
141
57
|
makeSafeTaskAnnotation,
|
|
142
58
|
matchAnchorAgainstTouchedFiles,
|
|
59
|
+
matchesCommitMessage,
|
|
143
60
|
normalizePath,
|
|
144
61
|
openAnchorDashboard,
|
|
145
62
|
padToWidth,
|
|
63
|
+
parseAnchorCommandInput,
|
|
64
|
+
parseQuickNoteInput,
|
|
146
65
|
renderActiveAnchorsContext,
|
|
147
66
|
renderColdStartAnchorsContext,
|
|
148
|
-
|
|
67
|
+
resolveAnchorTarget,
|
|
149
68
|
sortAnchorsForDisplay,
|
|
150
69
|
stripAnsi,
|
|
151
|
-
|
|
70
|
+
sweepQuietNotes,
|
|
152
71
|
truncateToWidth,
|
|
153
|
-
tryRealtimeAutoSettle,
|
|
154
72
|
updateAnchorStatusBar,
|
|
155
73
|
updateStartupBanner
|
|
156
74
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-anchor",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"description": "A digital sticky note docked below your Pi editor — stick notes in 0ms (pin: ...), track long tasks with micro progress bars [■■□□], jump back to the original session (↪), and auto-tear off on git commit.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|