@mrsf/cli 0.4.1 → 0.4.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/dist/browser.d.ts CHANGED
@@ -1,4 +1,17 @@
1
+ import * as fuzzy from "./lib/fuzzy.js";
2
+ import * as reanchorCore from "./lib/reanchor-core.js";
1
3
  export type { Comment, DiffHunk, FuzzyCandidate, MrsfDocument, ReanchorResult, ReanchorStatus, } from "./lib/types.js";
2
- export { combinedScore, exactMatch, fuzzySearch, levenshteinScore, normalizedMatch, tokenLcsScore, } from "./lib/fuzzy.js";
3
- export { applyReanchorResults, DEFAULT_THRESHOLD, HIGH_THRESHOLD, reanchorComment, reanchorDocumentLines, reanchorDocumentText, toReanchorLines, } from "./lib/reanchor-core.js";
4
+ export declare const combinedScore: typeof fuzzy.combinedScore;
5
+ export declare const exactMatch: typeof fuzzy.exactMatch;
6
+ export declare const fuzzySearch: typeof fuzzy.fuzzySearch;
7
+ export declare const levenshteinScore: typeof fuzzy.levenshteinScore;
8
+ export declare const normalizedMatch: typeof fuzzy.normalizedMatch;
9
+ export declare const tokenLcsScore: typeof fuzzy.tokenLcsScore;
10
+ export declare const applyReanchorResults: typeof reanchorCore.applyReanchorResults;
11
+ export declare const DEFAULT_THRESHOLD = 0.6;
12
+ export declare const HIGH_THRESHOLD = 0.8;
13
+ export declare const reanchorComment: typeof reanchorCore.reanchorComment;
14
+ export declare const reanchorDocumentLines: typeof reanchorCore.reanchorDocumentLines;
15
+ export declare const reanchorDocumentText: typeof reanchorCore.reanchorDocumentText;
16
+ export declare const toReanchorLines: typeof reanchorCore.toReanchorLines;
4
17
  //# sourceMappingURL=browser.d.ts.map
package/dist/browser.js CHANGED
@@ -1,3 +1,16 @@
1
- export { combinedScore, exactMatch, fuzzySearch, levenshteinScore, normalizedMatch, tokenLcsScore, } from "./lib/fuzzy.js";
2
- export { applyReanchorResults, DEFAULT_THRESHOLD, HIGH_THRESHOLD, reanchorComment, reanchorDocumentLines, reanchorDocumentText, toReanchorLines, } from "./lib/reanchor-core.js";
1
+ import * as fuzzy from "./lib/fuzzy.js";
2
+ import * as reanchorCore from "./lib/reanchor-core.js";
3
+ export const combinedScore = fuzzy.combinedScore;
4
+ export const exactMatch = fuzzy.exactMatch;
5
+ export const fuzzySearch = fuzzy.fuzzySearch;
6
+ export const levenshteinScore = fuzzy.levenshteinScore;
7
+ export const normalizedMatch = fuzzy.normalizedMatch;
8
+ export const tokenLcsScore = fuzzy.tokenLcsScore;
9
+ export const applyReanchorResults = reanchorCore.applyReanchorResults;
10
+ export const DEFAULT_THRESHOLD = reanchorCore.DEFAULT_THRESHOLD;
11
+ export const HIGH_THRESHOLD = reanchorCore.HIGH_THRESHOLD;
12
+ export const reanchorComment = reanchorCore.reanchorComment;
13
+ export const reanchorDocumentLines = reanchorCore.reanchorDocumentLines;
14
+ export const reanchorDocumentText = reanchorCore.reanchorDocumentText;
15
+ export const toReanchorLines = reanchorCore.toReanchorLines;
3
16
  //# sourceMappingURL=browser.js.map
@@ -28,17 +28,19 @@ export function registerInit(program) {
28
28
  const root = await findWorkspaceRoot(cwd);
29
29
  const sidecarPath = await discoverSidecar(docPath, { cwd: root ?? cwd });
30
30
  // Check if sidecar already exists
31
+ let sidecarExists = false;
31
32
  try {
32
33
  await fs.access(sidecarPath);
33
- if (!opts.force) {
34
- console.error(chalk.yellow(`Sidecar already exists: ${sidecarPath}`));
35
- console.error("Use --force to overwrite.");
36
- process.exit(1);
37
- }
34
+ sidecarExists = true;
38
35
  }
39
36
  catch {
40
37
  // Good — doesn't exist yet
41
38
  }
39
+ if (sidecarExists && !opts.force) {
40
+ console.error(chalk.yellow(`Sidecar already exists: ${sidecarPath}`));
41
+ console.error("Use --force to overwrite.");
42
+ process.exit(1);
43
+ }
42
44
  const doc = {
43
45
  mrsf_version: "1.0",
44
46
  document: path.basename(docPath),
package/dist/index.d.ts CHANGED
@@ -4,16 +4,67 @@
4
4
  * Usage:
5
5
  * import { validate, reanchorFile, addComment, ... } from "mrsf";
6
6
  */
7
- export type { MrsfDocument, Comment, CommentExtensions, CommentExtensionValue, MrsfConfig, DiagnosticSeverity, ValidationDiagnostic, ValidationResult, ReanchorStatus, ReanchorResult, FuzzyCandidate, DiffHunk, AddCommentOptions, CommentFilter, AnchorHealth, StatusResult, BaseOptions, ReanchorOptions, ValidateOptions, } from "./lib/types.js";
8
- export { findWorkspaceRoot, loadConfig, discoverSidecar, sidecarToDocument, discoverAllSidecars, } from "./lib/discovery.js";
9
- export { resolveSidecarPaths } from "./lib/resolve-files.js";
10
- export { parseSidecar, parseSidecarContent, parseSidecarLenient, parseSidecarContentLenient, readDocumentLines, } from "./lib/parser.js";
7
+ import * as discovery from "./lib/discovery.js";
8
+ import * as resolveFiles from "./lib/resolve-files.js";
9
+ import * as parser from "./lib/parser.js";
10
+ import * as writer from "./lib/writer.js";
11
+ import * as validator from "./lib/validator.js";
12
+ import * as fuzzy from "./lib/fuzzy.js";
13
+ import * as git from "./lib/git.js";
14
+ import * as reanchor from "./lib/reanchor.js";
15
+ import * as comments from "./lib/comments.js";
16
+ export type { MrsfDocument, Comment, CommentExtensions, CommentExtensionValue, MrsfConfig, DiagnosticSeverity, ValidationDiagnostic, ValidationResult, ReanchorStatus, ReanchorResult, FuzzyCandidate, DiffHunk, AddCommentOptions, EditCommentOptions, CommentFilter, AnchorHealth, StatusResult, BaseOptions, ReanchorOptions, ValidateOptions, } from "./lib/types.js";
17
+ export declare const findWorkspaceRoot: typeof discovery.findWorkspaceRoot;
18
+ export declare const loadConfig: typeof discovery.loadConfig;
19
+ export declare const discoverSidecar: typeof discovery.discoverSidecar;
20
+ export declare const sidecarToDocument: typeof discovery.sidecarToDocument;
21
+ export declare const discoverAllSidecars: typeof discovery.discoverAllSidecars;
22
+ export declare const resolveSidecarPaths: typeof resolveFiles.resolveSidecarPaths;
23
+ export declare const parseSidecar: typeof parser.parseSidecar;
24
+ export declare const parseSidecarContent: typeof parser.parseSidecarContent;
25
+ export declare const parseSidecarLenient: typeof parser.parseSidecarLenient;
26
+ export declare const parseSidecarContentLenient: typeof parser.parseSidecarContentLenient;
27
+ export declare const readDocumentLines: typeof parser.readDocumentLines;
11
28
  export type { LenientParseResult } from "./lib/parser.js";
12
- export { computeHash, syncHash, toYaml, toJson, writeSidecar, } from "./lib/writer.js";
13
- export { validate, validateFile } from "./lib/validator.js";
14
- export { exactMatch, normalizedMatch, fuzzySearch, combinedScore, } from "./lib/fuzzy.js";
15
- export { isGitAvailable, findRepoRoot, getCurrentCommit, isStale, getDiff, getLineShift, getFileAtCommit, getStagedFiles, detectRenames, parseDiffHunks, } from "./lib/git.js";
16
- export { DEFAULT_THRESHOLD, HIGH_THRESHOLD, reanchorComment, reanchorDocumentLines, reanchorDocumentText, toReanchorLines, reanchorDocument, applyReanchorResults, reanchorFile, } from "./lib/reanchor.js";
17
- export { addComment, normalizeCommentExtensions, populateSelectedText, resolveComment, unresolveComment, removeComment, filterComments, getThreads, summarize, } from "./lib/comments.js";
29
+ export declare const computeHash: typeof writer.computeHash;
30
+ export declare const syncHash: typeof writer.syncHash;
31
+ export declare const toYaml: typeof writer.toYaml;
32
+ export declare const toJson: typeof writer.toJson;
33
+ export declare const writeSidecar: typeof writer.writeSidecar;
34
+ export declare const validate: typeof validator.validate;
35
+ export declare const validateFile: typeof validator.validateFile;
36
+ export declare const exactMatch: typeof fuzzy.exactMatch;
37
+ export declare const normalizedMatch: typeof fuzzy.normalizedMatch;
38
+ export declare const fuzzySearch: typeof fuzzy.fuzzySearch;
39
+ export declare const combinedScore: typeof fuzzy.combinedScore;
40
+ export declare const isGitAvailable: typeof git.isGitAvailable;
41
+ export declare const findRepoRoot: typeof git.findRepoRoot;
42
+ export declare const getCurrentCommit: typeof git.getCurrentCommit;
43
+ export declare const isStale: typeof git.isStale;
44
+ export declare const getDiff: typeof git.getDiff;
45
+ export declare const getLineShift: typeof git.getLineShift;
46
+ export declare const getFileAtCommit: typeof git.getFileAtCommit;
47
+ export declare const getStagedFiles: typeof git.getStagedFiles;
48
+ export declare const detectRenames: typeof git.detectRenames;
49
+ export declare const parseDiffHunks: typeof git.parseDiffHunks;
50
+ export declare const DEFAULT_THRESHOLD = 0.6;
51
+ export declare const HIGH_THRESHOLD = 0.8;
52
+ export declare const reanchorComment: typeof reanchor.reanchorComment;
53
+ export declare const reanchorDocumentLines: typeof reanchor.reanchorDocumentLines;
54
+ export declare const reanchorDocumentText: typeof reanchor.reanchorDocumentText;
55
+ export declare const toReanchorLines: typeof reanchor.toReanchorLines;
56
+ export declare const reanchorDocument: typeof reanchor.reanchorDocument;
57
+ export declare const applyReanchorResults: typeof reanchor.applyReanchorResults;
58
+ export declare const reanchorFile: typeof reanchor.reanchorFile;
59
+ export declare const addComment: typeof comments.addComment;
60
+ export declare const editComment: typeof comments.editComment;
61
+ export declare const normalizeCommentExtensions: typeof comments.normalizeCommentExtensions;
62
+ export declare const populateSelectedText: typeof comments.populateSelectedText;
63
+ export declare const resolveComment: typeof comments.resolveComment;
64
+ export declare const unresolveComment: typeof comments.unresolveComment;
65
+ export declare const removeComment: typeof comments.removeComment;
66
+ export declare const filterComments: typeof comments.filterComments;
67
+ export declare const getThreads: typeof comments.getThreads;
68
+ export declare const summarize: typeof comments.summarize;
18
69
  export type { CommentSummary, RemoveCommentOptions } from "./lib/comments.js";
19
70
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -4,22 +4,73 @@
4
4
  * Usage:
5
5
  * import { validate, reanchorFile, addComment, ... } from "mrsf";
6
6
  */
7
+ import * as discovery from "./lib/discovery.js";
8
+ import * as resolveFiles from "./lib/resolve-files.js";
9
+ import * as parser from "./lib/parser.js";
10
+ import * as writer from "./lib/writer.js";
11
+ import * as validator from "./lib/validator.js";
12
+ import * as fuzzy from "./lib/fuzzy.js";
13
+ import * as git from "./lib/git.js";
14
+ import * as reanchor from "./lib/reanchor.js";
15
+ import * as comments from "./lib/comments.js";
7
16
  // Discovery
8
- export { findWorkspaceRoot, loadConfig, discoverSidecar, sidecarToDocument, discoverAllSidecars, } from "./lib/discovery.js";
17
+ export const findWorkspaceRoot = discovery.findWorkspaceRoot;
18
+ export const loadConfig = discovery.loadConfig;
19
+ export const discoverSidecar = discovery.discoverSidecar;
20
+ export const sidecarToDocument = discovery.sidecarToDocument;
21
+ export const discoverAllSidecars = discovery.discoverAllSidecars;
9
22
  // File resolution
10
- export { resolveSidecarPaths } from "./lib/resolve-files.js";
23
+ export const resolveSidecarPaths = resolveFiles.resolveSidecarPaths;
11
24
  // Parsing
12
- export { parseSidecar, parseSidecarContent, parseSidecarLenient, parseSidecarContentLenient, readDocumentLines, } from "./lib/parser.js";
25
+ export const parseSidecar = parser.parseSidecar;
26
+ export const parseSidecarContent = parser.parseSidecarContent;
27
+ export const parseSidecarLenient = parser.parseSidecarLenient;
28
+ export const parseSidecarContentLenient = parser.parseSidecarContentLenient;
29
+ export const readDocumentLines = parser.readDocumentLines;
13
30
  // Writing
14
- export { computeHash, syncHash, toYaml, toJson, writeSidecar, } from "./lib/writer.js";
31
+ export const computeHash = writer.computeHash;
32
+ export const syncHash = writer.syncHash;
33
+ export const toYaml = writer.toYaml;
34
+ export const toJson = writer.toJson;
35
+ export const writeSidecar = writer.writeSidecar;
15
36
  // Validation
16
- export { validate, validateFile } from "./lib/validator.js";
37
+ export const validate = validator.validate;
38
+ export const validateFile = validator.validateFile;
17
39
  // Fuzzy matching
18
- export { exactMatch, normalizedMatch, fuzzySearch, combinedScore, } from "./lib/fuzzy.js";
40
+ export const exactMatch = fuzzy.exactMatch;
41
+ export const normalizedMatch = fuzzy.normalizedMatch;
42
+ export const fuzzySearch = fuzzy.fuzzySearch;
43
+ export const combinedScore = fuzzy.combinedScore;
19
44
  // Git
20
- export { isGitAvailable, findRepoRoot, getCurrentCommit, isStale, getDiff, getLineShift, getFileAtCommit, getStagedFiles, detectRenames, parseDiffHunks, } from "./lib/git.js";
45
+ export const isGitAvailable = git.isGitAvailable;
46
+ export const findRepoRoot = git.findRepoRoot;
47
+ export const getCurrentCommit = git.getCurrentCommit;
48
+ export const isStale = git.isStale;
49
+ export const getDiff = git.getDiff;
50
+ export const getLineShift = git.getLineShift;
51
+ export const getFileAtCommit = git.getFileAtCommit;
52
+ export const getStagedFiles = git.getStagedFiles;
53
+ export const detectRenames = git.detectRenames;
54
+ export const parseDiffHunks = git.parseDiffHunks;
21
55
  // Re-anchoring
22
- export { DEFAULT_THRESHOLD, HIGH_THRESHOLD, reanchorComment, reanchorDocumentLines, reanchorDocumentText, toReanchorLines, reanchorDocument, applyReanchorResults, reanchorFile, } from "./lib/reanchor.js";
56
+ export const DEFAULT_THRESHOLD = reanchor.DEFAULT_THRESHOLD;
57
+ export const HIGH_THRESHOLD = reanchor.HIGH_THRESHOLD;
58
+ export const reanchorComment = reanchor.reanchorComment;
59
+ export const reanchorDocumentLines = reanchor.reanchorDocumentLines;
60
+ export const reanchorDocumentText = reanchor.reanchorDocumentText;
61
+ export const toReanchorLines = reanchor.toReanchorLines;
62
+ export const reanchorDocument = reanchor.reanchorDocument;
63
+ export const applyReanchorResults = reanchor.applyReanchorResults;
64
+ export const reanchorFile = reanchor.reanchorFile;
23
65
  // Comments
24
- export { addComment, normalizeCommentExtensions, populateSelectedText, resolveComment, unresolveComment, removeComment, filterComments, getThreads, summarize, } from "./lib/comments.js";
66
+ export const addComment = comments.addComment;
67
+ export const editComment = comments.editComment;
68
+ export const normalizeCommentExtensions = comments.normalizeCommentExtensions;
69
+ export const populateSelectedText = comments.populateSelectedText;
70
+ export const resolveComment = comments.resolveComment;
71
+ export const unresolveComment = comments.unresolveComment;
72
+ export const removeComment = comments.removeComment;
73
+ export const filterComments = comments.filterComments;
74
+ export const getThreads = comments.getThreads;
75
+ export const summarize = comments.summarize;
25
76
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * MRSF Comment Operations — CRUD for sidecar comments.
3
3
  */
4
- import type { AddCommentOptions, Comment, CommentFilter, CommentExtensions, MrsfDocument } from "./types.js";
4
+ import type { AddCommentOptions, Comment, CommentFilter, CommentExtensions, EditCommentOptions, MrsfDocument } from "./types.js";
5
5
  export declare function normalizeCommentExtensions(extensions?: Record<string, unknown>): CommentExtensions;
6
6
  /**
7
7
  * Add a new comment to a document. Mutates doc.comments in place.
@@ -13,6 +13,7 @@ export declare function addComment(doc: MrsfDocument, opts: AddCommentOptions, r
13
13
  * Should be called after addComment if the caller provides line info but not selected_text.
14
14
  */
15
15
  export declare function populateSelectedText(comment: Comment, documentLines: string[]): void;
16
+ export declare function editComment(doc: MrsfDocument, commentId: string, opts: EditCommentOptions): Comment;
16
17
  /**
17
18
  * Resolve a comment by id. Per §9, resolving a parent does NOT
18
19
  * automatically resolve its replies.
@@ -129,6 +129,20 @@ export function populateSelectedText(comment, documentLines) {
129
129
  comment.selected_text_hash = computeHash(comment.selected_text);
130
130
  }
131
131
  }
132
+ export function editComment(doc, commentId, opts) {
133
+ const comment = doc.comments.find((entry) => entry.id === commentId);
134
+ if (!comment) {
135
+ throw new Error(`Unknown comment '${commentId}'.`);
136
+ }
137
+ if (opts.actor && comment.author !== opts.actor) {
138
+ throw new Error("Only the comment author can edit this comment.");
139
+ }
140
+ if (opts.text.trim().length === 0) {
141
+ throw new Error("Comment text cannot be empty.");
142
+ }
143
+ comment.text = opts.text;
144
+ return comment;
145
+ }
132
146
  // ---------------------------------------------------------------------------
133
147
  // Resolve / Unresolve
134
148
  // ---------------------------------------------------------------------------
@@ -175,7 +175,7 @@ function salvageYaml(content) {
175
175
  */
176
176
  export async function readDocumentLines(filePath) {
177
177
  const content = await readFile(path.resolve(filePath), "utf-8");
178
- const lines = content.split("\n");
178
+ const lines = content.replace(/\r\n?/g, "\n").split("\n");
179
179
  // Prepend empty element so lines[1] = first line (1-based)
180
180
  return ["", ...lines];
181
181
  }
@@ -113,6 +113,11 @@ export interface AddCommentOptions {
113
113
  /** Tool-specific extension fields keyed by x_*. */
114
114
  extensions?: CommentExtensions;
115
115
  }
116
+ export interface EditCommentOptions {
117
+ text: string;
118
+ /** Optional actor identity for author-based edit permission checks. */
119
+ actor?: string;
120
+ }
116
121
  export interface CommentFilter {
117
122
  open?: boolean;
118
123
  resolved?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrsf/cli",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "CLI and library for the Markdown Review Sidecar Format (MRSF)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",