@hcflabs/pi-session-recall 0.0.0-stage → 5.2.8
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/LICENSE +22 -0
- package/README.md +146 -2
- package/docs/session-search-routing.html +138 -0
- package/docs/session-search-routing.svg +121 -0
- package/extensions/hydrate.ts +258 -0
- package/extensions/query.ts +379 -0
- package/extensions/repository-inventory.ts +499 -0
- package/extensions/search-core.ts +724 -0
- package/extensions/session-recall.ts +556 -0
- package/extensions/transcript.ts +112 -0
- package/extensions/types.ts +53 -0
- package/package.json +60 -4
- package/skills/pi-session-pattern-miner/SKILL.md +97 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared shapes between the index engine (search-core) and hydration (hydrate).
|
|
3
|
+
* Keep this file types-only.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/** A hydrated message returned by windows/read. */
|
|
7
|
+
export interface WindowMessage {
|
|
8
|
+
entryId: string;
|
|
9
|
+
role: string;
|
|
10
|
+
content: string;
|
|
11
|
+
timestamp: string;
|
|
12
|
+
/** True when this message is the anchor of a scroll window. */
|
|
13
|
+
anchor?: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Metadata row for BROWSE mode (served from the index tables, not JSONL). */
|
|
17
|
+
export interface SessionRow {
|
|
18
|
+
path: string;
|
|
19
|
+
cwd: string;
|
|
20
|
+
name?: string;
|
|
21
|
+
startedAt?: string;
|
|
22
|
+
preview?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Indexed metadata selected for pattern-miner preparation. */
|
|
26
|
+
export interface PreparationSessionRow extends SessionRow {
|
|
27
|
+
/** Stable one-hop fork identity used to avoid duplicate evidence. */
|
|
28
|
+
lineageId: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** One metadata-only FTS discovery hit. */
|
|
32
|
+
export interface SearchHit {
|
|
33
|
+
path: string;
|
|
34
|
+
snippet: string;
|
|
35
|
+
/** BM25 rank position (0 = best). */
|
|
36
|
+
rank: number;
|
|
37
|
+
matchMessageId: string;
|
|
38
|
+
role: string;
|
|
39
|
+
timestamp: string;
|
|
40
|
+
/** Session metadata joined from the sessions table. */
|
|
41
|
+
cwd?: string;
|
|
42
|
+
name?: string;
|
|
43
|
+
startedAt?: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface SyncResult {
|
|
47
|
+
filesProcessed: number;
|
|
48
|
+
/** Changed files still unindexed after this pass, including failures. */
|
|
49
|
+
backlogRemaining: number;
|
|
50
|
+
/** False when the filesystem walk could not fully enumerate the tree —
|
|
51
|
+
* indexed-but-unseen paths were NOT purged and results may be stale. */
|
|
52
|
+
walkComplete: boolean;
|
|
53
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,62 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hcflabs/pi-session-recall",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "5.2.8",
|
|
4
|
+
"description": "Local FTS5 search over past Pi sessions plus a skill for turning recurring work into deterministic automation.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"pi-package",
|
|
7
|
+
"pi",
|
|
8
|
+
"session-recall",
|
|
9
|
+
"fts5",
|
|
10
|
+
"recall"
|
|
11
|
+
],
|
|
12
|
+
"type": "module",
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=22.19.0"
|
|
15
|
+
},
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"files": [
|
|
18
|
+
"LICENSE",
|
|
19
|
+
"extensions",
|
|
20
|
+
"skills",
|
|
21
|
+
"docs",
|
|
22
|
+
"README.md"
|
|
23
|
+
],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"test": "node --test test/*.test.ts",
|
|
26
|
+
"typecheck": "tsc --noEmit --allowImportingTsExtensions --target ES2022 --module NodeNext --moduleResolution NodeNext --skipLibCheck extensions/*.ts test/*.test.ts",
|
|
27
|
+
"pack:check": "npm pack --dry-run"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"@earendil-works/pi-ai": "^1.3.0",
|
|
31
|
+
"@earendil-works/pi-coding-agent": "^1.3.0",
|
|
32
|
+
"@earendil-works/pi-tui": "^1.3.0",
|
|
33
|
+
"typebox": "^1.3.15"
|
|
34
|
+
},
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "git+https://github.com/hcflabs/pi-harness.git",
|
|
38
|
+
"directory": "extensions/pi-session-recall"
|
|
39
|
+
},
|
|
40
|
+
"bugs": {
|
|
41
|
+
"url": "https://github.com/hcflabs/pi-harness/issues"
|
|
42
|
+
},
|
|
43
|
+
"publishConfig": {
|
|
44
|
+
"access": "public"
|
|
45
|
+
},
|
|
46
|
+
"pi": {
|
|
47
|
+
"extensions": [
|
|
48
|
+
"./extensions/session-recall.ts"
|
|
49
|
+
],
|
|
50
|
+
"skills": [
|
|
51
|
+
"./skills"
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"@hcflabs/pi-config-store": "^4.0.0"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@earendil-works/pi-ai": "1.3.0",
|
|
59
|
+
"@earendil-works/pi-coding-agent": "1.3.0",
|
|
60
|
+
"@earendil-works/pi-tui": "1.3.0"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pi-session-pattern-miner
|
|
3
|
+
description: Mine repeated work, corrections, and manual procedures from past Pi sessions with session_search, then identify the smallest deterministic script or reusable skill that would prevent repeating them. Use when the user asks what to automate, which workflows recur, or what skill or script should be extracted from prior Pi sessions.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Pi Session Pattern Miner
|
|
7
|
+
|
|
8
|
+
Find repeated work in past Pi sessions. Turn the best-supported pattern into the smallest useful automation.
|
|
9
|
+
|
|
10
|
+
Use `session_search` for session history. Do not scan Pi session files directly.
|
|
11
|
+
|
|
12
|
+
## Prepare once
|
|
13
|
+
|
|
14
|
+
Choose the requested scope. Use `repository` for the current Git repository. Use `all` for a cross-repository request or work outside Git.
|
|
15
|
+
|
|
16
|
+
Before interpretation, call `session_search` exactly once with:
|
|
17
|
+
|
|
18
|
+
```json
|
|
19
|
+
{
|
|
20
|
+
"operation": "prepare-pattern-miner",
|
|
21
|
+
"scope": "repository",
|
|
22
|
+
"limit": 10
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Change only `scope` when needed. Do not run manual browse, read, scroll, or inventory rounds during preparation.
|
|
27
|
+
|
|
28
|
+
State the returned scope and sample count. If `sync.complete` is false, report the incomplete walk or positive backlog as a sample limitation.
|
|
29
|
+
|
|
30
|
+
The prepared corpus is recent and bounded. A truncated session can omit middle episodes. Never claim exhaustive coverage.
|
|
31
|
+
|
|
32
|
+
## Mine
|
|
33
|
+
|
|
34
|
+
The model performs these steps. Do not replace them with mechanical keyword rules.
|
|
35
|
+
|
|
36
|
+
1. Identify semantic episodes, including repeated intents, corrections, retries, manual procedures, and recurring agent-authored steps.
|
|
37
|
+
2. Ignore generic inspect, edit, and test work unless the same concrete procedure repeats.
|
|
38
|
+
3. Cluster episodes by their underlying job, not their wording.
|
|
39
|
+
4. Treat sessions with equal `lineageId` values as one source.
|
|
40
|
+
5. Choose the owning automation surface from the prepared inventory and targeted repository evidence.
|
|
41
|
+
6. Write the recommendation and implementation contract.
|
|
42
|
+
|
|
43
|
+
A user-supplied topic is already a candidate. Run a focused confirmation search even when that topic is absent from the prepared sample.
|
|
44
|
+
|
|
45
|
+
For other work, create a candidate from the prepared corpus before running optional searches. Do not search speculatively when no topic or candidate exists.
|
|
46
|
+
|
|
47
|
+
Confirm a candidate with one or more distinctive `query` calls. Use `limit: 10`. Record the session path, date or name, relevant entry ID, and a short paraphrase.
|
|
48
|
+
|
|
49
|
+
Do not copy secrets or unnecessary transcript text. Do not count forks, retries, or continuations of one task as independent evidence.
|
|
50
|
+
|
|
51
|
+
## Verify ownership
|
|
52
|
+
|
|
53
|
+
After clustering, use the inventory only to find likely owners. It is not ownership proof and does not verify the current worktree.
|
|
54
|
+
|
|
55
|
+
Always inspect the current candidate-relevant package manifests, executable scripts, skill files, and instruction files before assigning ownership. Do this even when the inventory is available and complete.
|
|
56
|
+
|
|
57
|
+
Reuse or repair existing automation when it already owns the workflow. If targeted current-file verification cannot be performed safely, abstain.
|
|
58
|
+
|
|
59
|
+
## Evidence gate
|
|
60
|
+
|
|
61
|
+
A recommendation requires two independent examples. This gate is mandatory.
|
|
62
|
+
|
|
63
|
+
Stop with “not enough repeated evidence” when fewer than two independent sessions support a pattern. Do not manufacture a recommendation from one occurrence.
|
|
64
|
+
|
|
65
|
+
## Choose the owning surface
|
|
66
|
+
|
|
67
|
+
Stop at the first option that fully handles the pattern:
|
|
68
|
+
|
|
69
|
+
1. **Existing command or skill** — document, fix, or invoke it instead of adding another path.
|
|
70
|
+
2. **Script** — use when inputs, decisions, outputs, and failures need no model judgment.
|
|
71
|
+
3. **Script plus thin skill** — use when an agent gathers inputs, but a script performs the repeated operation.
|
|
72
|
+
4. **Skill only** — use only when the reusable work inherently requires judgment, repository inspection, or user decisions.
|
|
73
|
+
5. **Product change** — use when the root cause belongs in an extension, API, CI check, or other code.
|
|
74
|
+
|
|
75
|
+
Prefer a repository command or standard-library script. Add no dependency without evidence that existing tools cannot handle the job.
|
|
76
|
+
|
|
77
|
+
A deterministic candidate must define its trigger, inputs, outputs, side effects, failure behavior, and one runnable check. Recommend investigation when evidence cannot define these details.
|
|
78
|
+
|
|
79
|
+
## Report
|
|
80
|
+
|
|
81
|
+
Return at most three ranked patterns:
|
|
82
|
+
|
|
83
|
+
| Pattern | Independent sessions | Repeated cost or failure | Existing coverage | Smallest automation |
|
|
84
|
+
| --- | ---: | --- | --- | --- |
|
|
85
|
+
|
|
86
|
+
For each pattern, cite session paths and entry IDs. Explain why the owning surface fits and what model work it removes.
|
|
87
|
+
|
|
88
|
+
Give the highest-confidence candidate a minimal implementation contract:
|
|
89
|
+
|
|
90
|
+
- **Trigger and inputs**
|
|
91
|
+
- **Deterministic steps**
|
|
92
|
+
- **Output and side effects**
|
|
93
|
+
- **Failure behavior**
|
|
94
|
+
- **Runnable check**
|
|
95
|
+
- **Files to add or change**
|
|
96
|
+
|
|
97
|
+
Do not grade the agent, generate a report site, or modify files unless the user asks to implement a candidate.
|