@markmdev/pebble 0.1.13 → 0.1.16
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/dist/cli/index.js
CHANGED
|
@@ -8,6 +8,9 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
8
8
|
|
|
9
9
|
// src/cli/index.ts
|
|
10
10
|
import { Command } from "commander";
|
|
11
|
+
import { readFileSync as readFileSync2 } from "fs";
|
|
12
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
13
|
+
import { dirname as dirname2, join as join3 } from "path";
|
|
11
14
|
|
|
12
15
|
// src/shared/types.ts
|
|
13
16
|
var ISSUE_TYPES = ["task", "bug", "epic", "verification"];
|
|
@@ -83,6 +86,17 @@ function getMainWorktreeRoot() {
|
|
|
83
86
|
return null;
|
|
84
87
|
}
|
|
85
88
|
}
|
|
89
|
+
function getCurrentWorktreeName() {
|
|
90
|
+
try {
|
|
91
|
+
const toplevel = execSync("git rev-parse --show-toplevel", {
|
|
92
|
+
encoding: "utf-8",
|
|
93
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
94
|
+
}).trim();
|
|
95
|
+
return path.basename(toplevel);
|
|
96
|
+
} catch {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
86
100
|
|
|
87
101
|
// src/cli/lib/storage.ts
|
|
88
102
|
var PEBBLE_DIR = ".pebble";
|
|
@@ -119,6 +133,18 @@ function resolveWorktreePebbleDir(localPebbleDir) {
|
|
|
119
133
|
return localPebbleDir;
|
|
120
134
|
}
|
|
121
135
|
function discoverPebbleDir(startDir = process.cwd()) {
|
|
136
|
+
if (process.env.PEBBLE_LOCAL !== "1") {
|
|
137
|
+
const mainRoot = getMainWorktreeRoot();
|
|
138
|
+
if (mainRoot) {
|
|
139
|
+
const mainPebble = path2.join(mainRoot, PEBBLE_DIR);
|
|
140
|
+
if (fs.existsSync(mainPebble) && fs.statSync(mainPebble).isDirectory()) {
|
|
141
|
+
const config = getConfigSafe(mainPebble);
|
|
142
|
+
if (config?.useMainTreePebble !== false) {
|
|
143
|
+
return mainPebble;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
122
148
|
let currentDir = path2.resolve(startDir);
|
|
123
149
|
const root = path2.parse(currentDir).root;
|
|
124
150
|
while (currentDir !== root) {
|
|
@@ -172,9 +198,21 @@ function getIssuesPath(pebbleDir) {
|
|
|
172
198
|
const dir = pebbleDir ?? getPebbleDir();
|
|
173
199
|
return path2.join(dir, ISSUES_FILE);
|
|
174
200
|
}
|
|
201
|
+
function getEventSource() {
|
|
202
|
+
const worktreeName = getCurrentWorktreeName();
|
|
203
|
+
if (worktreeName) {
|
|
204
|
+
return worktreeName;
|
|
205
|
+
}
|
|
206
|
+
const pebbleDir = discoverPebbleDir();
|
|
207
|
+
if (pebbleDir) {
|
|
208
|
+
return path2.basename(path2.dirname(pebbleDir));
|
|
209
|
+
}
|
|
210
|
+
return "unknown";
|
|
211
|
+
}
|
|
175
212
|
function appendEvent(event, pebbleDir) {
|
|
176
213
|
const issuesPath = getIssuesPath(pebbleDir);
|
|
177
|
-
const
|
|
214
|
+
const eventWithSource = event.source ? event : { ...event, source: getEventSource() };
|
|
215
|
+
const line = JSON.stringify(eventWithSource) + "\n";
|
|
178
216
|
fs.appendFileSync(issuesPath, line, "utf-8");
|
|
179
217
|
}
|
|
180
218
|
function readEventsFromFile(filePath) {
|
|
@@ -255,7 +293,8 @@ function computeState(events) {
|
|
|
255
293
|
verifies: createEvent.data.verifies,
|
|
256
294
|
comments: [],
|
|
257
295
|
createdAt: event.timestamp,
|
|
258
|
-
updatedAt: event.timestamp
|
|
296
|
+
updatedAt: event.timestamp,
|
|
297
|
+
lastSource: event.source
|
|
259
298
|
};
|
|
260
299
|
issues.set(event.issueId, issue);
|
|
261
300
|
break;
|
|
@@ -289,6 +328,7 @@ function computeState(events) {
|
|
|
289
328
|
issue.relatedTo = updateEvent.data.relatedTo;
|
|
290
329
|
}
|
|
291
330
|
issue.updatedAt = event.timestamp;
|
|
331
|
+
if (event.source) issue.lastSource = event.source;
|
|
292
332
|
}
|
|
293
333
|
break;
|
|
294
334
|
}
|
|
@@ -297,6 +337,7 @@ function computeState(events) {
|
|
|
297
337
|
if (issue) {
|
|
298
338
|
issue.status = "closed";
|
|
299
339
|
issue.updatedAt = event.timestamp;
|
|
340
|
+
if (event.source) issue.lastSource = event.source;
|
|
300
341
|
}
|
|
301
342
|
break;
|
|
302
343
|
}
|
|
@@ -305,6 +346,7 @@ function computeState(events) {
|
|
|
305
346
|
if (issue) {
|
|
306
347
|
issue.status = "open";
|
|
307
348
|
issue.updatedAt = event.timestamp;
|
|
349
|
+
if (event.source) issue.lastSource = event.source;
|
|
308
350
|
}
|
|
309
351
|
break;
|
|
310
352
|
}
|
|
@@ -314,6 +356,7 @@ function computeState(events) {
|
|
|
314
356
|
if (issue) {
|
|
315
357
|
issue.comments.push(commentEvent.data);
|
|
316
358
|
issue.updatedAt = event.timestamp;
|
|
359
|
+
if (event.source) issue.lastSource = event.source;
|
|
317
360
|
}
|
|
318
361
|
break;
|
|
319
362
|
}
|
|
@@ -2190,7 +2233,8 @@ function findIssueInSources(issueId, filePaths) {
|
|
|
2190
2233
|
return { issue: found, targetFile };
|
|
2191
2234
|
}
|
|
2192
2235
|
function appendEventToFile(event, filePath) {
|
|
2193
|
-
const
|
|
2236
|
+
const eventWithSource = event.source ? event : { ...event, source: getEventSource() };
|
|
2237
|
+
const line = JSON.stringify(eventWithSource) + "\n";
|
|
2194
2238
|
fs2.appendFileSync(filePath, line, "utf-8");
|
|
2195
2239
|
}
|
|
2196
2240
|
function uiCommand(program2) {
|
|
@@ -3037,9 +3081,9 @@ data: ${message}
|
|
|
3037
3081
|
res.status(500).json({ error: error.message });
|
|
3038
3082
|
}
|
|
3039
3083
|
});
|
|
3040
|
-
const
|
|
3041
|
-
const
|
|
3042
|
-
const uiPath = path3.resolve(
|
|
3084
|
+
const __filename3 = fileURLToPath(import.meta.url);
|
|
3085
|
+
const __dirname3 = path3.dirname(__filename3);
|
|
3086
|
+
const uiPath = path3.resolve(__dirname3, "../ui");
|
|
3043
3087
|
app.use(express.static(uiPath));
|
|
3044
3088
|
app.get("*", (_req, res) => {
|
|
3045
3089
|
res.sendFile(path3.join(uiPath, "index.html"));
|
|
@@ -3725,8 +3769,11 @@ function initCommand(program2) {
|
|
|
3725
3769
|
}
|
|
3726
3770
|
|
|
3727
3771
|
// src/cli/index.ts
|
|
3772
|
+
var __filename2 = fileURLToPath2(import.meta.url);
|
|
3773
|
+
var __dirname2 = dirname2(__filename2);
|
|
3774
|
+
var packageJson = JSON.parse(readFileSync2(join3(__dirname2, "../../package.json"), "utf-8"));
|
|
3728
3775
|
var program = new Command();
|
|
3729
|
-
program.name("pebble").description("A lightweight JSONL-based issue tracker").version(
|
|
3776
|
+
program.name("pebble").description("A lightweight JSONL-based issue tracker").version(packageJson.version);
|
|
3730
3777
|
program.option("-P, --pretty", "Human-readable output (default: JSON)");
|
|
3731
3778
|
program.option("--json", "JSON output (this is the default, flag not needed)");
|
|
3732
3779
|
program.option("--local", "Use local .pebble directory even in a git worktree");
|