@lumy-pack/line-lore 0.0.1 → 0.0.2
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 +199 -7
- package/dist/cli.mjs +185 -150
- package/dist/git/executor.d.ts +1 -0
- package/dist/git/index.d.ts +1 -1
- package/dist/index.cjs +177 -158
- package/dist/index.mjs +177 -148
- package/dist/version.d.ts +5 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -79,13 +79,181 @@ console.log(result.warnings); // degradation messages
|
|
|
79
79
|
|
|
80
80
|
No ML or heuristics — results are always reproducible.
|
|
81
81
|
|
|
82
|
+
## Understanding the Output
|
|
83
|
+
|
|
84
|
+
### TraceNode — the core unit of output
|
|
85
|
+
|
|
86
|
+
Every `trace()` call returns a `nodes` array. Each node represents one step in the ancestry chain from the code line back to its PR. Nodes are ordered from most recent (the line's direct commit) to most distant (the PR or issue).
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
interface TraceNode {
|
|
90
|
+
type: TraceNodeType; // What this node represents
|
|
91
|
+
sha?: string; // Git commit hash (40 chars)
|
|
92
|
+
trackingMethod: TrackingMethod; // How this node was discovered
|
|
93
|
+
confidence: Confidence; // How reliable this result is
|
|
94
|
+
prNumber?: number; // PR/MR number (only on pull_request nodes)
|
|
95
|
+
prUrl?: string; // Full URL to PR (only with Level 2 API access)
|
|
96
|
+
prTitle?: string; // PR title (only with Level 2 API access)
|
|
97
|
+
mergedAt?: string; // When the PR was merged (ISO 8601)
|
|
98
|
+
patchId?: string; // Git patch-id (only on rebased_commit nodes)
|
|
99
|
+
note?: string; // Additional context (e.g., "Cosmetic change: whitespace")
|
|
100
|
+
issueNumber?: number; // Issue number (only on issue nodes)
|
|
101
|
+
issueUrl?: string; // Issue URL
|
|
102
|
+
issueTitle?: string; // Issue title
|
|
103
|
+
issueState?: 'open' | 'closed';
|
|
104
|
+
issueLabels?: string[];
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Node types
|
|
109
|
+
|
|
110
|
+
| Type | Symbol | Meaning | When it appears |
|
|
111
|
+
|------|--------|---------|-----------------|
|
|
112
|
+
| `original_commit` | `●` | The commit that introduced or last modified this line | Always (at least one) |
|
|
113
|
+
| `cosmetic_commit` | `○` | A formatting-only change (whitespace, imports) | When AST detects no logic change |
|
|
114
|
+
| `merge_commit` | `◆` | The merge commit on the base branch | Merge-based workflows |
|
|
115
|
+
| `rebased_commit` | `◇` | A rebased version of the original commit | Rebase workflows with patch-id match |
|
|
116
|
+
| `pull_request` | `▸` | The PR/MR that introduced this change | When PR is found (Level 1 or 2) |
|
|
117
|
+
| `issue` | `▹` | A linked issue from the PR | When `--graph-depth >= 1` with Level 2 |
|
|
118
|
+
|
|
119
|
+
### Tracking methods
|
|
120
|
+
|
|
121
|
+
| Method | Stage | Meaning |
|
|
122
|
+
|--------|-------|---------|
|
|
123
|
+
| `blame-CMw` | 1 | Found via `git blame -C -C -M -w` |
|
|
124
|
+
| `ast-signature` | 1-B | Found via AST structural comparison |
|
|
125
|
+
| `message-parse` | 3 | PR number extracted from merge commit message (e.g., `Merge pull request #42`) |
|
|
126
|
+
| `ancestry-path` | 3 | Found via `git log --ancestry-path --merges` |
|
|
127
|
+
| `patch-id` | 3 | Matched via `git patch-id` (rebase detection) |
|
|
128
|
+
| `api` | 4 | Found via GitHub/GitLab REST API |
|
|
129
|
+
| `issue-link` | 4+ | Found via PR-to-issue link in API |
|
|
130
|
+
|
|
131
|
+
### Confidence levels
|
|
132
|
+
|
|
133
|
+
| Level | Meaning |
|
|
134
|
+
|-------|---------|
|
|
135
|
+
| `exact` | Deterministic match (blame, API lookup) |
|
|
136
|
+
| `structural` | AST structure matches but not byte-identical |
|
|
137
|
+
| `heuristic` | Best-effort match (message parsing, patch-id) |
|
|
138
|
+
|
|
139
|
+
### Output examples
|
|
140
|
+
|
|
141
|
+
**Typical merge workflow (Level 2):**
|
|
142
|
+
```
|
|
143
|
+
● Commit a1b2c3d [exact] via blame-CMw
|
|
144
|
+
▸ PR #42 feat: add authentication
|
|
145
|
+
└─ https://github.com/org/repo/pull/42
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
**Squash merge (Level 2):**
|
|
149
|
+
```
|
|
150
|
+
● Commit e4f5a6b [exact] via blame-CMw
|
|
151
|
+
▸ PR #55 refactor: user service
|
|
152
|
+
└─ https://github.com/org/repo/pull/55
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
**Cosmetic change detected (AST enabled):**
|
|
156
|
+
```
|
|
157
|
+
○ Cosmetic d7e8f9a [exact] Cosmetic change: whitespace-only
|
|
158
|
+
● Commit b2c3d4e [structural] via ast-signature
|
|
159
|
+
▸ PR #31 feat: original logic
|
|
160
|
+
└─ https://github.com/org/repo/pull/31
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
**Level 0 (offline — no platform CLI):**
|
|
164
|
+
```
|
|
165
|
+
● Commit a1b2c3d [exact] via blame-CMw
|
|
166
|
+
|
|
167
|
+
⚠ Could not detect platform. Running in Level 0 (git only).
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
**Level 1 (CLI found, not authenticated):**
|
|
171
|
+
```
|
|
172
|
+
● Commit a1b2c3d [exact] via blame-CMw
|
|
173
|
+
▸ PR #42 [heuristic] via message-parse
|
|
174
|
+
|
|
175
|
+
⚠ Platform CLI not authenticated. Running in Level 1 (local only).
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
**JSON output (`--output json`):**
|
|
179
|
+
```json
|
|
180
|
+
{
|
|
181
|
+
"nodes": [
|
|
182
|
+
{
|
|
183
|
+
"type": "original_commit",
|
|
184
|
+
"sha": "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0",
|
|
185
|
+
"trackingMethod": "blame-CMw",
|
|
186
|
+
"confidence": "exact"
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
"type": "pull_request",
|
|
190
|
+
"sha": "f0e1d2c3b4a5f6e7d8c9b0a1f2e3d4c5b6a7f8e9",
|
|
191
|
+
"trackingMethod": "api",
|
|
192
|
+
"confidence": "exact",
|
|
193
|
+
"prNumber": 42,
|
|
194
|
+
"prUrl": "https://github.com/org/repo/pull/42",
|
|
195
|
+
"prTitle": "feat: add authentication",
|
|
196
|
+
"mergedAt": "2025-03-15T10:30:00Z"
|
|
197
|
+
}
|
|
198
|
+
],
|
|
199
|
+
"operatingLevel": 2,
|
|
200
|
+
"featureFlags": {
|
|
201
|
+
"astDiff": true,
|
|
202
|
+
"deepTrace": false,
|
|
203
|
+
"commitGraph": false,
|
|
204
|
+
"issueGraph": false,
|
|
205
|
+
"graphql": true
|
|
206
|
+
},
|
|
207
|
+
"warnings": []
|
|
208
|
+
}
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
**Quiet mode (`--quiet`):**
|
|
212
|
+
```
|
|
213
|
+
42
|
|
214
|
+
```
|
|
215
|
+
Returns just the PR number. If no PR is found, returns the short commit SHA (e.g., `a1b2c3d`).
|
|
216
|
+
|
|
217
|
+
### How to interpret results
|
|
218
|
+
|
|
219
|
+
| What you see | What it means |
|
|
220
|
+
|--------------|---------------|
|
|
221
|
+
| Only `original_commit` | The commit was found but no PR could be linked (direct push, or Level 0) |
|
|
222
|
+
| `original_commit` + `pull_request` | Successfully traced line → commit → PR |
|
|
223
|
+
| `cosmetic_commit` + `original_commit` + `pull_request` | Line was reformatted; AST traced back to the real logic change |
|
|
224
|
+
| `prUrl` is empty | PR was found via message parsing (Level 1) but no API details available |
|
|
225
|
+
| `warnings` array has entries | Some features are degraded — check `operatingLevel` |
|
|
226
|
+
| `operatingLevel: 0` | No platform CLI — only git blame results available |
|
|
227
|
+
| `operatingLevel: 1` | CLI found but not authenticated — PR lookup via merge message only |
|
|
228
|
+
| `operatingLevel: 2` | Full API access — most accurate results |
|
|
229
|
+
|
|
82
230
|
## Operating Levels
|
|
83
231
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
232
|
+
| Level | Requirements | What works | What doesn't |
|
|
233
|
+
|-------|-------------|------------|--------------|
|
|
234
|
+
| **0** | Git only | Blame, AST diff | PR lookup, issue graph |
|
|
235
|
+
| **1** | `gh`/`glab` CLI installed | Blame, AST diff, PR via merge message | API-based PR lookup, issue graph, deep trace |
|
|
236
|
+
| **2** | `gh`/`glab` CLI authenticated | Everything | — |
|
|
237
|
+
|
|
238
|
+
Run `line-lore health` to check your current level:
|
|
239
|
+
```bash
|
|
240
|
+
npx @lumy-pack/line-lore health
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### Upgrading your level
|
|
87
244
|
|
|
88
|
-
|
|
245
|
+
```bash
|
|
246
|
+
# Level 0 → 1: Install the CLI
|
|
247
|
+
brew install gh # GitHub
|
|
248
|
+
brew install glab # GitLab
|
|
249
|
+
|
|
250
|
+
# Level 1 → 2: Authenticate
|
|
251
|
+
gh auth login # GitHub
|
|
252
|
+
glab auth login # GitLab
|
|
253
|
+
|
|
254
|
+
# GitHub Enterprise: authenticate with your hostname
|
|
255
|
+
gh auth login --hostname git.corp.com
|
|
256
|
+
```
|
|
89
257
|
|
|
90
258
|
## Platform Support
|
|
91
259
|
|
|
@@ -94,6 +262,8 @@ Higher levels unlock deep tracing, issue graph traversal, and more accurate PR m
|
|
|
94
262
|
- GitLab.com
|
|
95
263
|
- GitLab Self-Hosted
|
|
96
264
|
|
|
265
|
+
Platform is auto-detected from your git remote URL. Unknown hosts default to GitHub Enterprise.
|
|
266
|
+
|
|
97
267
|
## API Reference
|
|
98
268
|
|
|
99
269
|
### `trace(options: TraceOptions): Promise<TraceFullResult>`
|
|
@@ -115,13 +285,35 @@ Trace a code line to its originating PR.
|
|
|
115
285
|
**Returns:**
|
|
116
286
|
```typescript
|
|
117
287
|
{
|
|
118
|
-
nodes: TraceNode[]; // Ancestry
|
|
119
|
-
operatingLevel: 0 | 1 | 2; //
|
|
120
|
-
featureFlags: FeatureFlags; //
|
|
288
|
+
nodes: TraceNode[]; // Ancestry chain (commits → PRs → issues)
|
|
289
|
+
operatingLevel: 0 | 1 | 2; // Current capability level
|
|
290
|
+
featureFlags: FeatureFlags; // Which features are active
|
|
121
291
|
warnings: string[]; // Degradation notices
|
|
122
292
|
}
|
|
123
293
|
```
|
|
124
294
|
|
|
295
|
+
**How to read the result:**
|
|
296
|
+
```typescript
|
|
297
|
+
const result = await trace({ file: 'src/auth.ts', line: 42 });
|
|
298
|
+
|
|
299
|
+
// Did we find a PR?
|
|
300
|
+
const prNode = result.nodes.find(n => n.type === 'pull_request');
|
|
301
|
+
if (prNode) {
|
|
302
|
+
console.log(`PR #${prNode.prNumber}: ${prNode.prTitle}`);
|
|
303
|
+
console.log(`URL: ${prNode.prUrl}`); // only at Level 2
|
|
304
|
+
console.log(`Merged: ${prNode.mergedAt}`); // only at Level 2
|
|
305
|
+
} else {
|
|
306
|
+
// No PR found — line was a direct commit or Level 0
|
|
307
|
+
const commit = result.nodes.find(n => n.type === 'original_commit');
|
|
308
|
+
console.log(`Direct commit: ${commit?.sha}`);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// Check if results are degraded
|
|
312
|
+
if (result.operatingLevel < 2) {
|
|
313
|
+
console.warn('Limited results:', result.warnings);
|
|
314
|
+
}
|
|
315
|
+
```
|
|
316
|
+
|
|
125
317
|
### `health(options?: { cwd?: string }): Promise<HealthReport>`
|
|
126
318
|
|
|
127
319
|
Check system health: git version, platform CLI status, authentication.
|