md-annotator-opencode 0.5.7 → 0.6.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/annotator.html +334 -332
- package/dist/index.js +96 -31
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -42,7 +42,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
42
42
|
// ../../node_modules/depd/index.js
|
|
43
43
|
var require_depd = __commonJS({
|
|
44
44
|
"../../node_modules/depd/index.js"(exports, module) {
|
|
45
|
-
var
|
|
45
|
+
var relative3 = __require("path").relative;
|
|
46
46
|
module.exports = depd;
|
|
47
47
|
var basePath = process.cwd();
|
|
48
48
|
function containsNamespace(str, namespace) {
|
|
@@ -234,7 +234,7 @@ var require_depd = __commonJS({
|
|
|
234
234
|
return formatted;
|
|
235
235
|
}
|
|
236
236
|
function formatLocation(callSite) {
|
|
237
|
-
return
|
|
237
|
+
return relative3(basePath, callSite[0]) + ":" + callSite[1] + ":" + callSite[2];
|
|
238
238
|
}
|
|
239
239
|
function getStack() {
|
|
240
240
|
var limit = Error.stackTraceLimit;
|
|
@@ -19262,7 +19262,7 @@ var require_view = __commonJS({
|
|
|
19262
19262
|
var dirname4 = path2.dirname;
|
|
19263
19263
|
var basename = path2.basename;
|
|
19264
19264
|
var extname2 = path2.extname;
|
|
19265
|
-
var
|
|
19265
|
+
var join4 = path2.join;
|
|
19266
19266
|
var resolve3 = path2.resolve;
|
|
19267
19267
|
module.exports = View;
|
|
19268
19268
|
function View(name, options) {
|
|
@@ -19310,12 +19310,12 @@ var require_view = __commonJS({
|
|
|
19310
19310
|
};
|
|
19311
19311
|
View.prototype.resolve = function resolve4(dir2, file) {
|
|
19312
19312
|
var ext = this.ext;
|
|
19313
|
-
var path3 =
|
|
19313
|
+
var path3 = join4(dir2, file);
|
|
19314
19314
|
var stat = tryStat(path3);
|
|
19315
19315
|
if (stat && stat.isFile()) {
|
|
19316
19316
|
return path3;
|
|
19317
19317
|
}
|
|
19318
|
-
path3 =
|
|
19318
|
+
path3 = join4(dir2, basename(file, ext), "index" + ext);
|
|
19319
19319
|
stat = tryStat(path3);
|
|
19320
19320
|
if (stat && stat.isFile()) {
|
|
19321
19321
|
return path3;
|
|
@@ -20372,7 +20372,7 @@ var require_send = __commonJS({
|
|
|
20372
20372
|
var Stream = __require("stream");
|
|
20373
20373
|
var util = __require("util");
|
|
20374
20374
|
var extname2 = path2.extname;
|
|
20375
|
-
var
|
|
20375
|
+
var join4 = path2.join;
|
|
20376
20376
|
var normalize = path2.normalize;
|
|
20377
20377
|
var resolve3 = path2.resolve;
|
|
20378
20378
|
var sep = path2.sep;
|
|
@@ -20591,7 +20591,7 @@ var require_send = __commonJS({
|
|
|
20591
20591
|
return res;
|
|
20592
20592
|
}
|
|
20593
20593
|
parts = path3.split(sep);
|
|
20594
|
-
path3 = normalize(
|
|
20594
|
+
path3 = normalize(join4(root, path3));
|
|
20595
20595
|
} else {
|
|
20596
20596
|
if (UP_PATH_REGEXP.test(path3)) {
|
|
20597
20597
|
debug('malicious path "%s"', path3);
|
|
@@ -20726,7 +20726,7 @@ var require_send = __commonJS({
|
|
|
20726
20726
|
if (err) return self.onStatError(err);
|
|
20727
20727
|
return self.error(404);
|
|
20728
20728
|
}
|
|
20729
|
-
var p =
|
|
20729
|
+
var p = join4(path3, self._index[i]);
|
|
20730
20730
|
debug('stat "%s"', p);
|
|
20731
20731
|
fs6.stat(p, function(err2, stat) {
|
|
20732
20732
|
if (err2) return next(err2);
|
|
@@ -26930,7 +26930,7 @@ var require_portfinder = __commonJS({
|
|
|
26930
26930
|
// index.ts
|
|
26931
26931
|
import { tool } from "@opencode-ai/plugin";
|
|
26932
26932
|
import { readFileSync } from "fs";
|
|
26933
|
-
import { dirname as dirname3, join as
|
|
26933
|
+
import { dirname as dirname3, join as join3 } from "path";
|
|
26934
26934
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
26935
26935
|
|
|
26936
26936
|
// ../../server/annotator.js
|
|
@@ -26940,7 +26940,7 @@ var import_portfinder = __toESM(require_portfinder(), 1);
|
|
|
26940
26940
|
import { existsSync } from "fs";
|
|
26941
26941
|
import { createHash as createHash2 } from "crypto";
|
|
26942
26942
|
import { fileURLToPath } from "url";
|
|
26943
|
-
import { dirname as dirname2, join } from "path";
|
|
26943
|
+
import { dirname as dirname2, join as join2 } from "path";
|
|
26944
26944
|
|
|
26945
26945
|
// ../../server/config.js
|
|
26946
26946
|
var DEFAULT_PORT = 3e3;
|
|
@@ -26975,7 +26975,7 @@ var config = {
|
|
|
26975
26975
|
|
|
26976
26976
|
// ../../server/routes.js
|
|
26977
26977
|
var import_express = __toESM(require_express2(), 1);
|
|
26978
|
-
import { relative, resolve as resolve2, dirname, isAbsolute } from "path";
|
|
26978
|
+
import { relative as relative2, resolve as resolve2, dirname, isAbsolute } from "path";
|
|
26979
26979
|
import { createHash } from "crypto";
|
|
26980
26980
|
|
|
26981
26981
|
// ../../server/file.js
|
|
@@ -27074,7 +27074,7 @@ ${ann.originalText}
|
|
|
27074
27074
|
${ann.originalText}
|
|
27075
27075
|
\`\`\`
|
|
27076
27076
|
`;
|
|
27077
|
-
output += `> ${ann.text.replace(/\n/g, "\n> ")}
|
|
27077
|
+
output += `> ${(ann.text ?? "").replace(/\n/g, "\n> ")}
|
|
27078
27078
|
`;
|
|
27079
27079
|
} else if (ann.type === "INSERTION") {
|
|
27080
27080
|
output += `Insert text (${lineRef})
|
|
@@ -27084,7 +27084,7 @@ ${ann.originalText}
|
|
|
27084
27084
|
`;
|
|
27085
27085
|
}
|
|
27086
27086
|
output += `\`\`\`
|
|
27087
|
-
${ann.text}
|
|
27087
|
+
${ann.text ?? ""}
|
|
27088
27088
|
\`\`\`
|
|
27089
27089
|
`;
|
|
27090
27090
|
output += `> User wants this text inserted at this point in the document.
|
|
@@ -27182,6 +27182,63 @@ function exportFeedback(annotations, blocks) {
|
|
|
27182
27182
|
return output;
|
|
27183
27183
|
}
|
|
27184
27184
|
|
|
27185
|
+
// ../../server/workspace.js
|
|
27186
|
+
import { execFile } from "child_process";
|
|
27187
|
+
import { readdir } from "fs/promises";
|
|
27188
|
+
import { relative, join } from "path";
|
|
27189
|
+
var MAX_FILES = 5e3;
|
|
27190
|
+
var EXCLUDE_DIRS = /* @__PURE__ */ new Set([
|
|
27191
|
+
"node_modules",
|
|
27192
|
+
".git",
|
|
27193
|
+
"dist",
|
|
27194
|
+
"build",
|
|
27195
|
+
"coverage",
|
|
27196
|
+
"__pycache__",
|
|
27197
|
+
".next",
|
|
27198
|
+
".cache",
|
|
27199
|
+
".turbo",
|
|
27200
|
+
".output"
|
|
27201
|
+
]);
|
|
27202
|
+
function gitListFiles(cwd) {
|
|
27203
|
+
return new Promise((resolve3, reject2) => {
|
|
27204
|
+
execFile("git", ["ls-files"], { cwd, maxBuffer: 10 * 1024 * 1024, timeout: 1e4 }, (err, stdout) => {
|
|
27205
|
+
if (err) {
|
|
27206
|
+
return reject2(err);
|
|
27207
|
+
}
|
|
27208
|
+
const files = stdout.split("\n").filter(Boolean);
|
|
27209
|
+
resolve3(files.slice(0, MAX_FILES));
|
|
27210
|
+
});
|
|
27211
|
+
});
|
|
27212
|
+
}
|
|
27213
|
+
async function fallbackListFiles(cwd) {
|
|
27214
|
+
const entries = await readdir(cwd, { recursive: true, withFileTypes: true });
|
|
27215
|
+
const files = [];
|
|
27216
|
+
for (const entry of entries) {
|
|
27217
|
+
if (!entry.isFile()) {
|
|
27218
|
+
continue;
|
|
27219
|
+
}
|
|
27220
|
+
const parentPath = entry.parentPath || entry.path;
|
|
27221
|
+
const rel = relative(cwd, join(parentPath, entry.name));
|
|
27222
|
+
const parts = rel.split("/");
|
|
27223
|
+
if (parts.some((p) => EXCLUDE_DIRS.has(p))) {
|
|
27224
|
+
continue;
|
|
27225
|
+
}
|
|
27226
|
+
files.push(rel);
|
|
27227
|
+
if (files.length >= MAX_FILES) {
|
|
27228
|
+
break;
|
|
27229
|
+
}
|
|
27230
|
+
}
|
|
27231
|
+
return files.sort();
|
|
27232
|
+
}
|
|
27233
|
+
async function listWorkspaceFiles() {
|
|
27234
|
+
const cwd = process.cwd();
|
|
27235
|
+
try {
|
|
27236
|
+
return await gitListFiles(cwd);
|
|
27237
|
+
} catch {
|
|
27238
|
+
return await fallbackListFiles(cwd);
|
|
27239
|
+
}
|
|
27240
|
+
}
|
|
27241
|
+
|
|
27185
27242
|
// ../../server/routes.js
|
|
27186
27243
|
function success(data) {
|
|
27187
27244
|
return { success: true, data };
|
|
@@ -27191,12 +27248,20 @@ function failure(error) {
|
|
|
27191
27248
|
}
|
|
27192
27249
|
function createApiRouter(filePaths, resolveDecision, origin = "cli", stores = []) {
|
|
27193
27250
|
const router = (0, import_express.Router)();
|
|
27251
|
+
router.get("/api/workspace/files", async (_req, res) => {
|
|
27252
|
+
try {
|
|
27253
|
+
const files = await listWorkspaceFiles();
|
|
27254
|
+
res.json(success({ files }));
|
|
27255
|
+
} catch (error) {
|
|
27256
|
+
res.status(500).json(failure(error.message));
|
|
27257
|
+
}
|
|
27258
|
+
});
|
|
27194
27259
|
router.get("/api/files", async (_req, res) => {
|
|
27195
27260
|
try {
|
|
27196
27261
|
const files = await Promise.all(
|
|
27197
27262
|
stores.map(async (store, index2) => {
|
|
27198
27263
|
const content = await readMarkdownFile(store.absolutePath);
|
|
27199
|
-
const relativePath =
|
|
27264
|
+
const relativePath = relative2(process.cwd(), store.absolutePath) || store.absolutePath;
|
|
27200
27265
|
const currentHash = createHash("sha256").update(content).digest("hex");
|
|
27201
27266
|
return {
|
|
27202
27267
|
index: index2,
|
|
@@ -27216,7 +27281,7 @@ function createApiRouter(filePaths, resolveDecision, origin = "cli", stores = []
|
|
|
27216
27281
|
var _a;
|
|
27217
27282
|
try {
|
|
27218
27283
|
const content = await readMarkdownFile(filePaths[0]);
|
|
27219
|
-
const relativePath =
|
|
27284
|
+
const relativePath = relative2(process.cwd(), filePaths[0]) || filePaths[0];
|
|
27220
27285
|
res.json(success({
|
|
27221
27286
|
content,
|
|
27222
27287
|
path: relativePath,
|
|
@@ -27235,7 +27300,7 @@ function createApiRouter(filePaths, resolveDecision, origin = "cli", stores = []
|
|
|
27235
27300
|
}
|
|
27236
27301
|
const referenceDir = relativeTo ? dirname(resolve2(baseDir, relativeTo)) : dirname(filePaths[0]);
|
|
27237
27302
|
const absolutePath = resolve2(referenceDir, requestedPath);
|
|
27238
|
-
const rel =
|
|
27303
|
+
const rel = relative2(baseDir, absolutePath);
|
|
27239
27304
|
if (rel.startsWith("..") || rel === "" || isAbsolute(rel)) {
|
|
27240
27305
|
return res.status(403).json(failure("Access denied: path outside project directory"));
|
|
27241
27306
|
}
|
|
@@ -27245,7 +27310,7 @@ function createApiRouter(filePaths, resolveDecision, origin = "cli", stores = []
|
|
|
27245
27310
|
try {
|
|
27246
27311
|
const content = await readMarkdownFile(absolutePath);
|
|
27247
27312
|
const contentHash = createHash("sha256").update(content).digest("hex");
|
|
27248
|
-
const relativePath =
|
|
27313
|
+
const relativePath = relative2(baseDir, absolutePath) || absolutePath;
|
|
27249
27314
|
let fileIndex = stores.findIndex((s) => s.absolutePath === absolutePath);
|
|
27250
27315
|
if (fileIndex === -1) {
|
|
27251
27316
|
stores.push({ absolutePath, contentHash, annotations: [] });
|
|
@@ -27414,7 +27479,7 @@ function parseMarkdownToBlocks(markdown) {
|
|
|
27414
27479
|
});
|
|
27415
27480
|
continue;
|
|
27416
27481
|
}
|
|
27417
|
-
if (trimmed
|
|
27482
|
+
if (/^([-*_])\s*(\1\s*){2,}$/.test(trimmed)) {
|
|
27418
27483
|
flush();
|
|
27419
27484
|
blocks.push({
|
|
27420
27485
|
id: `block-${currentId++}`,
|
|
@@ -27666,8 +27731,8 @@ function findBlockForLine(blocks, line) {
|
|
|
27666
27731
|
|
|
27667
27732
|
// ../../server/annotator.js
|
|
27668
27733
|
var __dirname = dirname2(fileURLToPath(import.meta.url));
|
|
27669
|
-
var DIST_PATH =
|
|
27670
|
-
var DEV_PATH =
|
|
27734
|
+
var DIST_PATH = join2(__dirname, "..", "client", "dist");
|
|
27735
|
+
var DEV_PATH = join2(__dirname, "..", "client");
|
|
27671
27736
|
function resolveNotesForFile(feedbackNotes, fileIndex, content) {
|
|
27672
27737
|
if (!Array.isArray(feedbackNotes) || fileIndex !== 0) {
|
|
27673
27738
|
return [];
|
|
@@ -27916,13 +27981,13 @@ function defineLazyProperty(object, propertyName, valueGetter) {
|
|
|
27916
27981
|
// ../../node_modules/default-browser/index.js
|
|
27917
27982
|
import { promisify as promisify4 } from "util";
|
|
27918
27983
|
import process6 from "process";
|
|
27919
|
-
import { execFile as
|
|
27984
|
+
import { execFile as execFile5 } from "child_process";
|
|
27920
27985
|
|
|
27921
27986
|
// ../../node_modules/default-browser-id/index.js
|
|
27922
27987
|
import { promisify } from "util";
|
|
27923
27988
|
import process4 from "process";
|
|
27924
|
-
import { execFile } from "child_process";
|
|
27925
|
-
var execFileAsync = promisify(
|
|
27989
|
+
import { execFile as execFile2 } from "child_process";
|
|
27990
|
+
var execFileAsync = promisify(execFile2);
|
|
27926
27991
|
async function defaultBrowserId() {
|
|
27927
27992
|
if (process4.platform !== "darwin") {
|
|
27928
27993
|
throw new Error("macOS only");
|
|
@@ -27939,8 +28004,8 @@ async function defaultBrowserId() {
|
|
|
27939
28004
|
// ../../node_modules/run-applescript/index.js
|
|
27940
28005
|
import process5 from "process";
|
|
27941
28006
|
import { promisify as promisify2 } from "util";
|
|
27942
|
-
import { execFile as
|
|
27943
|
-
var execFileAsync2 = promisify2(
|
|
28007
|
+
import { execFile as execFile3, execFileSync } from "child_process";
|
|
28008
|
+
var execFileAsync2 = promisify2(execFile3);
|
|
27944
28009
|
async function runAppleScript(script, { humanReadableOutput = true, signal } = {}) {
|
|
27945
28010
|
if (process5.platform !== "darwin") {
|
|
27946
28011
|
throw new Error("macOS only");
|
|
@@ -27962,8 +28027,8 @@ tell application "System Events" to get value of property list item "CFBundleNam
|
|
|
27962
28027
|
|
|
27963
28028
|
// ../../node_modules/default-browser/windows.js
|
|
27964
28029
|
import { promisify as promisify3 } from "util";
|
|
27965
|
-
import { execFile as
|
|
27966
|
-
var execFileAsync3 = promisify3(
|
|
28030
|
+
import { execFile as execFile4 } from "child_process";
|
|
28031
|
+
var execFileAsync3 = promisify3(execFile4);
|
|
27967
28032
|
var windowsBrowserProgIds = {
|
|
27968
28033
|
MSEdgeHTM: { name: "Edge", id: "com.microsoft.edge" },
|
|
27969
28034
|
// The missing `L` is correct.
|
|
@@ -28006,7 +28071,7 @@ async function defaultBrowser(_execFileAsync = execFileAsync3) {
|
|
|
28006
28071
|
}
|
|
28007
28072
|
|
|
28008
28073
|
// ../../node_modules/default-browser/index.js
|
|
28009
|
-
var execFileAsync4 = promisify4(
|
|
28074
|
+
var execFileAsync4 = promisify4(execFile5);
|
|
28010
28075
|
var titleize = (string) => string.toLowerCase().replaceAll(/(?:^|\s|-)\S/g, (x) => x.toUpperCase());
|
|
28011
28076
|
async function defaultBrowser2() {
|
|
28012
28077
|
if (process6.platform === "darwin") {
|
|
@@ -28027,7 +28092,7 @@ async function defaultBrowser2() {
|
|
|
28027
28092
|
}
|
|
28028
28093
|
|
|
28029
28094
|
// ../../node_modules/open/index.js
|
|
28030
|
-
var
|
|
28095
|
+
var execFile6 = promisify5(childProcess.execFile);
|
|
28031
28096
|
var __dirname2 = path.dirname(fileURLToPath2(import.meta.url));
|
|
28032
28097
|
var localXdgOpenPath = path.join(__dirname2, "xdg-open");
|
|
28033
28098
|
var { platform, arch } = process7;
|
|
@@ -28035,7 +28100,7 @@ async function getWindowsDefaultBrowserFromWsl() {
|
|
|
28035
28100
|
const powershellPath = await powerShellPath();
|
|
28036
28101
|
const rawCommand = String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`;
|
|
28037
28102
|
const encodedCommand = Buffer2.from(rawCommand, "utf16le").toString("base64");
|
|
28038
|
-
const { stdout } = await
|
|
28103
|
+
const { stdout } = await execFile6(
|
|
28039
28104
|
powershellPath,
|
|
28040
28105
|
[
|
|
28041
28106
|
"-NoProfile",
|
|
@@ -28294,7 +28359,7 @@ async function openBrowser(url) {
|
|
|
28294
28359
|
|
|
28295
28360
|
// index.ts
|
|
28296
28361
|
var __dirname3 = dirname3(fileURLToPath3(import.meta.url));
|
|
28297
|
-
var htmlContent = readFileSync(
|
|
28362
|
+
var htmlContent = readFileSync(join3(__dirname3, "..", "annotator.html"), "utf-8");
|
|
28298
28363
|
var sleep = (ms) => new Promise((resolve3) => setTimeout(resolve3, ms));
|
|
28299
28364
|
var MdAnnotatorPlugin = async (ctx) => {
|
|
28300
28365
|
return {
|