pi-plans 0.2.0 → 0.3.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 +74 -21
- package/index.ts +115 -9
- package/package.json +7 -1
- package/references/pi-planning-workflow.md +18 -3
- package/references/state-and-config.md +34 -2
- package/scripts/validate.ts +4 -0
- package/src/code-graph/commands.ts +437 -0
- package/src/code-graph/discovery.ts +118 -0
- package/src/code-graph/git.ts +108 -0
- package/src/code-graph/identity.ts +59 -0
- package/src/code-graph/indexer.ts +281 -0
- package/src/code-graph/materialize.ts +166 -0
- package/src/code-graph/mode.ts +28 -0
- package/src/code-graph/mutations.ts +160 -0
- package/src/code-graph/parser.ts +51 -0
- package/src/code-graph/parsers/javascript.ts +35 -0
- package/src/code-graph/parsers/python.ts +160 -0
- package/src/code-graph/parsers/tree-sitter.ts +316 -0
- package/src/code-graph/paths.ts +85 -0
- package/src/code-graph/prompts.ts +18 -0
- package/src/code-graph/resolver.ts +69 -0
- package/src/code-graph/runtime.ts +158 -0
- package/src/code-graph/schema.ts +135 -0
- package/src/code-graph/screening.ts +82 -0
- package/src/code-graph/store.ts +278 -0
- package/src/code-graph/summary.ts +435 -0
- package/src/code-graph/types.ts +163 -0
- package/src/compaction.ts +1125 -371
- package/src/config-command.ts +326 -0
- package/src/exec.ts +356 -686
- package/src/refine-prompts.ts +50 -0
- package/src/refine-ui-helpers.ts +71 -18
- package/src/refine-ui-state.ts +87 -21
- package/src/refine-ui.ts +210 -102
- package/src/state.ts +19 -6
- package/src/subagent.ts +163 -61
- package/tests/ask-choice.test.ts +263 -0
- package/tests/autocomplete.test.ts +6 -1
- package/tests/code-graph-apply.test.ts +185 -0
- package/tests/code-graph-commands.test.ts +211 -0
- package/tests/code-graph-db.test.ts +166 -0
- package/tests/code-graph-discovery.test.ts +38 -0
- package/tests/code-graph-git.test.ts +94 -0
- package/tests/code-graph-index.test.ts +175 -0
- package/tests/code-graph-loop.e2e.test.ts +159 -0
- package/tests/code-graph-mutations.test.ts +117 -0
- package/tests/code-graph-parser.test.ts +85 -0
- package/tests/code-graph-rollback.test.ts +100 -0
- package/tests/code-graph-summary-batching.test.ts +518 -0
- package/tests/code-graph-summary.test.ts +148 -0
- package/tests/compaction.test.ts +371 -57
- package/tests/config-command.test.ts +255 -0
- package/tests/exec.test.ts +665 -241
- package/tests/fixtures/code-graph/sample.js +36 -0
- package/tests/fixtures/code-graph/sample.py +20 -0
- package/tests/fixtures/code-graph/sample.ts +15 -0
- package/tests/graph-aware-file-tools.test.ts +411 -0
- package/tests/refine-prompts.test.ts +67 -2
- package/tests/refine-ui.test.ts +337 -72
- package/tests/subagent.test.ts +26 -20
- package/tools/ask-choice.ts +158 -11
- package/tools/code-graph.ts +254 -0
- package/tools/graph-aware-file-tools.ts +392 -0
- package/tools/plans.ts +84 -1
- package/tools/refine.ts +61 -15
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public type definitions shared across the code-graph module. Kept small and
|
|
3
|
+
* dependency-free so all sibling modules can import them safely.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export type Language = "javascript" | "typescript" | "tsx" | "python";
|
|
7
|
+
|
|
8
|
+
export interface SourceLocation {
|
|
9
|
+
startByte: number;
|
|
10
|
+
endByte: number;
|
|
11
|
+
startLine: number;
|
|
12
|
+
startColumn: number;
|
|
13
|
+
endLine: number;
|
|
14
|
+
endColumn: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface ParseDiagnostic {
|
|
18
|
+
message: string;
|
|
19
|
+
severity: "error" | "warning" | "missing";
|
|
20
|
+
startByte?: number;
|
|
21
|
+
endByte?: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type RenderUnitKind =
|
|
25
|
+
| "raw"
|
|
26
|
+
| "function"
|
|
27
|
+
| "method"
|
|
28
|
+
| "arrow"
|
|
29
|
+
| "lambda"
|
|
30
|
+
| "expression"
|
|
31
|
+
| "decorator"
|
|
32
|
+
| "docstring"
|
|
33
|
+
| "unsupported";
|
|
34
|
+
|
|
35
|
+
export interface RenderUnit {
|
|
36
|
+
kind: RenderUnitKind;
|
|
37
|
+
/** Byte offsets into the source snapshot (UTF-8 bytes). */
|
|
38
|
+
startByte: number;
|
|
39
|
+
endByte: number;
|
|
40
|
+
/** Optional identifier for chunks (function name, expression handle, etc.). */
|
|
41
|
+
label?: string;
|
|
42
|
+
/** Nested children rendered by the same backend. */
|
|
43
|
+
children?: RenderUnit[];
|
|
44
|
+
/** Whether this unit may be safely moved between manifest entries. */
|
|
45
|
+
moveSupported: boolean;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface FunctionRecord {
|
|
49
|
+
fileDir: string;
|
|
50
|
+
fileName: string;
|
|
51
|
+
functionName: string;
|
|
52
|
+
language: Language;
|
|
53
|
+
kind: "declaration" | "expression" | "arrow" | "method" | "async" | "generator" | "lambda" | "accessor" | "unsupported";
|
|
54
|
+
/** UTF-8 text of the callable body (best-effort, may equal render code). */
|
|
55
|
+
fullCode: string;
|
|
56
|
+
fullCodeHash: string;
|
|
57
|
+
/** Text used by the materializer to reconstruct the file (render unit). */
|
|
58
|
+
renderCode: string;
|
|
59
|
+
renderCodeHash: string;
|
|
60
|
+
/** Optional human-readable parent identifier (class name, container). */
|
|
61
|
+
parent?: string;
|
|
62
|
+
/** Optional container group (class body, module). */
|
|
63
|
+
container?: string;
|
|
64
|
+
/** Whether the function entry may be moved between manifest positions. */
|
|
65
|
+
moveSupported: boolean;
|
|
66
|
+
/** Whether this record is a primary function (true) or merged overload signature (false). */
|
|
67
|
+
isPrimary: boolean;
|
|
68
|
+
/** Optional list of overload signatures merged into this entry (TypeScript). */
|
|
69
|
+
overloadSignatures?: string[];
|
|
70
|
+
/** UTF-8 byte span of the callable (provenance). */
|
|
71
|
+
provenance: SourceLocation;
|
|
72
|
+
summary: SummaryRecord | null;
|
|
73
|
+
version: number;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface SummaryRecord {
|
|
77
|
+
description: string;
|
|
78
|
+
inputs: string[];
|
|
79
|
+
outputs: string[];
|
|
80
|
+
status: "ok" | "pending" | "declined" | "failed";
|
|
81
|
+
model?: string;
|
|
82
|
+
schemaVersion: number;
|
|
83
|
+
effectiveEffort?: string;
|
|
84
|
+
errorMessage?: string;
|
|
85
|
+
updatedAt?: string;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface FileEntry {
|
|
89
|
+
id: number;
|
|
90
|
+
kind: "raw" | "function" | "decorator" | "docstring" | "trailing";
|
|
91
|
+
/** Order within the file manifest. */
|
|
92
|
+
ordinal: number;
|
|
93
|
+
/** Optional reference to a function row (`(file_dir,file_name,function_name)`). */
|
|
94
|
+
functionName?: string;
|
|
95
|
+
/** Byte offsets into the file source snapshot. */
|
|
96
|
+
startByte: number;
|
|
97
|
+
endByte: number;
|
|
98
|
+
text: string;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export interface FileRecord {
|
|
102
|
+
fileDir: string;
|
|
103
|
+
fileName: string;
|
|
104
|
+
language: Language;
|
|
105
|
+
sourceHash: string;
|
|
106
|
+
sourceText: string;
|
|
107
|
+
entries: FileEntry[];
|
|
108
|
+
updatedAt: string;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export type EdgeKind = "call" | "definition" | "import";
|
|
112
|
+
export type EdgeResolution = "resolved" | "ambiguous" | "unresolved";
|
|
113
|
+
|
|
114
|
+
export interface CallEdge {
|
|
115
|
+
id: number;
|
|
116
|
+
fromFileDir: string;
|
|
117
|
+
fromFileName: string;
|
|
118
|
+
fromFunction: string;
|
|
119
|
+
toFileDir?: string;
|
|
120
|
+
toFileName?: string;
|
|
121
|
+
toFunction?: string;
|
|
122
|
+
toCalleeText: string;
|
|
123
|
+
kind: EdgeKind;
|
|
124
|
+
resolution: EdgeResolution;
|
|
125
|
+
reason?: string;
|
|
126
|
+
provenance: SourceLocation;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export interface GraphMeta {
|
|
130
|
+
schemaVersion: number;
|
|
131
|
+
worktreeRoot: string;
|
|
132
|
+
gitCommonDir: string;
|
|
133
|
+
parserVersions: Record<string, string>;
|
|
134
|
+
updatedAt: string;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export interface CodeGraphSnapshot {
|
|
138
|
+
id: number;
|
|
139
|
+
headCommit: string;
|
|
140
|
+
uncommittedPaths: string[];
|
|
141
|
+
recordedAt: string;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export interface GraphContext {
|
|
145
|
+
worktreeRoot: string;
|
|
146
|
+
gitCommonDir: string;
|
|
147
|
+
dbPath: string;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export interface FunctionScreening {
|
|
151
|
+
fileDir: string;
|
|
152
|
+
fileName: string;
|
|
153
|
+
functionName: string;
|
|
154
|
+
language: Language;
|
|
155
|
+
kind: FunctionRecord["kind"];
|
|
156
|
+
description: string | null;
|
|
157
|
+
inputs: string[] | null;
|
|
158
|
+
outputs: string[] | null;
|
|
159
|
+
version: number;
|
|
160
|
+
summaryStatus: SummaryRecord["status"] | null;
|
|
161
|
+
inLinks: Array<{ fileDir: string; fileName: string; functionName: string }>;
|
|
162
|
+
outLinks: Array<{ fileDir: string; fileName: string; functionName: string }>;
|
|
163
|
+
}
|