@actagent/diffs-language-pack 2026.6.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/index.ts ADDED
@@ -0,0 +1,10 @@
1
+ // Diffs Language Pack plugin entrypoint registers its ACTAgent integration.
2
+ import { definePluginEntry } from "./api.js";
3
+ import { registerDiffsLanguagePackPlugin } from "./src/plugin.js";
4
+
5
+ export default definePluginEntry({
6
+ id: "diffs-language-pack",
7
+ name: "Diff Viewer Language Pack",
8
+ description: "Adds syntax highlighting for languages outside the default diffs viewer set.",
9
+ register: registerDiffsLanguagePackPlugin,
10
+ });
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "@actagent/diffs-language-pack",
3
+ "version": "2026.6.2",
4
+ "lockfileVersion": 3,
5
+ "requires": true,
6
+ "packages": {
7
+ "": {
8
+ "name": "@actagent/diffs-language-pack",
9
+ "version": "2026.6.2"
10
+ }
11
+ }
12
+ }
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@actagent/diffs-language-pack",
3
+ "version": "2026.6.2",
4
+ "description": "ACTAgent diffs viewer syntax highlighting language pack",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/actagent/actagent"
8
+ },
9
+ "type": "module",
10
+ "devDependencies": {
11
+ "@actagent/plugin-sdk": "workspace:*"
12
+ },
13
+ "actagent": {
14
+ "extensions": [
15
+ "./index.ts"
16
+ ],
17
+ "install": {
18
+ "npmSpec": "@actagent/diffs-language-pack",
19
+ "actagenthubSpec": "actagenthub:@actagent/diffs-language-pack",
20
+ "localPath": "extensions/diffs-language-pack",
21
+ "defaultChoice": "npm",
22
+ "minHostVersion": ">=2026.5.27"
23
+ },
24
+ "compat": {
25
+ "pluginApi": ">=2026.6.2"
26
+ },
27
+ "assetScripts": {
28
+ "build": "node ../../scripts/build-diffs-viewer-runtime.mjs full"
29
+ },
30
+ "build": {
31
+ "actagentVersion": "2026.6.2",
32
+ "staticAssets": [
33
+ {
34
+ "source": "./assets/viewer-runtime.js",
35
+ "output": "assets/viewer-runtime.js"
36
+ }
37
+ ]
38
+ },
39
+ "release": {
40
+ "publishToACTAgentHub": true,
41
+ "publishToNpm": true
42
+ }
43
+ }
44
+ }
package/src/plugin.ts ADDED
@@ -0,0 +1,65 @@
1
+ // Diffs Language Pack plugin module implements plugin behavior.
2
+ import type { IncomingMessage, ServerResponse } from "node:http";
3
+ import type { ACTAgentPluginApi } from "../api.js";
4
+ import { VIEWER_ASSET_PREFIX, getServedViewerAsset } from "./viewer-assets.js";
5
+
6
+ export function registerDiffsLanguagePackPlugin(api: ACTAgentPluginApi): void {
7
+ api.registerHttpRoute({
8
+ path: "/plugins/diffs-language-pack",
9
+ auth: "plugin",
10
+ match: "prefix",
11
+ handler: createDiffsLanguagePackHttpHandler(),
12
+ });
13
+ }
14
+
15
+ function createDiffsLanguagePackHttpHandler() {
16
+ return async (req: IncomingMessage, res: ServerResponse): Promise<boolean> => {
17
+ const parsed = parseRequestUrl(req.url);
18
+ if (!parsed?.pathname.startsWith(VIEWER_ASSET_PREFIX)) {
19
+ return false;
20
+ }
21
+ if (req.method !== "GET" && req.method !== "HEAD") {
22
+ respondText(res, 405, "Method not allowed");
23
+ return true;
24
+ }
25
+
26
+ const asset = await getServedViewerAsset(parsed.pathname);
27
+ if (!asset) {
28
+ respondText(res, 404, "Asset not found");
29
+ return true;
30
+ }
31
+
32
+ res.statusCode = 200;
33
+ setSharedHeaders(res, asset.contentType);
34
+ if (req.method === "HEAD") {
35
+ res.end();
36
+ } else {
37
+ res.end(asset.body);
38
+ }
39
+ return true;
40
+ };
41
+ }
42
+
43
+ function parseRequestUrl(rawUrl?: string): URL | null {
44
+ if (!rawUrl) {
45
+ return null;
46
+ }
47
+ try {
48
+ return new URL(rawUrl, "http://127.0.0.1");
49
+ } catch {
50
+ return null;
51
+ }
52
+ }
53
+
54
+ function respondText(res: ServerResponse, statusCode: number, body: string): void {
55
+ res.statusCode = statusCode;
56
+ setSharedHeaders(res, "text/plain; charset=utf-8");
57
+ res.end(body);
58
+ }
59
+
60
+ function setSharedHeaders(res: ServerResponse, contentType: string): void {
61
+ res.setHeader("cache-control", "no-store, max-age=0");
62
+ res.setHeader("content-type", contentType);
63
+ res.setHeader("x-content-type-options", "nosniff");
64
+ res.setHeader("referrer-policy", "no-referrer");
65
+ }
@@ -0,0 +1,91 @@
1
+ // Diffs Language Pack plugin module implements viewer assets behavior.
2
+ import crypto from "node:crypto";
3
+ import fs from "node:fs/promises";
4
+ import { fileURLToPath } from "node:url";
5
+
6
+ export const VIEWER_ASSET_PREFIX = "/plugins/diffs-language-pack/assets/";
7
+ export const VIEWER_LOADER_PATH = `${VIEWER_ASSET_PREFIX}viewer.js`;
8
+ export const VIEWER_RUNTIME_PATH = `${VIEWER_ASSET_PREFIX}viewer-runtime.js`;
9
+ const VIEWER_RUNTIME_RELATIVE_IMPORT_PATH = "./viewer-runtime.js";
10
+ const VIEWER_RUNTIME_CANDIDATE_RELATIVE_PATHS = [
11
+ "./assets/viewer-runtime.js",
12
+ "../assets/viewer-runtime.js",
13
+ ] as const;
14
+
15
+ type ServedViewerAsset = {
16
+ body: string | Buffer;
17
+ contentType: string;
18
+ };
19
+
20
+ type RuntimeAssetCache = {
21
+ mtimeMs: number;
22
+ runtimeBody: Buffer;
23
+ loaderBody: string;
24
+ };
25
+
26
+ let runtimeAssetCache: RuntimeAssetCache | null = null;
27
+
28
+ function isMissingFileError(error: unknown): error is NodeJS.ErrnoException {
29
+ return error instanceof Error && "code" in error && error.code === "ENOENT";
30
+ }
31
+
32
+ export async function resolveViewerRuntimeFileUrl(): Promise<URL> {
33
+ let missingFileError: NodeJS.ErrnoException | null = null;
34
+
35
+ for (const relativePath of VIEWER_RUNTIME_CANDIDATE_RELATIVE_PATHS) {
36
+ const candidateUrl = new URL(relativePath, import.meta.url);
37
+ try {
38
+ await fs.stat(fileURLToPath(candidateUrl));
39
+ return candidateUrl;
40
+ } catch (error) {
41
+ if (isMissingFileError(error)) {
42
+ missingFileError = error;
43
+ continue;
44
+ }
45
+ throw error;
46
+ }
47
+ }
48
+
49
+ if (missingFileError) {
50
+ throw missingFileError;
51
+ }
52
+
53
+ throw new Error("viewer runtime asset candidates were not checked");
54
+ }
55
+
56
+ export async function getServedViewerAsset(pathname: string): Promise<ServedViewerAsset | null> {
57
+ if (pathname !== VIEWER_LOADER_PATH && pathname !== VIEWER_RUNTIME_PATH) {
58
+ return null;
59
+ }
60
+
61
+ const assets = await loadViewerAssets();
62
+ if (pathname === VIEWER_LOADER_PATH) {
63
+ return {
64
+ body: assets.loaderBody,
65
+ contentType: "text/javascript; charset=utf-8",
66
+ };
67
+ }
68
+
69
+ return {
70
+ body: assets.runtimeBody,
71
+ contentType: "text/javascript; charset=utf-8",
72
+ };
73
+ }
74
+
75
+ async function loadViewerAssets(): Promise<RuntimeAssetCache> {
76
+ const runtimeUrl = await resolveViewerRuntimeFileUrl();
77
+ const runtimePath = fileURLToPath(runtimeUrl);
78
+ const runtimeStat = await fs.stat(runtimePath);
79
+ if (runtimeAssetCache && runtimeAssetCache.mtimeMs === runtimeStat.mtimeMs) {
80
+ return runtimeAssetCache;
81
+ }
82
+
83
+ const runtimeBody = await fs.readFile(runtimePath);
84
+ const hash = crypto.createHash("sha1").update(runtimeBody).digest("hex").slice(0, 12);
85
+ runtimeAssetCache = {
86
+ mtimeMs: runtimeStat.mtimeMs,
87
+ runtimeBody,
88
+ loaderBody: `import "${VIEWER_RUNTIME_RELATIVE_IMPORT_PATH}?v=${hash}";\n`,
89
+ };
90
+ return runtimeAssetCache;
91
+ }