pi-anchor 0.4.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.
@@ -6,6 +6,14 @@ import { ExtensionAPI } from '@earendil-works/pi-coding-agent';
6
6
  */
7
7
  type AnchorStatus = 'active' | 'sleeping' | 'settled';
8
8
  type AnchorPriority = 'p0' | 'p1' | 'p2';
9
+ interface AnchorProgress {
10
+ /** Completed steps or units */
11
+ done: number;
12
+ /** Total steps or units */
13
+ total: number;
14
+ /** Optional parsed step labels (e.g. ['抽出接口', '替换Cookie', '补单测']) */
15
+ steps?: string[];
16
+ }
9
17
  interface AnchorEvidence {
10
18
  settledAt?: number;
11
19
  settledBy?: 'commit' | 'manual' | 'one-tap-settlement' | 'manual-command' | 'verification-test';
@@ -32,10 +40,14 @@ interface Anchor {
32
40
  updatedAt: number;
33
41
  /** Last activity timestamp (ms) */
34
42
  lastTouchedAt: number;
35
- /** Associated file paths or globs (explicit or auto-extracted from note text) */
43
+ /** Associated file paths or globs (explicit, auto-extracted from note text, or inherited from active session) */
36
44
  files: string[];
37
45
  /** Optional tags */
38
46
  tags: string[];
47
+ /** Associated Pi conversation session file (.jsonl) for 1-click session jump/resume */
48
+ sessionFile?: string;
49
+ /** Optional lightweight progress tracker for long-term or multi-step notes */
50
+ progress?: AnchorProgress;
39
51
  /** Optional due date ('YYYY-MM-DD') */
40
52
  targetDate?: string;
41
53
  /** Optional priority kept for backward compatibility */
@@ -76,6 +88,15 @@ declare function globToRegExp(pattern: string): RegExp;
76
88
  * (e.g. "src/auth.ts", "D:/College/优化/notes.md") so the user never has to fill out forms.
77
89
  */
78
90
  declare function extractPathsFromText(text?: string): string[];
91
+ /**
92
+ * Automatically extract lightweight progress metadata from note text if present:
93
+ * - Explicit ratio: `[2/5]`, `(3/10)`, or standalone `5/30` (where 0 <= done <= total and 2 <= total <= 500)
94
+ * - Numbered inline steps: `1. 抽出接口 2. 替换Cookie 3. 补单测`
95
+ */
96
+ declare function extractProgressFromText(rawTitle: string): {
97
+ cleanTitle: string;
98
+ progress?: AnchorProgress;
99
+ };
79
100
  /**
80
101
  * Check if a sticky note belongs to or targets the given workspace directory
81
102
  */
@@ -136,6 +157,8 @@ declare class AnchorStore {
136
157
  project?: string;
137
158
  files?: string[];
138
159
  tags?: string[];
160
+ sessionFile?: string;
161
+ progress?: AnchorProgress;
139
162
  }): Anchor;
140
163
  private findAnchorIndex;
141
164
  get(id: string): Anchor | undefined;
@@ -145,7 +168,16 @@ declare class AnchorStore {
145
168
  all?: boolean;
146
169
  }): Anchor[];
147
170
  update(id: string, patch: Partial<Omit<Anchor, 'id' | 'createdAt'>>): Anchor;
148
- touch(id: string, timestamp?: number): Anchor;
171
+ touch(id: string, timestamp?: number, sessionFile?: string): Anchor;
172
+ /**
173
+ * Advance (or set) progress on a sticky note:
174
+ * - If delta is provided (default +1), increments `done` up to `total`.
175
+ * - If note had no progress yet, initializes a 4-step bar (`1/4`).
176
+ */
177
+ step(id: string, delta?: number, explicitTotal?: number): {
178
+ anchor: Anchor;
179
+ completed: boolean;
180
+ };
149
181
  /**
150
182
  * Tear off (settle) a completed sticky note and archive it to archive.jsonl
151
183
  */
@@ -157,11 +189,17 @@ declare class AnchorStore {
157
189
  }
158
190
 
159
191
  declare function parseAnchorCommandInput(raw: string): {
160
- mode: 'dashboard' | 'undo' | 'settle' | 'pin';
192
+ mode: 'dashboard' | 'undo' | 'settle' | 'step' | 'jump' | 'pin';
161
193
  targetId?: string;
194
+ delta?: number;
162
195
  title?: string;
163
196
  };
197
+ /**
198
+ * Detect 0ms human-first quick note prefix in the input box:
199
+ * e.g. `pin: 明天把Token改Cookie` or `便签: 检查网关重试 [1/4]`
200
+ */
201
+ declare function parseQuickNoteInput(text: string): string | null;
164
202
  declare function resolveAnchorTarget(store: AnchorStore, idOrIndex: string, cwd?: string): string | undefined;
165
203
  declare function export_default(pi: ExtensionAPI): void;
166
204
 
167
- export { type Anchor as A, COMMENT_FORMATS as C, MS_PER_DAY as M, QUIET_AFTER_DAYS as Q, type TouchMatchResult as T, AnchorStore as a, type AnchorEvidence as b, type AnchorPriority as c, type AnchorStatus as d, type AnchorStoreState as e, acquireSyncLock as f, atomicRenameWithRetry as g, extractPathsFromText as h, findMatchedAnchors as i, getDefaultStorageDir as j, globToRegExp as k, isAnchorTargetingWorkspace as l, isSameOrSubPath as m, makeSafeTaskAnnotation as n, matchAnchorAgainstTouchedFiles as o, matchesCommitMessage as p, normalizePath as q, parseAnchorCommandInput as r, renderActiveAnchorsContext as s, renderColdStartAnchorsContext as t, resolveAnchorTarget as u, sweepQuietNotes as v, export_default as w };
205
+ export { type Anchor as A, COMMENT_FORMATS as C, MS_PER_DAY as M, QUIET_AFTER_DAYS as Q, type TouchMatchResult as T, type AnchorProgress as a, AnchorStore as b, type AnchorEvidence as c, type AnchorPriority as d, type AnchorStatus as e, type AnchorStoreState as f, acquireSyncLock as g, atomicRenameWithRetry as h, extractPathsFromText as i, extractProgressFromText as j, findMatchedAnchors as k, getDefaultStorageDir as l, globToRegExp as m, isAnchorTargetingWorkspace as n, isSameOrSubPath as o, makeSafeTaskAnnotation as p, matchAnchorAgainstTouchedFiles as q, matchesCommitMessage as r, normalizePath as s, parseAnchorCommandInput as t, parseQuickNoteInput as u, renderActiveAnchorsContext as v, renderColdStartAnchorsContext as w, resolveAnchorTarget as x, sweepQuietNotes as y, export_default as z };
@@ -6,6 +6,14 @@ import { ExtensionAPI } from '@earendil-works/pi-coding-agent';
6
6
  */
7
7
  type AnchorStatus = 'active' | 'sleeping' | 'settled';
8
8
  type AnchorPriority = 'p0' | 'p1' | 'p2';
9
+ interface AnchorProgress {
10
+ /** Completed steps or units */
11
+ done: number;
12
+ /** Total steps or units */
13
+ total: number;
14
+ /** Optional parsed step labels (e.g. ['抽出接口', '替换Cookie', '补单测']) */
15
+ steps?: string[];
16
+ }
9
17
  interface AnchorEvidence {
10
18
  settledAt?: number;
11
19
  settledBy?: 'commit' | 'manual' | 'one-tap-settlement' | 'manual-command' | 'verification-test';
@@ -32,10 +40,14 @@ interface Anchor {
32
40
  updatedAt: number;
33
41
  /** Last activity timestamp (ms) */
34
42
  lastTouchedAt: number;
35
- /** Associated file paths or globs (explicit or auto-extracted from note text) */
43
+ /** Associated file paths or globs (explicit, auto-extracted from note text, or inherited from active session) */
36
44
  files: string[];
37
45
  /** Optional tags */
38
46
  tags: string[];
47
+ /** Associated Pi conversation session file (.jsonl) for 1-click session jump/resume */
48
+ sessionFile?: string;
49
+ /** Optional lightweight progress tracker for long-term or multi-step notes */
50
+ progress?: AnchorProgress;
39
51
  /** Optional due date ('YYYY-MM-DD') */
40
52
  targetDate?: string;
41
53
  /** Optional priority kept for backward compatibility */
@@ -76,6 +88,15 @@ declare function globToRegExp(pattern: string): RegExp;
76
88
  * (e.g. "src/auth.ts", "D:/College/优化/notes.md") so the user never has to fill out forms.
77
89
  */
78
90
  declare function extractPathsFromText(text?: string): string[];
91
+ /**
92
+ * Automatically extract lightweight progress metadata from note text if present:
93
+ * - Explicit ratio: `[2/5]`, `(3/10)`, or standalone `5/30` (where 0 <= done <= total and 2 <= total <= 500)
94
+ * - Numbered inline steps: `1. 抽出接口 2. 替换Cookie 3. 补单测`
95
+ */
96
+ declare function extractProgressFromText(rawTitle: string): {
97
+ cleanTitle: string;
98
+ progress?: AnchorProgress;
99
+ };
79
100
  /**
80
101
  * Check if a sticky note belongs to or targets the given workspace directory
81
102
  */
@@ -136,6 +157,8 @@ declare class AnchorStore {
136
157
  project?: string;
137
158
  files?: string[];
138
159
  tags?: string[];
160
+ sessionFile?: string;
161
+ progress?: AnchorProgress;
139
162
  }): Anchor;
140
163
  private findAnchorIndex;
141
164
  get(id: string): Anchor | undefined;
@@ -145,7 +168,16 @@ declare class AnchorStore {
145
168
  all?: boolean;
146
169
  }): Anchor[];
147
170
  update(id: string, patch: Partial<Omit<Anchor, 'id' | 'createdAt'>>): Anchor;
148
- touch(id: string, timestamp?: number): Anchor;
171
+ touch(id: string, timestamp?: number, sessionFile?: string): Anchor;
172
+ /**
173
+ * Advance (or set) progress on a sticky note:
174
+ * - If delta is provided (default +1), increments `done` up to `total`.
175
+ * - If note had no progress yet, initializes a 4-step bar (`1/4`).
176
+ */
177
+ step(id: string, delta?: number, explicitTotal?: number): {
178
+ anchor: Anchor;
179
+ completed: boolean;
180
+ };
149
181
  /**
150
182
  * Tear off (settle) a completed sticky note and archive it to archive.jsonl
151
183
  */
@@ -157,11 +189,17 @@ declare class AnchorStore {
157
189
  }
158
190
 
159
191
  declare function parseAnchorCommandInput(raw: string): {
160
- mode: 'dashboard' | 'undo' | 'settle' | 'pin';
192
+ mode: 'dashboard' | 'undo' | 'settle' | 'step' | 'jump' | 'pin';
161
193
  targetId?: string;
194
+ delta?: number;
162
195
  title?: string;
163
196
  };
197
+ /**
198
+ * Detect 0ms human-first quick note prefix in the input box:
199
+ * e.g. `pin: 明天把Token改Cookie` or `便签: 检查网关重试 [1/4]`
200
+ */
201
+ declare function parseQuickNoteInput(text: string): string | null;
164
202
  declare function resolveAnchorTarget(store: AnchorStore, idOrIndex: string, cwd?: string): string | undefined;
165
203
  declare function export_default(pi: ExtensionAPI): void;
166
204
 
167
- export { type Anchor as A, COMMENT_FORMATS as C, MS_PER_DAY as M, QUIET_AFTER_DAYS as Q, type TouchMatchResult as T, AnchorStore as a, type AnchorEvidence as b, type AnchorPriority as c, type AnchorStatus as d, type AnchorStoreState as e, acquireSyncLock as f, atomicRenameWithRetry as g, extractPathsFromText as h, findMatchedAnchors as i, getDefaultStorageDir as j, globToRegExp as k, isAnchorTargetingWorkspace as l, isSameOrSubPath as m, makeSafeTaskAnnotation as n, matchAnchorAgainstTouchedFiles as o, matchesCommitMessage as p, normalizePath as q, parseAnchorCommandInput as r, renderActiveAnchorsContext as s, renderColdStartAnchorsContext as t, resolveAnchorTarget as u, sweepQuietNotes as v, export_default as w };
205
+ export { type Anchor as A, COMMENT_FORMATS as C, MS_PER_DAY as M, QUIET_AFTER_DAYS as Q, type TouchMatchResult as T, type AnchorProgress as a, AnchorStore as b, type AnchorEvidence as c, type AnchorPriority as d, type AnchorStatus as e, type AnchorStoreState as f, acquireSyncLock as g, atomicRenameWithRetry as h, extractPathsFromText as i, extractProgressFromText as j, findMatchedAnchors as k, getDefaultStorageDir as l, globToRegExp as m, isAnchorTargetingWorkspace as n, isSameOrSubPath as o, makeSafeTaskAnnotation as p, matchAnchorAgainstTouchedFiles as q, matchesCommitMessage as r, normalizePath as s, parseAnchorCommandInput as t, parseQuickNoteInput as u, renderActiveAnchorsContext as v, renderColdStartAnchorsContext as w, resolveAnchorTarget as x, sweepQuietNotes as y, export_default as z };