@mirrowel/opencode-openshare 0.3.0-dev.1 → 0.3.0-dev.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/ci/openshare.js +21 -0
- package/dist/core.js +29 -0
- package/package.json +1 -1
- package/src/core.ts +25 -0
package/ci/openshare.js
CHANGED
|
@@ -2482,6 +2482,23 @@ function createEngine(deps) {
|
|
|
2482
2482
|
svelte: "svelte"
|
|
2483
2483
|
};
|
|
2484
2484
|
const FILE_TOOLS = new Set(["read", "write", "edit", "patch"]);
|
|
2485
|
+
const refineEmbeddedLanguage = (meta, text) => {
|
|
2486
|
+
if (meta.language !== "html")
|
|
2487
|
+
return false;
|
|
2488
|
+
const head = text.slice(0, 4000);
|
|
2489
|
+
if (/<[a-zA-Z][^>\n]*>/.test(head))
|
|
2490
|
+
return false;
|
|
2491
|
+
let refined;
|
|
2492
|
+
if (/^[ \t]*[.#][A-Za-z][\w-]*[^\n{]*\{/m.test(head) && !/\b(function|=>|return)\b/.test(head)) {
|
|
2493
|
+
refined = "css";
|
|
2494
|
+
} else if (/\b(function|const|let|var|return|if|for|while|=>|addEventListener|document\.|window\.)\b/.test(head) || /[;{}]\s*$/m.test(head)) {
|
|
2495
|
+
refined = "javascript";
|
|
2496
|
+
}
|
|
2497
|
+
if (!refined || meta.language === refined)
|
|
2498
|
+
return false;
|
|
2499
|
+
meta.language = refined;
|
|
2500
|
+
return true;
|
|
2501
|
+
};
|
|
2485
2502
|
const stampFileLanguages = () => {
|
|
2486
2503
|
for (const m of msgIndex.values()) {
|
|
2487
2504
|
if (m.role !== "assistant")
|
|
@@ -2508,6 +2525,10 @@ function createEngine(deps) {
|
|
|
2508
2525
|
mutated = true;
|
|
2509
2526
|
}
|
|
2510
2527
|
}
|
|
2528
|
+
if (part.name === "read" && typeof state.output === "string" && state.output.length > 0) {
|
|
2529
|
+
if (refineEmbeddedLanguage(meta, state.output))
|
|
2530
|
+
mutated = true;
|
|
2531
|
+
}
|
|
2511
2532
|
if (typeof meta.lineStart !== "number" && part.name === "read") {
|
|
2512
2533
|
const off = state.input?.offset;
|
|
2513
2534
|
if (typeof off === "number" && off >= 0 && off > 0) {
|
package/dist/core.js
CHANGED
|
@@ -2209,6 +2209,30 @@ export function createEngine(deps) {
|
|
|
2209
2209
|
swift: "swift", kt: "kotlin", php: "php", lua: "lua", vue: "vue", svelte: "svelte",
|
|
2210
2210
|
};
|
|
2211
2211
|
const FILE_TOOLS = new Set(["read", "write", "edit", "patch"]);
|
|
2212
|
+
/** A read that returns lines from inside an html file's <script>/<style>
|
|
2213
|
+
* block gets tokenized as html by the viewer, and a snippet with no tag
|
|
2214
|
+
* context tokenizes as untyped soup (one default span per line). The
|
|
2215
|
+
* viewer only sees the snippet, so the stamp carries the language that is
|
|
2216
|
+
* true for the RETURNED RANGE: no tags plus code shape means the range sat
|
|
2217
|
+
* inside an embedded script or style block. */
|
|
2218
|
+
const refineEmbeddedLanguage = (meta, text) => {
|
|
2219
|
+
if (meta.language !== "html")
|
|
2220
|
+
return false;
|
|
2221
|
+
const head = text.slice(0, 4000);
|
|
2222
|
+
if (/<[a-zA-Z][^>\n]*>/.test(head))
|
|
2223
|
+
return false;
|
|
2224
|
+
let refined;
|
|
2225
|
+
if (/^[ \t]*[.#][A-Za-z][\w-]*[^\n{]*\{/m.test(head) && !/\b(function|=>|return)\b/.test(head)) {
|
|
2226
|
+
refined = "css";
|
|
2227
|
+
}
|
|
2228
|
+
else if (/\b(function|const|let|var|return|if|for|while|=>|addEventListener|document\.|window\.)\b/.test(head) || /[;{}]\s*$/m.test(head)) {
|
|
2229
|
+
refined = "javascript";
|
|
2230
|
+
}
|
|
2231
|
+
if (!refined || meta.language === refined)
|
|
2232
|
+
return false;
|
|
2233
|
+
meta.language = refined;
|
|
2234
|
+
return true;
|
|
2235
|
+
};
|
|
2212
2236
|
const stampFileLanguages = () => {
|
|
2213
2237
|
for (const m of msgIndex.values()) {
|
|
2214
2238
|
if (m.role !== "assistant")
|
|
@@ -2240,6 +2264,11 @@ export function createEngine(deps) {
|
|
|
2240
2264
|
mutated = true;
|
|
2241
2265
|
}
|
|
2242
2266
|
}
|
|
2267
|
+
// range refinement: html-stamped reads inside script/style blocks
|
|
2268
|
+
if (part.name === "read" && typeof state.output === "string" && state.output.length > 0) {
|
|
2269
|
+
if (refineEmbeddedLanguage(meta, state.output))
|
|
2270
|
+
mutated = true;
|
|
2271
|
+
}
|
|
2243
2272
|
// lineStart stamp: reads sliced from an offset keep REAL file line
|
|
2244
2273
|
// numbers in the viewer's unified file card (pierre numbers from 1;
|
|
2245
2274
|
// 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.2",
|
|
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
|
@@ -2263,6 +2263,27 @@ export function createEngine(deps: EngineDeps): Engine {
|
|
|
2263
2263
|
|
|
2264
2264
|
const FILE_TOOLS = new Set(["read", "write", "edit", "patch"])
|
|
2265
2265
|
|
|
2266
|
+
/** A read that returns lines from inside an html file's <script>/<style>
|
|
2267
|
+
* block gets tokenized as html by the viewer, and a snippet with no tag
|
|
2268
|
+
* context tokenizes as untyped soup (one default span per line). The
|
|
2269
|
+
* viewer only sees the snippet, so the stamp carries the language that is
|
|
2270
|
+
* true for the RETURNED RANGE: no tags plus code shape means the range sat
|
|
2271
|
+
* inside an embedded script or style block. */
|
|
2272
|
+
const refineEmbeddedLanguage = (meta: { language?: unknown }, text: string): boolean => {
|
|
2273
|
+
if (meta.language !== "html") return false
|
|
2274
|
+
const head = text.slice(0, 4000)
|
|
2275
|
+
if (/<[a-zA-Z][^>\n]*>/.test(head)) return false
|
|
2276
|
+
let refined: string | undefined
|
|
2277
|
+
if (/^[ \t]*[.#][A-Za-z][\w-]*[^\n{]*\{/m.test(head) && !/\b(function|=>|return)\b/.test(head)) {
|
|
2278
|
+
refined = "css"
|
|
2279
|
+
} else if (/\b(function|const|let|var|return|if|for|while|=>|addEventListener|document\.|window\.)\b/.test(head) || /[;{}]\s*$/m.test(head)) {
|
|
2280
|
+
refined = "javascript"
|
|
2281
|
+
}
|
|
2282
|
+
if (!refined || meta.language === refined) return false
|
|
2283
|
+
meta.language = refined
|
|
2284
|
+
return true
|
|
2285
|
+
}
|
|
2286
|
+
|
|
2266
2287
|
const stampFileLanguages = () => {
|
|
2267
2288
|
for (const m of msgIndex.values()) {
|
|
2268
2289
|
if (m.role !== "assistant") continue
|
|
@@ -2289,6 +2310,10 @@ export function createEngine(deps: EngineDeps): Engine {
|
|
|
2289
2310
|
mutated = true
|
|
2290
2311
|
}
|
|
2291
2312
|
}
|
|
2313
|
+
// range refinement: html-stamped reads inside script/style blocks
|
|
2314
|
+
if (part.name === "read" && typeof state.output === "string" && state.output.length > 0) {
|
|
2315
|
+
if (refineEmbeddedLanguage(meta, state.output)) mutated = true
|
|
2316
|
+
}
|
|
2292
2317
|
// lineStart stamp: reads sliced from an offset keep REAL file line
|
|
2293
2318
|
// numbers in the viewer's unified file card (pierre numbers from 1;
|
|
2294
2319
|
// the viewer shifts by this stamp, authoritatively)
|