@mirrowel/opencode-openshare 0.3.0-dev.2 → 0.3.0-dev.3
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/ci/openshare.js +14 -0
- package/dist/core.js +21 -0
- package/package.json +1 -1
- package/src/core.ts +20 -0
package/ci/openshare.js
CHANGED
|
@@ -2499,6 +2499,15 @@ function createEngine(deps) {
|
|
|
2499
2499
|
meta.language = refined;
|
|
2500
2500
|
return true;
|
|
2501
2501
|
};
|
|
2502
|
+
const refinePatchLanguage = (meta, patchText) => {
|
|
2503
|
+
const at = patchText.indexOf("@@");
|
|
2504
|
+
if (at < 0)
|
|
2505
|
+
return false;
|
|
2506
|
+
const body = patchText.slice(at).split(`
|
|
2507
|
+
`).map((l) => /^[ +\\]/.test(l) ? l.slice(1) : l.startsWith("-") ? l.slice(1) : "").join(`
|
|
2508
|
+
`);
|
|
2509
|
+
return refineEmbeddedLanguage(meta, body);
|
|
2510
|
+
};
|
|
2502
2511
|
const stampFileLanguages = () => {
|
|
2503
2512
|
for (const m of msgIndex.values()) {
|
|
2504
2513
|
if (m.role !== "assistant")
|
|
@@ -2529,6 +2538,11 @@ function createEngine(deps) {
|
|
|
2529
2538
|
if (refineEmbeddedLanguage(meta, state.output))
|
|
2530
2539
|
mutated = true;
|
|
2531
2540
|
}
|
|
2541
|
+
if ((part.name === "edit" || part.name === "patch") && typeof meta.language === "string") {
|
|
2542
|
+
const pt = typeof meta.diff === "string" ? meta.diff : typeof meta.filediff?.patch === "string" ? meta.filediff.patch : undefined;
|
|
2543
|
+
if (pt && refinePatchLanguage(meta, pt))
|
|
2544
|
+
mutated = true;
|
|
2545
|
+
}
|
|
2532
2546
|
if (typeof meta.lineStart !== "number" && part.name === "read") {
|
|
2533
2547
|
const off = state.input?.offset;
|
|
2534
2548
|
if (typeof off === "number" && off >= 0 && off > 0) {
|
package/dist/core.js
CHANGED
|
@@ -2233,6 +2233,20 @@ export function createEngine(deps) {
|
|
|
2233
2233
|
meta.language = refined;
|
|
2234
2234
|
return true;
|
|
2235
2235
|
};
|
|
2236
|
+
/** Sniff the CODE CONTENT of a unified patch: drop everything before the
|
|
2237
|
+
* first hunk header and strip each line's diff marker, so the same
|
|
2238
|
+
* tag/shape checks as reads run over clean source lines. */
|
|
2239
|
+
const refinePatchLanguage = (meta, patchText) => {
|
|
2240
|
+
const at = patchText.indexOf("@@");
|
|
2241
|
+
if (at < 0)
|
|
2242
|
+
return false;
|
|
2243
|
+
const body = patchText
|
|
2244
|
+
.slice(at)
|
|
2245
|
+
.split("\n")
|
|
2246
|
+
.map((l) => (/^[ +\\]/.test(l) ? l.slice(1) : l.startsWith("-") ? l.slice(1) : ""))
|
|
2247
|
+
.join("\n");
|
|
2248
|
+
return refineEmbeddedLanguage(meta, body);
|
|
2249
|
+
};
|
|
2236
2250
|
const stampFileLanguages = () => {
|
|
2237
2251
|
for (const m of msgIndex.values()) {
|
|
2238
2252
|
if (m.role !== "assistant")
|
|
@@ -2269,6 +2283,13 @@ export function createEngine(deps) {
|
|
|
2269
2283
|
if (refineEmbeddedLanguage(meta, state.output))
|
|
2270
2284
|
mutated = true;
|
|
2271
2285
|
}
|
|
2286
|
+
// same refinement for edit hunks: a mid-script html diff tokenizes
|
|
2287
|
+
// untyped without the range language
|
|
2288
|
+
if ((part.name === "edit" || part.name === "patch") && typeof meta.language === "string") {
|
|
2289
|
+
const pt = typeof meta.diff === "string" ? meta.diff : typeof meta.filediff?.patch === "string" ? meta.filediff.patch : undefined;
|
|
2290
|
+
if (pt && refinePatchLanguage(meta, pt))
|
|
2291
|
+
mutated = true;
|
|
2292
|
+
}
|
|
2272
2293
|
// lineStart stamp: reads sliced from an offset keep REAL file line
|
|
2273
2294
|
// numbers in the viewer's unified file card (pierre numbers from 1;
|
|
2274
2295
|
// the viewer shifts by this stamp, authoritatively)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mirrowel/opencode-openshare",
|
|
3
|
-
"version": "0.3.0-dev.
|
|
3
|
+
"version": "0.3.0-dev.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Open(code)Share — re:share: self-hosted session sharing for opencode. Server plugin (single file or package), optional TUI for interactive opt-in sharing.",
|
|
6
6
|
"license": "MIT",
|
package/src/core.ts
CHANGED
|
@@ -2284,6 +2284,20 @@ export function createEngine(deps: EngineDeps): Engine {
|
|
|
2284
2284
|
return true
|
|
2285
2285
|
}
|
|
2286
2286
|
|
|
2287
|
+
/** Sniff the CODE CONTENT of a unified patch: drop everything before the
|
|
2288
|
+
* first hunk header and strip each line's diff marker, so the same
|
|
2289
|
+
* tag/shape checks as reads run over clean source lines. */
|
|
2290
|
+
const refinePatchLanguage = (meta: { language?: unknown }, patchText: string): boolean => {
|
|
2291
|
+
const at = patchText.indexOf("@@")
|
|
2292
|
+
if (at < 0) return false
|
|
2293
|
+
const body = patchText
|
|
2294
|
+
.slice(at)
|
|
2295
|
+
.split("\n")
|
|
2296
|
+
.map((l) => (/^[ +\\]/.test(l) ? l.slice(1) : l.startsWith("-") ? l.slice(1) : ""))
|
|
2297
|
+
.join("\n")
|
|
2298
|
+
return refineEmbeddedLanguage(meta, body)
|
|
2299
|
+
}
|
|
2300
|
+
|
|
2287
2301
|
const stampFileLanguages = () => {
|
|
2288
2302
|
for (const m of msgIndex.values()) {
|
|
2289
2303
|
if (m.role !== "assistant") continue
|
|
@@ -2314,6 +2328,12 @@ export function createEngine(deps: EngineDeps): Engine {
|
|
|
2314
2328
|
if (part.name === "read" && typeof state.output === "string" && state.output.length > 0) {
|
|
2315
2329
|
if (refineEmbeddedLanguage(meta, state.output)) mutated = true
|
|
2316
2330
|
}
|
|
2331
|
+
// same refinement for edit hunks: a mid-script html diff tokenizes
|
|
2332
|
+
// untyped without the range language
|
|
2333
|
+
if ((part.name === "edit" || part.name === "patch") && typeof meta.language === "string") {
|
|
2334
|
+
const pt = typeof (meta as any).diff === "string" ? (meta as any).diff : typeof (meta as any).filediff?.patch === "string" ? (meta as any).filediff.patch : undefined
|
|
2335
|
+
if (pt && refinePatchLanguage(meta, pt)) mutated = true
|
|
2336
|
+
}
|
|
2317
2337
|
// lineStart stamp: reads sliced from an offset keep REAL file line
|
|
2318
2338
|
// numbers in the viewer's unified file card (pierre numbers from 1;
|
|
2319
2339
|
// the viewer shifts by this stamp, authoritatively)
|