open-research 0.1.24 → 0.1.25
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.js +21 -111
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -8,7 +8,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
8
8
|
|
|
9
9
|
// src/cli.ts
|
|
10
10
|
import React5 from "react";
|
|
11
|
-
import
|
|
11
|
+
import path21 from "path";
|
|
12
12
|
import { Command } from "commander";
|
|
13
13
|
import { render } from "ink";
|
|
14
14
|
|
|
@@ -811,7 +811,7 @@ function formatDateTime(value) {
|
|
|
811
811
|
}
|
|
812
812
|
|
|
813
813
|
// src/lib/cli/version.ts
|
|
814
|
-
var PACKAGE_VERSION = "0.1.
|
|
814
|
+
var PACKAGE_VERSION = "0.1.25";
|
|
815
815
|
function getPackageVersion() {
|
|
816
816
|
return PACKAGE_VERSION;
|
|
817
817
|
}
|
|
@@ -871,7 +871,7 @@ async function ensureOpenResearchConfig(options) {
|
|
|
871
871
|
}
|
|
872
872
|
|
|
873
873
|
// src/tui/app.tsx
|
|
874
|
-
import
|
|
874
|
+
import path20 from "path";
|
|
875
875
|
import {
|
|
876
876
|
startTransition,
|
|
877
877
|
useDeferredValue,
|
|
@@ -6617,88 +6617,9 @@ function truncate3(value, max = 96) {
|
|
|
6617
6617
|
import { Box as Box4, Text as Text4 } from "ink";
|
|
6618
6618
|
|
|
6619
6619
|
// src/tui/markdown.ts
|
|
6620
|
-
import path20 from "path";
|
|
6621
|
-
import fs21 from "fs";
|
|
6622
|
-
import { pathToFileURL } from "url";
|
|
6623
|
-
var FILE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
6624
|
-
".py",
|
|
6625
|
-
".ts",
|
|
6626
|
-
".tsx",
|
|
6627
|
-
".js",
|
|
6628
|
-
".jsx",
|
|
6629
|
-
".r",
|
|
6630
|
-
".R",
|
|
6631
|
-
".tex",
|
|
6632
|
-
".bib",
|
|
6633
|
-
".md",
|
|
6634
|
-
".txt",
|
|
6635
|
-
".json",
|
|
6636
|
-
".yaml",
|
|
6637
|
-
".yml",
|
|
6638
|
-
".toml",
|
|
6639
|
-
".csv",
|
|
6640
|
-
".tsv",
|
|
6641
|
-
".sh",
|
|
6642
|
-
".bash",
|
|
6643
|
-
".zsh",
|
|
6644
|
-
".sql",
|
|
6645
|
-
".html",
|
|
6646
|
-
".css",
|
|
6647
|
-
".xml",
|
|
6648
|
-
".pdf",
|
|
6649
|
-
".png",
|
|
6650
|
-
".jpg",
|
|
6651
|
-
".svg",
|
|
6652
|
-
".gif",
|
|
6653
|
-
".cfg",
|
|
6654
|
-
".ini",
|
|
6655
|
-
".env",
|
|
6656
|
-
".lock",
|
|
6657
|
-
".log"
|
|
6658
|
-
]);
|
|
6659
|
-
var linkCache = /* @__PURE__ */ new Map();
|
|
6660
|
-
var LOCATION_SUFFIX_RE = /^(.*?)(:\d+(?::\d+)?)$/;
|
|
6661
|
-
function splitLocation(text) {
|
|
6662
|
-
const trimmed = text.trim();
|
|
6663
|
-
const match = trimmed.match(LOCATION_SUFFIX_RE);
|
|
6664
|
-
if (match && match[1]) {
|
|
6665
|
-
return { filePath: match[1], location: match[2] };
|
|
6666
|
-
}
|
|
6667
|
-
return { filePath: trimmed, location: "" };
|
|
6668
|
-
}
|
|
6669
|
-
function looksLikeFilePath(text) {
|
|
6670
|
-
const { filePath } = splitLocation(text);
|
|
6671
|
-
if (filePath.length < 3 || filePath.length > 260) return false;
|
|
6672
|
-
if (filePath.includes("\n")) return false;
|
|
6673
|
-
if (/^[a-z]+:\/\//i.test(filePath)) return false;
|
|
6674
|
-
const ext = path20.extname(filePath).toLowerCase();
|
|
6675
|
-
if (FILE_EXTENSIONS.has(ext)) return true;
|
|
6676
|
-
if (filePath.includes("/") || filePath.includes("\\")) return true;
|
|
6677
|
-
return false;
|
|
6678
|
-
}
|
|
6679
|
-
function fileLink(displayText, rawText, baseDir) {
|
|
6680
|
-
const { filePath } = splitLocation(rawText);
|
|
6681
|
-
const candidate = path20.isAbsolute(filePath) ? filePath : path20.resolve(baseDir, filePath);
|
|
6682
|
-
let resolved = linkCache.get(candidate);
|
|
6683
|
-
if (resolved === void 0) {
|
|
6684
|
-
try {
|
|
6685
|
-
resolved = fs21.realpathSync(candidate);
|
|
6686
|
-
} catch {
|
|
6687
|
-
resolved = null;
|
|
6688
|
-
}
|
|
6689
|
-
linkCache.set(candidate, resolved);
|
|
6690
|
-
}
|
|
6691
|
-
if (!resolved) return displayText;
|
|
6692
|
-
const uri = pathToFileURL(resolved).href;
|
|
6693
|
-
return `\x1B]8;;${uri}\x1B\\${displayText}\x1B]8;;\x1B\\`;
|
|
6694
|
-
}
|
|
6695
|
-
var BARE_PATH_RE = /((?:\.{1,2}\/|\/)[^\s`),;\]]+\.[a-zA-Z0-9]{1,6})/g;
|
|
6696
6620
|
function renderMarkdown(text, options = {}) {
|
|
6697
6621
|
if (!text || !text.trim()) return text;
|
|
6698
|
-
|
|
6699
|
-
if (!/[*_`#\[\]>~\-]/.test(text) && !text.includes("```") && !BARE_PATH_RE.test(text)) {
|
|
6700
|
-
return text;
|
|
6701
|
-
}
|
|
6622
|
+
if (!/[*_`#\[\]>~\-]/.test(text) && !text.includes("```")) return text;
|
|
6702
6623
|
const lines = text.split("\n");
|
|
6703
6624
|
const output2 = [];
|
|
6704
6625
|
let inCodeBlock = false;
|
|
@@ -6731,7 +6652,7 @@ function renderMarkdown(text, options = {}) {
|
|
|
6731
6652
|
const headingMatch = line.match(/^(#{1,6})\s+(.+)$/);
|
|
6732
6653
|
if (headingMatch) {
|
|
6733
6654
|
const level = headingMatch[1].length;
|
|
6734
|
-
const content = renderInline(headingMatch[2]
|
|
6655
|
+
const content = renderInline(headingMatch[2]);
|
|
6735
6656
|
if (level === 1) output2.push(source_default.bold.cyan(content));
|
|
6736
6657
|
else if (level === 2) output2.push(source_default.bold.white(content));
|
|
6737
6658
|
else output2.push(source_default.bold(content));
|
|
@@ -6742,21 +6663,21 @@ function renderMarkdown(text, options = {}) {
|
|
|
6742
6663
|
continue;
|
|
6743
6664
|
}
|
|
6744
6665
|
if (line.trimStart().startsWith("> ")) {
|
|
6745
|
-
const content = renderInline(line.replace(/^\s*>\s?/, "")
|
|
6666
|
+
const content = renderInline(line.replace(/^\s*>\s?/, ""));
|
|
6746
6667
|
output2.push(source_default.gray("\u2502 ") + source_default.italic(content));
|
|
6747
6668
|
continue;
|
|
6748
6669
|
}
|
|
6749
6670
|
const ulMatch = line.match(/^(\s*)[*+-]\s+(.+)$/);
|
|
6750
6671
|
if (ulMatch) {
|
|
6751
|
-
output2.push(`${ulMatch[1]}${source_default.gray("\u2022")} ${renderInline(ulMatch[2]
|
|
6672
|
+
output2.push(`${ulMatch[1]}${source_default.gray("\u2022")} ${renderInline(ulMatch[2])}`);
|
|
6752
6673
|
continue;
|
|
6753
6674
|
}
|
|
6754
6675
|
const olMatch = line.match(/^(\s*)(\d+)[.)]\s+(.+)$/);
|
|
6755
6676
|
if (olMatch) {
|
|
6756
|
-
output2.push(`${olMatch[1]}${source_default.gray(olMatch[2] + ".")} ${renderInline(olMatch[3]
|
|
6677
|
+
output2.push(`${olMatch[1]}${source_default.gray(olMatch[2] + ".")} ${renderInline(olMatch[3])}`);
|
|
6757
6678
|
continue;
|
|
6758
6679
|
}
|
|
6759
|
-
output2.push(renderInline(line
|
|
6680
|
+
output2.push(renderInline(line));
|
|
6760
6681
|
}
|
|
6761
6682
|
if (inCodeBlock && codeBlockLines.length > 0) {
|
|
6762
6683
|
output2.push(source_default.gray("\u250C" + "\u2500".repeat(40)));
|
|
@@ -6767,14 +6688,9 @@ function renderMarkdown(text, options = {}) {
|
|
|
6767
6688
|
}
|
|
6768
6689
|
return output2.join("\n");
|
|
6769
6690
|
}
|
|
6770
|
-
function renderInline(text
|
|
6691
|
+
function renderInline(text) {
|
|
6771
6692
|
let result = text;
|
|
6772
|
-
result = result.replace(/`([^`]+)`/g, (_, code) =>
|
|
6773
|
-
if (looksLikeFilePath(code)) {
|
|
6774
|
-
return fileLink(source_default.cyan.underline(code), code, baseDir);
|
|
6775
|
-
}
|
|
6776
|
-
return source_default.cyan(code);
|
|
6777
|
-
});
|
|
6693
|
+
result = result.replace(/`([^`]+)`/g, (_, code) => source_default.cyan(code));
|
|
6778
6694
|
result = result.replace(/\*\*\*(.+?)\*\*\*/g, (_, t) => source_default.bold.italic(t));
|
|
6779
6695
|
result = result.replace(/___(.+?)___/g, (_, t) => source_default.bold.italic(t));
|
|
6780
6696
|
result = result.replace(/\*\*(.+?)\*\*/g, (_, t) => source_default.bold(t));
|
|
@@ -6786,12 +6702,6 @@ function renderInline(text, baseDir) {
|
|
|
6786
6702
|
/\[([^\]]+)\]\(([^)]+)\)/g,
|
|
6787
6703
|
(_, label, url) => source_default.blue(label) + source_default.gray.dim(` (${url})`)
|
|
6788
6704
|
);
|
|
6789
|
-
result = result.replace(BARE_PATH_RE, (match) => {
|
|
6790
|
-
if (looksLikeFilePath(match)) {
|
|
6791
|
-
return fileLink(source_default.cyan.underline(match), match, baseDir);
|
|
6792
|
-
}
|
|
6793
|
-
return match;
|
|
6794
|
-
});
|
|
6795
6705
|
return result;
|
|
6796
6706
|
}
|
|
6797
6707
|
|
|
@@ -6820,8 +6730,8 @@ function UserMessage({ text }) {
|
|
|
6820
6730
|
/* @__PURE__ */ jsx4(Box4, { marginLeft: 2, children: /* @__PURE__ */ jsx4(Text4, { children: text }) })
|
|
6821
6731
|
] });
|
|
6822
6732
|
}
|
|
6823
|
-
function AgentMessage({ text
|
|
6824
|
-
const rendered = renderMarkdown(text
|
|
6733
|
+
function AgentMessage({ text }) {
|
|
6734
|
+
const rendered = renderMarkdown(text);
|
|
6825
6735
|
return /* @__PURE__ */ jsxs3(Box4, { flexDirection: "column", marginBottom: 1, children: [
|
|
6826
6736
|
/* @__PURE__ */ jsxs3(Box4, { children: [
|
|
6827
6737
|
/* @__PURE__ */ jsxs3(Text4, { color: "green", bold: true, children: [
|
|
@@ -8324,7 +8234,7 @@ ${error.stack}` : String(error)}` }
|
|
|
8324
8234
|
if (msg.role === "user") {
|
|
8325
8235
|
return /* @__PURE__ */ jsx5(UserMessage, { text: msg.text }, `msg-${idx}`);
|
|
8326
8236
|
}
|
|
8327
|
-
return /* @__PURE__ */ jsx5(AgentMessage, { text: msg.text
|
|
8237
|
+
return /* @__PURE__ */ jsx5(AgentMessage, { text: msg.text }, `msg-${idx}`);
|
|
8328
8238
|
}) }),
|
|
8329
8239
|
deferredPendingUpdates.length > 0 && /* @__PURE__ */ jsx5(
|
|
8330
8240
|
PendingUpdateCard,
|
|
@@ -8445,7 +8355,7 @@ ${error.stack}` : String(error)}` }
|
|
|
8445
8355
|
statusParts,
|
|
8446
8356
|
statusColor,
|
|
8447
8357
|
tokenDisplay,
|
|
8448
|
-
workspaceName: hasWorkspace ?
|
|
8358
|
+
workspaceName: hasWorkspace ? path20.basename(workspacePath) : process.cwd(),
|
|
8449
8359
|
mode: agentMode,
|
|
8450
8360
|
planningStatus: planningState.status
|
|
8451
8361
|
}
|
|
@@ -8457,7 +8367,7 @@ ${error.stack}` : String(error)}` }
|
|
|
8457
8367
|
var program = new Command();
|
|
8458
8368
|
program.name("open-research").version(getPackageVersion()).description("Local-first research CLI powered by ChatGPT/Codex auth.").argument("[workspacePath]", "Optional workspace path to open").action(async (workspacePath) => {
|
|
8459
8369
|
await ensureOpenResearchConfig();
|
|
8460
|
-
const target = workspacePath ?
|
|
8370
|
+
const target = workspacePath ? path21.resolve(workspacePath) : process.cwd();
|
|
8461
8371
|
const project = await loadWorkspaceProject(target);
|
|
8462
8372
|
const auth2 = await loadStoredAuth();
|
|
8463
8373
|
render(
|
|
@@ -8474,7 +8384,7 @@ program.name("open-research").version(getPackageVersion()).description("Local-fi
|
|
|
8474
8384
|
});
|
|
8475
8385
|
program.command("init").argument("[workspacePath]").description("Initialize an Open Research workspace.").action(async (workspacePath) => {
|
|
8476
8386
|
await ensureOpenResearchConfig();
|
|
8477
|
-
const target =
|
|
8387
|
+
const target = path21.resolve(workspacePath ?? process.cwd());
|
|
8478
8388
|
const project = await initWorkspace({ workspaceDir: target });
|
|
8479
8389
|
console.log(`Initialized workspace: ${target}`);
|
|
8480
8390
|
console.log(`Title: ${project.title}`);
|
|
@@ -8543,8 +8453,8 @@ skills.command("create").argument("[name]").description("Scaffold a new user ski
|
|
|
8543
8453
|
});
|
|
8544
8454
|
skills.command("edit").argument("<name>").description("Open a user skill in $EDITOR.").action(async (name) => {
|
|
8545
8455
|
await ensureOpenResearchConfig();
|
|
8546
|
-
const skillDir =
|
|
8547
|
-
openInEditor(
|
|
8456
|
+
const skillDir = path21.join(getOpenResearchSkillsDir(), name);
|
|
8457
|
+
openInEditor(path21.join(skillDir, "SKILL.md"));
|
|
8548
8458
|
const validation = await validateSkillDirectory({ skillDir });
|
|
8549
8459
|
if (!validation.ok) {
|
|
8550
8460
|
console.error(validation.errors.join("\n"));
|
|
@@ -8555,9 +8465,9 @@ skills.command("edit").argument("<name>").description("Open a user skill in $EDI
|
|
|
8555
8465
|
});
|
|
8556
8466
|
skills.command("validate").argument("[nameOrPath]").description("Validate one user skill.").action(async (nameOrPath) => {
|
|
8557
8467
|
await ensureOpenResearchConfig();
|
|
8558
|
-
const skillDir = nameOrPath ?
|
|
8468
|
+
const skillDir = nameOrPath ? path21.isAbsolute(nameOrPath) ? nameOrPath : path21.join(getOpenResearchSkillsDir(), nameOrPath) : getOpenResearchSkillsDir();
|
|
8559
8469
|
const stat = await import("fs/promises").then(
|
|
8560
|
-
(
|
|
8470
|
+
(fs21) => fs21.stat(skillDir).catch(() => null)
|
|
8561
8471
|
);
|
|
8562
8472
|
if (!stat) {
|
|
8563
8473
|
throw new Error(`Skill path not found: ${skillDir}`);
|
package/package.json
CHANGED