@0dai-dev/cli 3.2.3 → 3.2.4
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/bin/0dai.js +41 -15
- package/package.json +1 -1
package/bin/0dai.js
CHANGED
|
@@ -1599,31 +1599,57 @@ async function cmdAuthStatus() {
|
|
|
1599
1599
|
}
|
|
1600
1600
|
|
|
1601
1601
|
async function cmdFeedbackPush(target) {
|
|
1602
|
-
const
|
|
1603
|
-
const
|
|
1602
|
+
const fbDir = path.join(target, "ai", "feedback");
|
|
1603
|
+
const items = [];
|
|
1604
|
+
|
|
1605
|
+
// Collect from report JSON files
|
|
1604
1606
|
try {
|
|
1605
|
-
for (const f of fs.readdirSync(
|
|
1607
|
+
for (const f of fs.readdirSync(fbDir)) {
|
|
1606
1608
|
if (f.endsWith("-report.json") || (f.endsWith(".json") && f.match(/^\d{8}/))) {
|
|
1607
1609
|
try {
|
|
1608
|
-
const d = JSON.parse(fs.readFileSync(path.join(
|
|
1609
|
-
if (d.project || d.verdict)
|
|
1610
|
+
const d = JSON.parse(fs.readFileSync(path.join(fbDir, f), "utf8"));
|
|
1611
|
+
if (d.project || d.verdict) items.push({ type: "report", data: d, file: f });
|
|
1610
1612
|
} catch {}
|
|
1611
1613
|
}
|
|
1612
1614
|
}
|
|
1613
1615
|
} catch {}
|
|
1614
1616
|
|
|
1615
|
-
|
|
1617
|
+
// Collect from operational.jsonl (feedback log entries)
|
|
1618
|
+
const jsonlPath = path.join(fbDir, "operational.jsonl");
|
|
1619
|
+
try {
|
|
1620
|
+
if (fs.existsSync(jsonlPath)) {
|
|
1621
|
+
const lines = fs.readFileSync(jsonlPath, "utf8").trim().split("\n").filter(Boolean);
|
|
1622
|
+
for (const line of lines) {
|
|
1623
|
+
try { items.push({ type: "log", data: JSON.parse(line) }); } catch {}
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
} catch {}
|
|
1627
|
+
|
|
1628
|
+
if (!items.length) {
|
|
1629
|
+
log("no feedback found");
|
|
1630
|
+
console.log(` ${D}Log feedback first: 0dai feedback log --type suggestion --detail '...'${R}`);
|
|
1631
|
+
return;
|
|
1632
|
+
}
|
|
1616
1633
|
|
|
1617
|
-
//
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1634
|
+
// Push all items
|
|
1635
|
+
const report = {
|
|
1636
|
+
project: path.basename(target),
|
|
1637
|
+
entries: items.map(i => i.data),
|
|
1638
|
+
count: items.length,
|
|
1639
|
+
submitted_at: new Date().toISOString(),
|
|
1640
|
+
};
|
|
1641
|
+
log(`pushing ${items.length} feedback item(s)...`);
|
|
1642
|
+
const result = await apiCall("/v1/feedback", { report });
|
|
1643
|
+
if (result.received) {
|
|
1644
|
+
log(`received${result.issue ? `: ${result.issue}` : ""}`);
|
|
1645
|
+
if (result.bonus) log(`${T}bonus:${R} ${result.bonus}`);
|
|
1646
|
+
// Archive pushed entries
|
|
1647
|
+
if (fs.existsSync(jsonlPath)) {
|
|
1648
|
+
const archivePath = path.join(fbDir, `pushed-${Date.now()}.jsonl`);
|
|
1649
|
+
fs.renameSync(jsonlPath, archivePath);
|
|
1626
1650
|
}
|
|
1651
|
+
} else {
|
|
1652
|
+
log(`error: ${result.error || "unknown"}`);
|
|
1627
1653
|
}
|
|
1628
1654
|
}
|
|
1629
1655
|
|