pi-context 1.1.4 → 2.0.0-beta.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 +24 -14
- package/package.json +15 -9
- package/skills/context-management/SKILL.md +242 -226
- package/skills/context-management/references/development-and-troubleshooting.md +75 -0
- package/skills/context-management/references/planning-and-execution.md +79 -0
- package/skills/context-management/references/repeated-items-and-batch-work.md +68 -0
- package/skills/context-management/references/retry-branch-and-pivot.md +71 -0
- package/skills/context-management/references/search-research-and-reading.md +82 -0
- package/skills/context-management/references/task-switching-and-cleanup.md +63 -0
- package/src/context.ts +5 -4
- package/src/index.ts +70 -69
- package/dist/index.js +0 -370
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Development and Troubleshooting
|
|
2
|
+
|
|
3
|
+
Use this reference for long-running:
|
|
4
|
+
- implementation
|
|
5
|
+
- debugging
|
|
6
|
+
- troubleshooting
|
|
7
|
+
- refactoring
|
|
8
|
+
- migration
|
|
9
|
+
- review or audit work
|
|
10
|
+
|
|
11
|
+
These tasks often stay cleaner when treated as stages with anchors, instead of one uninterrupted thread. If multiple alternative approaches, failed branches, or route comparisons become central, also read `retry-branch-and-pivot.md`.
|
|
12
|
+
|
|
13
|
+
## Working pattern
|
|
14
|
+
|
|
15
|
+
1. Create a checkpoint before starting serious work.
|
|
16
|
+
2. Add checkpoints before risky edits, new approaches, or major phase changes.
|
|
17
|
+
3. Review the timeline when you need to understand the current shape of the work.
|
|
18
|
+
4. Rewind after a stable implementation milestone, a failed approach, or a completed troubleshooting phase.
|
|
19
|
+
|
|
20
|
+
## Typical checkpoint moments
|
|
21
|
+
|
|
22
|
+
Checkpoint:
|
|
23
|
+
- before starting implementation
|
|
24
|
+
- before a risky refactor
|
|
25
|
+
- before trying an alternative fix
|
|
26
|
+
- after a milestone like "root cause confirmed" or "first pass implemented"
|
|
27
|
+
- before switching to a side task
|
|
28
|
+
|
|
29
|
+
Example checkpoint names:
|
|
30
|
+
- `parser-fix-start`
|
|
31
|
+
- `cache-refactor-attempt-2`
|
|
32
|
+
- `migration-plan-ready`
|
|
33
|
+
- `incident-root-cause-confirmed`
|
|
34
|
+
|
|
35
|
+
## Timeline review moments
|
|
36
|
+
|
|
37
|
+
Run `context_timeline` when:
|
|
38
|
+
- multiple attempts now exist
|
|
39
|
+
- the task moved from diagnosis to implementation
|
|
40
|
+
- you are about to abandon one approach and restart from another anchor
|
|
41
|
+
- you are unsure which checkpoint best represents the clean continuation point
|
|
42
|
+
|
|
43
|
+
## Rewind patterns
|
|
44
|
+
|
|
45
|
+
### After a failed attempt
|
|
46
|
+
|
|
47
|
+
Use rewind when an attempt clearly failed and you have a crisp summary of why.
|
|
48
|
+
|
|
49
|
+
```javascript
|
|
50
|
+
context_rewind({
|
|
51
|
+
target: "memory-leak-fix-start",
|
|
52
|
+
message: "WeakRef approach failed because objects were collected too early and cache hit rate collapsed. Reason: abandoning this attempt and returning to a clean anchor. Next step: try object pooling instead.",
|
|
53
|
+
backupCheckpoint: "memory-leak-weakref-raw-history"
|
|
54
|
+
});
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### After a completed phase
|
|
58
|
+
|
|
59
|
+
Use rewind when a phase is done and you want to continue from a cleaner thread.
|
|
60
|
+
|
|
61
|
+
```javascript
|
|
62
|
+
context_rewind({
|
|
63
|
+
target: "parser-fix-start",
|
|
64
|
+
message: "Parser fix is implemented and the debugging phase is complete. Reason: compacting implementation history before focused validation. Next step: run targeted validation and summarize remaining edge cases.",
|
|
65
|
+
backupCheckpoint: "parser-fix-debug-history"
|
|
66
|
+
});
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Warning signs
|
|
70
|
+
|
|
71
|
+
Switch into stronger context-management behavior when:
|
|
72
|
+
- you are accumulating many partial theories
|
|
73
|
+
- the thread contains multiple fix attempts
|
|
74
|
+
- you keep revisiting earlier reasoning
|
|
75
|
+
- the next step is clear but the path behind it is getting noisy
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Planning and Execution
|
|
2
|
+
|
|
3
|
+
Use this reference when the work is organized around an explicit execution frame, such as:
|
|
4
|
+
- a formal implementation or migration plan
|
|
5
|
+
- a roadmap with multiple milestones
|
|
6
|
+
- a lightweight todo list or checklist
|
|
7
|
+
- staged execution that will be revisited, updated, or reordered across many turns
|
|
8
|
+
|
|
9
|
+
The defining feature here is not just that the work has phases. It is that execution repeatedly returns to an explicit plan, roadmap, or todo baseline.
|
|
10
|
+
|
|
11
|
+
## Two common variants
|
|
12
|
+
|
|
13
|
+
### Formal plan
|
|
14
|
+
Examples:
|
|
15
|
+
- a plan produced by a planning step or planning agent
|
|
16
|
+
- a migration plan with several services or phases
|
|
17
|
+
- a rollout plan with checkpoints and validation steps
|
|
18
|
+
|
|
19
|
+
### Lightweight todo / checklist
|
|
20
|
+
Examples:
|
|
21
|
+
- a short task list for a refactor
|
|
22
|
+
- a checklist for a release or audit
|
|
23
|
+
- a small execution outline that will be worked through item by item
|
|
24
|
+
|
|
25
|
+
Both variants use the same context-management rhythm.
|
|
26
|
+
|
|
27
|
+
## Working pattern
|
|
28
|
+
|
|
29
|
+
1. Create or confirm the plan / todo list.
|
|
30
|
+
2. Create a checkpoint for the clean plan-ready state.
|
|
31
|
+
3. Execute one subtask or phase.
|
|
32
|
+
4. If that subtask becomes noisy, let it get noisy locally.
|
|
33
|
+
5. Once the subtask produces a stable takeaway, rewind back to the plan-ready or phase-start anchor.
|
|
34
|
+
6. Continue with the next subtask from the clean anchor.
|
|
35
|
+
7. If the plan changes materially, checkpoint the updated plan state again.
|
|
36
|
+
|
|
37
|
+
## Useful anchors
|
|
38
|
+
|
|
39
|
+
Example checkpoint names:
|
|
40
|
+
- `auth-migration-plan-ready`
|
|
41
|
+
- `release-rollout-plan-ready`
|
|
42
|
+
- `parser-refactor-todo-baseline`
|
|
43
|
+
- `cleanup-phase-2-start`
|
|
44
|
+
- `vendor-audit-milestone-1`
|
|
45
|
+
|
|
46
|
+
## When to review timeline
|
|
47
|
+
|
|
48
|
+
Run `context_timeline` when:
|
|
49
|
+
- several subtasks have already been executed
|
|
50
|
+
- the plan has changed more than once
|
|
51
|
+
- multiple branches now exist under the same plan
|
|
52
|
+
- you are unsure whether to rewind to the overall plan anchor or the current phase-start anchor
|
|
53
|
+
|
|
54
|
+
## When to rewind
|
|
55
|
+
|
|
56
|
+
Rewind when:
|
|
57
|
+
- a subtask is complete and its raw execution path is no longer worth keeping active
|
|
58
|
+
- a phase finished and the next phase should start from a cleaner state
|
|
59
|
+
- the plan remains valid but the current execution segment has become noisy
|
|
60
|
+
|
|
61
|
+
Do not rewind just because a todo list exists. Rewind when a specific execution segment has already served its purpose and can be compacted.
|
|
62
|
+
|
|
63
|
+
## Replan
|
|
64
|
+
|
|
65
|
+
If the plan itself changes materially:
|
|
66
|
+
1. finish or abandon the current noisy segment
|
|
67
|
+
2. summarize the change in direction
|
|
68
|
+
3. checkpoint the new plan-ready state
|
|
69
|
+
4. continue from the updated plan anchor
|
|
70
|
+
|
|
71
|
+
If the plan change is driven by failed branches or strategy shifts, also read `retry-branch-and-pivot.md`.
|
|
72
|
+
|
|
73
|
+
## Common mistakes
|
|
74
|
+
|
|
75
|
+
Avoid:
|
|
76
|
+
- keeping every finished subtask's raw reasoning active
|
|
77
|
+
- rewinding too far back when the current plan-ready anchor is still valid
|
|
78
|
+
- failing to checkpoint the updated plan after a major replan
|
|
79
|
+
- confusing repeated-item work with plan-driven work when the subtasks are actually different in nature
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Repeated Items and Batch Work
|
|
2
|
+
|
|
3
|
+
Use this reference when the work involves many similar items handled over many turns, such as:
|
|
4
|
+
- repeated cases
|
|
5
|
+
- repeated tickets
|
|
6
|
+
- repeated reviews
|
|
7
|
+
- repeated checks
|
|
8
|
+
- repeated fix attempts on similar inputs
|
|
9
|
+
|
|
10
|
+
Use this reference when the items are similar enough that the same method should be reused across them. If the subtasks are heterogeneous and anchored to a roadmap or todo baseline, use `planning-and-execution.md` instead.
|
|
11
|
+
|
|
12
|
+
## Working pattern
|
|
13
|
+
|
|
14
|
+
1. Create a checkpoint at the start of the overall repeated-item task.
|
|
15
|
+
2. If item 1 teaches you a reusable approach, checkpoint again after that approach becomes clear.
|
|
16
|
+
3. Work item by item.
|
|
17
|
+
4. Rewind after each completed item or completed mini-phase when the raw path is no longer worth carrying forward.
|
|
18
|
+
5. Use timeline occasionally to verify that the history still has a clean structure.
|
|
19
|
+
|
|
20
|
+
For repeated-item work, the default completion move is not "keep carrying the last item's raw reasoning". Once an item is done and its takeaway is stable, rewind back to the repeated-work anchor.
|
|
21
|
+
|
|
22
|
+
## Useful anchors
|
|
23
|
+
|
|
24
|
+
Example checkpoint names:
|
|
25
|
+
- `vendor-review-start`
|
|
26
|
+
- `vendor-review-method-clear`
|
|
27
|
+
- `ticket-triage-batch-start`
|
|
28
|
+
- `ticket-triage-pattern-1-confirmed`
|
|
29
|
+
|
|
30
|
+
## When to review timeline
|
|
31
|
+
|
|
32
|
+
Run `context_timeline` when:
|
|
33
|
+
- several items have already been processed
|
|
34
|
+
- item-level work has created multiple branches or rewinds
|
|
35
|
+
- you want to confirm that the overall pattern still looks clean
|
|
36
|
+
- you are about to choose which anchor repeated work should keep returning to
|
|
37
|
+
|
|
38
|
+
## When to rewind
|
|
39
|
+
|
|
40
|
+
Rewind after:
|
|
41
|
+
- a representative item produced a reusable method
|
|
42
|
+
- a single item is complete and the raw path should be compacted
|
|
43
|
+
- an item-specific dead end is understood and should not remain active in full
|
|
44
|
+
|
|
45
|
+
## Example rhythm
|
|
46
|
+
|
|
47
|
+
```javascript
|
|
48
|
+
context_checkpoint({ name: "vendor-review-start" });
|
|
49
|
+
|
|
50
|
+
// ... work through first representative item ...
|
|
51
|
+
|
|
52
|
+
context_checkpoint({ name: "vendor-review-method-clear" });
|
|
53
|
+
|
|
54
|
+
// ... process another item ...
|
|
55
|
+
|
|
56
|
+
context_rewind({
|
|
57
|
+
target: "vendor-review-method-clear",
|
|
58
|
+
message: "One more vendor review completed. Reason: compacting finished item work and returning to the clean repeated-item anchor. Next step: process the next vendor using the same method.",
|
|
59
|
+
backupCheckpoint: "vendor-review-item-7-history"
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Warning signs
|
|
64
|
+
|
|
65
|
+
Use stronger checkpoint/timeline/rewind discipline when:
|
|
66
|
+
- each item creates lots of local reasoning
|
|
67
|
+
- you are starting to confuse one item's path with another's
|
|
68
|
+
- the repeated work is stretching across many turns
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Retry, Branch, and Pivot
|
|
2
|
+
|
|
3
|
+
Use this reference when multiple approaches are being tried and abandoned cleanly, such as:
|
|
4
|
+
- trying A / B / C approaches
|
|
5
|
+
- failed branches that should not pollute the main line
|
|
6
|
+
- compare-and-choose work
|
|
7
|
+
- strategy pivots or goal shifts
|
|
8
|
+
- restarting from a cleaner anchor after a dead end
|
|
9
|
+
|
|
10
|
+
This is a **cross-cutting pattern reference**. Read it alongside a primary reference such as search/research, development/troubleshooting, or planning/execution when branch behavior becomes central.
|
|
11
|
+
|
|
12
|
+
## Working pattern
|
|
13
|
+
|
|
14
|
+
1. Checkpoint before opening a risky branch or alternative path.
|
|
15
|
+
2. Explore or implement that branch.
|
|
16
|
+
3. If anchor choice becomes unclear, inspect timeline.
|
|
17
|
+
4. Once the branch produces a stable lesson, decision, or dead-end, rewind back to the best clean pre-branch anchor.
|
|
18
|
+
5. Continue with the next branch or the chosen direction from that clean state.
|
|
19
|
+
|
|
20
|
+
## When to review timeline
|
|
21
|
+
|
|
22
|
+
Run `context_timeline` when:
|
|
23
|
+
- multiple branches now exist
|
|
24
|
+
- you are unsure which branch actually stayed useful
|
|
25
|
+
- you need to choose the cleanest pre-branch anchor
|
|
26
|
+
- the next direction is clear but the old branch still clutters active context
|
|
27
|
+
|
|
28
|
+
## When to rewind
|
|
29
|
+
|
|
30
|
+
Rewind when:
|
|
31
|
+
- a branch clearly failed
|
|
32
|
+
- a comparison is complete and one option won
|
|
33
|
+
- the direction changed enough that the old path is now baggage
|
|
34
|
+
- the next attempt should start from a cleaner base
|
|
35
|
+
|
|
36
|
+
## Strategy pivot
|
|
37
|
+
|
|
38
|
+
Use this pattern when the old direction no longer makes sense even though the task is still continuing.
|
|
39
|
+
|
|
40
|
+
Examples:
|
|
41
|
+
- the original approach is no longer viable
|
|
42
|
+
- the user's priority changed
|
|
43
|
+
- the scope narrowed or widened enough that old execution noise is now baggage
|
|
44
|
+
|
|
45
|
+
In these cases:
|
|
46
|
+
- summarize what still matters
|
|
47
|
+
- rewind back to the best clean anchor before the stale branch
|
|
48
|
+
- continue under the new direction
|
|
49
|
+
|
|
50
|
+
## Example rhythm
|
|
51
|
+
|
|
52
|
+
```javascript
|
|
53
|
+
context_checkpoint({ name: "oauth-fix-start" });
|
|
54
|
+
|
|
55
|
+
// ... try cookie-based approach ...
|
|
56
|
+
|
|
57
|
+
context_rewind({
|
|
58
|
+
target: "oauth-fix-start",
|
|
59
|
+
message: "Cookie-based approach is not viable because the callback flow loses session continuity. Reason: retrying from a clean anchor after a failed branch. Important decision: switch to signed state tokens. Next step: implement the signed-state approach.",
|
|
60
|
+
backupCheckpoint: "oauth-cookie-approach-history"
|
|
61
|
+
});
|
|
62
|
+
context_checkpoint({ name: "oauth-signed-state-start" });
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Common mistakes
|
|
66
|
+
|
|
67
|
+
Avoid:
|
|
68
|
+
- opening alternative branches without a clean checkpoint first
|
|
69
|
+
- dragging failed branches forward after their lesson is already clear
|
|
70
|
+
- rewinding to a point that still includes the branch you meant to abandon
|
|
71
|
+
- treating every branch as equally worth preserving
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Search, Research, and Reading
|
|
2
|
+
|
|
3
|
+
Use this reference when the work is mainly driven by large amounts of input material, such as:
|
|
4
|
+
- searching
|
|
5
|
+
- research
|
|
6
|
+
- web search
|
|
7
|
+
- browser-driven information gathering
|
|
8
|
+
- reading many files, logs, docs, webpages, or web results
|
|
9
|
+
- review-heavy reading
|
|
10
|
+
- comparison-heavy reading
|
|
11
|
+
- audit or inspection across many sources
|
|
12
|
+
|
|
13
|
+
This reference is for **input-heavy work where the process is much larger than the final conclusion**. It is especially relevant for web search and browser/page reading, where the information density is often low and the raw trail becomes stale quickly. If the main anchor is an explicit plan or todo list, use `planning-and-execution.md` instead.
|
|
14
|
+
|
|
15
|
+
## Working pattern
|
|
16
|
+
|
|
17
|
+
1. Create a checkpoint before a large search or reading loop.
|
|
18
|
+
2. Search, browse, read, inspect, and follow leads normally.
|
|
19
|
+
3. If you lose orientation, review the timeline.
|
|
20
|
+
4. Once the investigation yields a stable finding, rewind to a cleaner anchor.
|
|
21
|
+
5. Continue with the conclusion, recommendation, or next action instead of carrying the entire raw exploration forward.
|
|
22
|
+
|
|
23
|
+
Do not stop at "I already made a checkpoint" if the investigation phase is actually complete. The cleanup move for completed research is usually a rewind back to the best earlier anchor.
|
|
24
|
+
|
|
25
|
+
## When to checkpoint
|
|
26
|
+
|
|
27
|
+
Checkpoint:
|
|
28
|
+
- before the first big search pass
|
|
29
|
+
- before opening a browser-heavy or webpage-heavy reading pass
|
|
30
|
+
- before diving into a new evidence branch
|
|
31
|
+
- after a stable intermediate conclusion
|
|
32
|
+
- before changing investigation direction
|
|
33
|
+
|
|
34
|
+
Example checkpoint names:
|
|
35
|
+
- `incident-search-start`
|
|
36
|
+
- `vendor-review-evidence-branch`
|
|
37
|
+
- `api-timeout-investigation-midpoint`
|
|
38
|
+
|
|
39
|
+
## When to review timeline
|
|
40
|
+
|
|
41
|
+
Run `context_timeline` when:
|
|
42
|
+
- you have followed several leads
|
|
43
|
+
- you are no longer sure what the main anchor is
|
|
44
|
+
- the investigation has already produced multiple checkpoints
|
|
45
|
+
- you are deciding which path should be compacted
|
|
46
|
+
|
|
47
|
+
## When to rewind
|
|
48
|
+
|
|
49
|
+
Rewind after the investigation produces one of these:
|
|
50
|
+
- a stable root cause
|
|
51
|
+
- a stable comparison result
|
|
52
|
+
- a dead-end conclusion
|
|
53
|
+
- a shortlist of viable next actions
|
|
54
|
+
|
|
55
|
+
If you already have one of these, the investigation phase is usually complete enough to compact.
|
|
56
|
+
|
|
57
|
+
Do not rewind in the middle of a still-open search loop just because the thread feels busy.
|
|
58
|
+
|
|
59
|
+
## Typical rhythm
|
|
60
|
+
|
|
61
|
+
```javascript
|
|
62
|
+
context_checkpoint({ name: "timeout-investigation-start" });
|
|
63
|
+
|
|
64
|
+
// ... search logs, read code, compare docs, inspect outputs ...
|
|
65
|
+
|
|
66
|
+
context_timeline();
|
|
67
|
+
|
|
68
|
+
context_rewind({
|
|
69
|
+
target: "timeout-investigation-start",
|
|
70
|
+
message: "Found DB connection pool exhaustion as the likely root cause. Reason: investigation phase is complete and ready to compact. Next step: report findings and propose mitigation."
|
|
71
|
+
});
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Good rewind outcomes
|
|
75
|
+
|
|
76
|
+
After rewinding, you should be able to continue with:
|
|
77
|
+
- the finding
|
|
78
|
+
- the recommendation
|
|
79
|
+
- the next verification step
|
|
80
|
+
- the next narrower investigation
|
|
81
|
+
|
|
82
|
+
You should not still need the whole raw trail in active context unless the investigation is still ongoing.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Task Switching and Cleanup
|
|
2
|
+
|
|
3
|
+
Use this reference when the main problem is not the task domain itself, but a change in thread state, such as:
|
|
4
|
+
- the user inserts a temporary side task
|
|
5
|
+
- you need to pause one line of work and resume it later
|
|
6
|
+
- several active fronts now exist
|
|
7
|
+
- the thread is already messy and needs cleanup before continuing
|
|
8
|
+
- a finished noisy phase should be summarized and left behind
|
|
9
|
+
|
|
10
|
+
This reference is for **pause/resume, cleanup, and clean continuation**. It is not for repeated similar items or plan-driven execution.
|
|
11
|
+
|
|
12
|
+
## Two common variants
|
|
13
|
+
|
|
14
|
+
### Interruption / task switch
|
|
15
|
+
Use when you are actively switching away from one line of work and intend to come back.
|
|
16
|
+
|
|
17
|
+
### Cleanup and continue
|
|
18
|
+
Use when the thread is already stale or messy and you want to compress it now, even though context management is being adopted late.
|
|
19
|
+
|
|
20
|
+
## Working pattern
|
|
21
|
+
|
|
22
|
+
1. Inspect timeline if anchor choice is unclear.
|
|
23
|
+
2. Before switching away or compacting a noisy path, preserve the best clean anchor.
|
|
24
|
+
3. If needed, create a backup checkpoint for the current noisy branch.
|
|
25
|
+
4. Handle the side task or cleanup move.
|
|
26
|
+
5. Rewind away the stale path when the baton pass is clear.
|
|
27
|
+
6. Resume from the paused anchor or continue from the compacted state.
|
|
28
|
+
|
|
29
|
+
## Useful anchors
|
|
30
|
+
|
|
31
|
+
Example checkpoint names:
|
|
32
|
+
- `primary-task-paused`
|
|
33
|
+
- `migration-mainline-paused`
|
|
34
|
+
- `release-investigation-paused`
|
|
35
|
+
- `cleanup-pre-noise-anchor`
|
|
36
|
+
|
|
37
|
+
## When to review timeline
|
|
38
|
+
|
|
39
|
+
Run `context_timeline` when:
|
|
40
|
+
- multiple interruptions happened
|
|
41
|
+
- the pause lasted many turns
|
|
42
|
+
- several side-task branches now exist
|
|
43
|
+
- you are unsure which clean anchor should be resumed
|
|
44
|
+
- the thread is already messy and you need to find the right pre-noise checkpoint
|
|
45
|
+
|
|
46
|
+
## When to rewind
|
|
47
|
+
|
|
48
|
+
Rewind when:
|
|
49
|
+
- the interruption created lots of noise
|
|
50
|
+
- the side task is done and should not stay active in full
|
|
51
|
+
- a stale path is making current reasoning worse
|
|
52
|
+
- the useful state is now much smaller than the accumulated process
|
|
53
|
+
- you can express the baton pass clearly in a summary
|
|
54
|
+
|
|
55
|
+
If the interruption was tiny and clean, a rewind may be unnecessary. A checkpoint before switching away is still the key move.
|
|
56
|
+
|
|
57
|
+
## Common mistakes
|
|
58
|
+
|
|
59
|
+
Avoid:
|
|
60
|
+
- switching away without a pause checkpoint
|
|
61
|
+
- returning to the main line while still carrying the side task's full raw path
|
|
62
|
+
- trying to clean up without first checking timeline when anchor choice is unclear
|
|
63
|
+
- over-resetting and losing still-valid near-term context
|
package/src/context.ts
CHANGED
|
@@ -2,8 +2,8 @@ import {
|
|
|
2
2
|
type ExtensionAPI,
|
|
3
3
|
type SessionManager,
|
|
4
4
|
DynamicBorder,
|
|
5
|
-
} from "@
|
|
6
|
-
import { Container, Text, Spacer } from "@
|
|
5
|
+
} from "@earendil-works/pi-coding-agent";
|
|
6
|
+
import { Container, Text, Spacer } from "@earendil-works/pi-tui";
|
|
7
7
|
import { formatTokens } from "./utils.js";
|
|
8
8
|
|
|
9
9
|
export default function (pi: ExtensionAPI) {
|
|
@@ -61,8 +61,9 @@ export default function (pi: ExtensionAPI) {
|
|
|
61
61
|
const toolDefTokensRaw = estimateTokens(JSON.stringify(activeToolDefs));
|
|
62
62
|
const totalActual = usage.tokens;
|
|
63
63
|
const limit = usage.contextWindow;
|
|
64
|
+
const usagePercent = usage.percent;
|
|
64
65
|
|
|
65
|
-
if (totalActual == null || limit == null ||
|
|
66
|
+
if (totalActual == null || limit == null || usagePercent == null) {
|
|
66
67
|
ctx.ui.notify("Context usage info not available.", "warning");
|
|
67
68
|
return;
|
|
68
69
|
}
|
|
@@ -123,7 +124,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
123
124
|
gridLines.push(rowStr.trimEnd());
|
|
124
125
|
}
|
|
125
126
|
|
|
126
|
-
const totalUsageTitle = `${theme.fg("text", theme.bold("Total Usage".padEnd(16)))} ${theme.fg("text", theme.bold(formatTokens(totalActual).padStart(7)))} ${theme.fg("text", theme.bold(`(${
|
|
127
|
+
const totalUsageTitle = `${theme.fg("text", theme.bold("Total Usage".padEnd(16)))} ${theme.fg("text", theme.bold(formatTokens(totalActual).padStart(7)))} ${theme.fg("text", theme.bold(`(${usagePercent.toFixed(1).padStart(5)}%)`))}`;
|
|
127
128
|
|
|
128
129
|
const catDetailLines = categories.map(cat => {
|
|
129
130
|
const labelStr = cat.label.padEnd(14);
|