pi-smart-compact 7.7.0 → 7.9.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/CHANGELOG.md +32 -0
- package/README.md +407 -402
- package/dist/constants.d.ts +45 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/core.d.ts +27 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +264 -112
- package/dist/phases/explore.d.ts +35 -0
- package/dist/phases/explore.d.ts.map +1 -0
- package/dist/phases/synthesize.d.ts +23 -0
- package/dist/phases/synthesize.d.ts.map +1 -0
- package/dist/phases/verify.d.ts +16 -0
- package/dist/phases/verify.d.ts.map +1 -0
- package/dist/types.d.ts +265 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/ui/overlays.d.ts +29 -0
- package/dist/ui/overlays.d.ts.map +1 -0
- package/dist/utils/cache.d.ts +27 -0
- package/dist/utils/cache.d.ts.map +1 -0
- package/dist/utils/damage.d.ts +28 -0
- package/dist/utils/damage.d.ts.map +1 -0
- package/dist/utils/extraction.d.ts +27 -0
- package/dist/utils/extraction.d.ts.map +1 -0
- package/dist/utils/fingerprint.d.ts +32 -0
- package/dist/utils/fingerprint.d.ts.map +1 -0
- package/dist/utils/helpers.d.ts +22 -0
- package/dist/utils/helpers.d.ts.map +1 -0
- package/dist/utils/logger.d.ts +8 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/pruning.d.ts +19 -0
- package/dist/utils/pruning.d.ts.map +1 -0
- package/dist/utils/state.d.ts +62 -0
- package/dist/utils/state.d.ts.map +1 -0
- package/dist/utils/tokens.d.ts +8 -0
- package/dist/utils/tokens.d.ts.map +1 -0
- package/dist/utils/type-guards.d.ts +26 -0
- package/dist/utils/type-guards.d.ts.map +1 -0
- package/docs/assets/pi-smart-compact.png +0 -0
- package/package.json +10 -2
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build structured machine-readable compaction state.
|
|
3
|
+
* Produced alongside the human-readable Markdown summary.
|
|
4
|
+
* Supports cross-compaction tracking and delta computation.
|
|
5
|
+
*/
|
|
6
|
+
import type { StructuredExtraction, OpenLoop, CompactionState, ExplorationReport } from "../types.ts";
|
|
7
|
+
/**
|
|
8
|
+
* Persist compaction state for cross-compaction tracking.
|
|
9
|
+
*/
|
|
10
|
+
export declare function saveCompactionState(projectId: string, state: CompactionState): void;
|
|
11
|
+
/**
|
|
12
|
+
* Load previous compaction state for delta computation.
|
|
13
|
+
*/
|
|
14
|
+
export declare function loadCompactionState(projectId: string): CompactionState | null;
|
|
15
|
+
export declare function buildCompactionState(extraction: StructuredExtraction, openLoops: OpenLoop[], report: ExplorationReport | null, nextActions: string[], criticalContext: string[]): CompactionState;
|
|
16
|
+
/**
|
|
17
|
+
* Inject Open Loops section into the Markdown summary.
|
|
18
|
+
*/
|
|
19
|
+
export declare function injectOpenLoopsSection(summary: string, openLoops: OpenLoop[]): string;
|
|
20
|
+
/**
|
|
21
|
+
* Compute delta between previous and current compaction state.
|
|
22
|
+
*/
|
|
23
|
+
export interface CompactionDelta {
|
|
24
|
+
/** Decisions added since last compaction */
|
|
25
|
+
newDecisions: string[];
|
|
26
|
+
/** Decisions that appear to have been superseded or removed */
|
|
27
|
+
removedDecisions: string[];
|
|
28
|
+
/** Open loops that were resolved */
|
|
29
|
+
resolvedLoops: string[];
|
|
30
|
+
/** Open loops still open from last time */
|
|
31
|
+
persistentLoops: string[];
|
|
32
|
+
/** New open loops */
|
|
33
|
+
newLoops: string[];
|
|
34
|
+
/** Files modified since last compaction */
|
|
35
|
+
newModifiedFiles: string[];
|
|
36
|
+
/** Errors that were resolved since last compaction */
|
|
37
|
+
resolvedErrors: string[];
|
|
38
|
+
/** New unresolved errors */
|
|
39
|
+
newErrors: string[];
|
|
40
|
+
/** Goal changed? */
|
|
41
|
+
goalChanged: boolean;
|
|
42
|
+
/** Previous goal if changed */
|
|
43
|
+
previousGoal: string | null;
|
|
44
|
+
}
|
|
45
|
+
export declare function computeDelta(prev: CompactionState, current: CompactionState): CompactionDelta;
|
|
46
|
+
/**
|
|
47
|
+
* Format delta as Markdown section for injection into summary.
|
|
48
|
+
*/
|
|
49
|
+
export declare function formatDeltaSection(delta: CompactionDelta): string;
|
|
50
|
+
/**
|
|
51
|
+
* Inject delta section into summary, after Open Loops (or before Next Steps).
|
|
52
|
+
*/
|
|
53
|
+
export declare function injectDeltaSection(summary: string, delta: CompactionDelta): string;
|
|
54
|
+
/**
|
|
55
|
+
* Extract next actions from the summary's "Next Steps" section.
|
|
56
|
+
*/
|
|
57
|
+
export declare function extractNextActions(summary: string): string[];
|
|
58
|
+
/**
|
|
59
|
+
* Extract critical context lines from the summary.
|
|
60
|
+
*/
|
|
61
|
+
export declare function extractCriticalContext(summary: string): string[];
|
|
62
|
+
//# sourceMappingURL=state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/utils/state.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,oBAAoB,EAAE,QAAQ,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAUtG;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,GAAG,IAAI,CAKnF;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,CAe7E;AAED,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,oBAAoB,EAChC,SAAS,EAAE,QAAQ,EAAE,EACrB,MAAM,EAAE,iBAAiB,GAAG,IAAI,EAChC,WAAW,EAAE,MAAM,EAAE,EACrB,eAAe,EAAE,MAAM,EAAE,GACxB,eAAe,CAgDjB;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,MAAM,CAsBrF;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,4CAA4C;IAC5C,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,+DAA+D;IAC/D,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,oCAAoC;IACpC,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,2CAA2C;IAC3C,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,qBAAqB;IACrB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,2CAA2C;IAC3C,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,sDAAsD;IACtD,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,4BAA4B;IAC5B,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,oBAAoB;IACpB,WAAW,EAAE,OAAO,CAAC;IACrB,+BAA+B;IAC/B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,eAAe,GAAG,eAAe,CAmD7F;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CA+BjE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,GAAG,MAAM,CA2BlF;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAO5D;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAIhE"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Token estimation with provider-specific ratios and EMA calibration.
|
|
3
|
+
*/
|
|
4
|
+
import type { ProviderCapabilities } from "../types.ts";
|
|
5
|
+
export declare function getProviderCaps(provider: string): ProviderCapabilities;
|
|
6
|
+
export declare function estimateTokens(text: string, provider?: string): number;
|
|
7
|
+
export declare function calibrateFromResponse(estimated: number, actual: number, provider?: string): void;
|
|
8
|
+
//# sourceMappingURL=tokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../src/utils/tokens.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AA8ExD,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,oBAAoB,CAQtE;AAUD,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAQtE;AAED,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAMhG"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type guards and utility functions for content block inspection.
|
|
3
|
+
* Extracted from types.ts to keep type definitions pure.
|
|
4
|
+
*/
|
|
5
|
+
/** Type guard for text content blocks */
|
|
6
|
+
export declare function isTextBlock(c: unknown): c is {
|
|
7
|
+
type: "text";
|
|
8
|
+
text: string;
|
|
9
|
+
};
|
|
10
|
+
/** Type guard for tool call content blocks */
|
|
11
|
+
export declare function isToolCallBlock(c: unknown): c is {
|
|
12
|
+
type: "toolCall";
|
|
13
|
+
id?: string;
|
|
14
|
+
name: string;
|
|
15
|
+
arguments: Record<string, unknown>;
|
|
16
|
+
};
|
|
17
|
+
/** Get tool call names from unknown content */
|
|
18
|
+
export declare function getToolCallNames(content: unknown): string[];
|
|
19
|
+
/** Filter tool call blocks from unknown content */
|
|
20
|
+
export declare function filterToolCalls(content: unknown): Array<{
|
|
21
|
+
type: "toolCall";
|
|
22
|
+
id?: string;
|
|
23
|
+
name: string;
|
|
24
|
+
arguments: Record<string, unknown>;
|
|
25
|
+
}>;
|
|
26
|
+
//# sourceMappingURL=type-guards.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-guards.d.ts","sourceRoot":"","sources":["../../src/utils/type-guards.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,yCAAyC;AACzC,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAE3E;AAED,8CAA8C;AAC9C,wBAAgB,eAAe,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,CAEpI;AAED,+CAA+C;AAC/C,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,EAAE,CAG3D;AAED,mDAAmD;AACnD,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,KAAK,CAAC;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,CAAC,CAG5I"}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-smart-compact",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.9.0",
|
|
4
4
|
"description": "EESV smart compaction extension for Pi Coding Agent — deterministic extraction, exploration, synthesis, verification with redundancy pruning, project fingerprinting, and damage detection.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
7
14
|
"author": "Alper Tarhan <alpertarhan@gmail.com>",
|
|
8
15
|
"repository": {
|
|
9
16
|
"type": "git",
|
|
@@ -27,12 +34,13 @@
|
|
|
27
34
|
],
|
|
28
35
|
"files": [
|
|
29
36
|
"dist",
|
|
37
|
+
"docs",
|
|
30
38
|
"README.md",
|
|
31
39
|
"LICENSE",
|
|
32
40
|
"CHANGELOG.md"
|
|
33
41
|
],
|
|
34
42
|
"scripts": {
|
|
35
|
-
"build": "rm -rf dist && mkdir dist && bun build ./src/index.ts --outdir ./dist --target bun --external '@earendil-works/*' --external 'typebox'",
|
|
43
|
+
"build": "rm -rf dist && mkdir dist && bun build ./src/index.ts --outdir ./dist --target bun --external '@earendil-works/*' --external 'typebox' && (bunx tsc --emitDeclarationOnly --outDir dist || true)",
|
|
36
44
|
"test": "bun test",
|
|
37
45
|
"typecheck": "bunx tsc --noEmit"
|
|
38
46
|
},
|