@hagicode/hagiscript 0.1.6 → 0.1.7

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.
Files changed (50) hide show
  1. package/README.md +68 -0
  2. package/README_cn.md +55 -0
  3. package/bin/runtime +16 -0
  4. package/dist/cli.js +4 -0
  5. package/dist/cli.js.map +1 -1
  6. package/dist/commands/pm2-commands.d.ts +2 -0
  7. package/dist/commands/pm2-commands.js +54 -0
  8. package/dist/commands/pm2-commands.js.map +1 -0
  9. package/dist/commands/runtime-commands.d.ts +2 -0
  10. package/dist/commands/runtime-commands.js +136 -0
  11. package/dist/commands/runtime-commands.js.map +1 -0
  12. package/dist/index.d.ts +6 -0
  13. package/dist/index.js +6 -0
  14. package/dist/index.js.map +1 -1
  15. package/dist/runtime/command-launch.js +1 -0
  16. package/dist/runtime/command-launch.js.map +1 -1
  17. package/dist/runtime/pm2-manager.d.ts +54 -0
  18. package/dist/runtime/pm2-manager.js +260 -0
  19. package/dist/runtime/pm2-manager.js.map +1 -0
  20. package/dist/runtime/runtime-executor.d.ts +45 -0
  21. package/dist/runtime/runtime-executor.js +135 -0
  22. package/dist/runtime/runtime-executor.js.map +1 -0
  23. package/dist/runtime/runtime-manager.d.ts +79 -0
  24. package/dist/runtime/runtime-manager.js +651 -0
  25. package/dist/runtime/runtime-manager.js.map +1 -0
  26. package/dist/runtime/runtime-manifest.d.ts +77 -0
  27. package/dist/runtime/runtime-manifest.js +277 -0
  28. package/dist/runtime/runtime-manifest.js.map +1 -0
  29. package/dist/runtime/runtime-paths.d.ts +31 -0
  30. package/dist/runtime/runtime-paths.js +77 -0
  31. package/dist/runtime/runtime-paths.js.map +1 -0
  32. package/dist/runtime/runtime-state.d.ts +45 -0
  33. package/dist/runtime/runtime-state.js +82 -0
  34. package/dist/runtime/runtime-state.js.map +1 -0
  35. package/package.json +8 -3
  36. package/runtime/lib/runtime-script-lib.mjs +142 -0
  37. package/runtime/manifest.yaml +136 -0
  38. package/runtime/scripts/configure-code-server.mjs +14 -0
  39. package/runtime/scripts/configure-omniroute.mjs +16 -0
  40. package/runtime/scripts/install-code-server.mjs +35 -0
  41. package/runtime/scripts/install-dotnet.mjs +24 -0
  42. package/runtime/scripts/install-node.mjs +4 -0
  43. package/runtime/scripts/install-npm-packages.mjs +4 -0
  44. package/runtime/scripts/install-omniroute.mjs +37 -0
  45. package/runtime/scripts/remove-npm-packages.mjs +4 -0
  46. package/runtime/scripts/update-npm-packages.mjs +4 -0
  47. package/runtime/scripts/verify-dotnet.mjs +10 -0
  48. package/runtime/scripts/verify-node.mjs +4 -0
  49. package/runtime/templates/code-server-config.yaml +5 -0
  50. package/runtime/templates/omniroute-config.yaml +4 -0
@@ -0,0 +1,82 @@
1
+ import { mkdir, readFile, writeFile } from "node:fs/promises";
2
+ import { dirname } from "node:path";
3
+ export class RuntimeStateError extends Error {
4
+ constructor(message) {
5
+ super(message);
6
+ this.name = "RuntimeStateError";
7
+ }
8
+ }
9
+ export function createInitialRuntimeState(manifest, paths) {
10
+ return {
11
+ schemaVersion: 1,
12
+ runtime: {
13
+ name: manifest.runtime.name,
14
+ version: manifest.runtime.version,
15
+ manifestPath: manifest.manifestPath
16
+ },
17
+ managedRoot: paths.root,
18
+ managedPaths: paths,
19
+ components: {},
20
+ lastOperation: null
21
+ };
22
+ }
23
+ export async function readRuntimeState(statePath) {
24
+ let parsed;
25
+ try {
26
+ parsed = JSON.parse(await readFile(statePath, "utf8"));
27
+ }
28
+ catch (error) {
29
+ if (isMissingFileError(error)) {
30
+ return null;
31
+ }
32
+ const message = error instanceof Error ? error.message : String(error);
33
+ throw new RuntimeStateError(`Failed to read runtime state ${statePath}: ${message}`);
34
+ }
35
+ return validateRuntimeState(parsed, statePath);
36
+ }
37
+ export async function writeRuntimeState(statePath, state) {
38
+ await mkdir(dirname(statePath), { recursive: true });
39
+ await writeFile(statePath, `${JSON.stringify(state, null, 2)}\n`, "utf8");
40
+ }
41
+ export function mergeRuntimeState(manifest, paths, state) {
42
+ const nextState = state ?? createInitialRuntimeState(manifest, paths);
43
+ return {
44
+ ...nextState,
45
+ runtime: {
46
+ name: manifest.runtime.name,
47
+ version: manifest.runtime.version,
48
+ manifestPath: manifest.manifestPath
49
+ },
50
+ managedRoot: paths.root,
51
+ managedPaths: paths,
52
+ components: { ...nextState.components }
53
+ };
54
+ }
55
+ function validateRuntimeState(value, statePath) {
56
+ if (!isRecord(value)) {
57
+ throw new RuntimeStateError(`Runtime state ${statePath} must be a JSON object.`);
58
+ }
59
+ if (value.schemaVersion !== 1) {
60
+ throw new RuntimeStateError(`Runtime state ${statePath} has unsupported schemaVersion ${String(value.schemaVersion)}.`);
61
+ }
62
+ if (!isRecord(value.runtime) || typeof value.runtime.name !== "string" || typeof value.runtime.version !== "string") {
63
+ throw new RuntimeStateError(`Runtime state ${statePath} is missing runtime metadata.`);
64
+ }
65
+ if (!isRecord(value.managedPaths)) {
66
+ throw new RuntimeStateError(`Runtime state ${statePath} is missing managedPaths.`);
67
+ }
68
+ if (!isRecord(value.components)) {
69
+ throw new RuntimeStateError(`Runtime state ${statePath} is missing components.`);
70
+ }
71
+ return value;
72
+ }
73
+ function isRecord(value) {
74
+ return typeof value === "object" && value !== null && !Array.isArray(value);
75
+ }
76
+ function isMissingFileError(error) {
77
+ return (error instanceof Error &&
78
+ "code" in error &&
79
+ typeof error.code === "string" &&
80
+ error.code === "ENOENT");
81
+ }
82
+ //# sourceMappingURL=runtime-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-state.js","sourceRoot":"","sources":["../../src/runtime/runtime-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAgDnC,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAC1C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,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CAAC,YAAY,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,iBAAiB,CAAC,iBAAiB,SAAS,2BAA2B,CAAC,CAAA;IACpF,CAAC;IAED,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC;QAChC,MAAM,IAAI,iBAAiB,CAAC,iBAAiB,SAAS,yBAAyB,CAAC,CAAA;IAClF,CAAC;IAED,OAAO,KAAgC,CAAA;AACzC,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAC7E,CAAC;AAED,SAAS,kBAAkB,CAAC,KAAc;IACxC,OAAO,CACL,KAAK,YAAY,KAAK;QACtB,MAAM,IAAI,KAAK;QACf,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;QAC9B,KAAK,CAAC,IAAI,KAAK,QAAQ,CACxB,CAAA;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hagicode/hagiscript",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Scoped npm package foundation for Hagiscript language tooling.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/HagiCode-org/hagiscript#readme",
@@ -20,10 +20,13 @@
20
20
  "./package.json": "./package.json"
21
21
  },
22
22
  "bin": {
23
- "hagiscript": "dist/cli.js"
23
+ "hagiscript": "dist/cli.js",
24
+ "hagicode-runtime": "bin/runtime"
24
25
  },
25
26
  "files": [
26
27
  "dist",
28
+ "bin",
29
+ "runtime",
27
30
  "README.md",
28
31
  "README_cn.md"
29
32
  ],
@@ -35,6 +38,7 @@
35
38
  "format:check": "prettier --check .",
36
39
  "lint": "eslint .",
37
40
  "integration:installed-runtime": "node scripts/integration-installed-runtime.mjs",
41
+ "integration:runtime-management": "node scripts/integration-runtime-management.mjs",
38
42
  "pack:check": "node scripts/verify-package.mjs",
39
43
  "publish:check-prereqs": "node scripts/verify-npm-publish-prereqs.mjs",
40
44
  "publish:prepare-dev-version": "node scripts/prepare-dev-version.mjs",
@@ -59,7 +63,8 @@
59
63
  "dependencies": {
60
64
  "commander": "^14.0.1",
61
65
  "execa": "^9.6.1",
62
- "semver": "^7.7.4"
66
+ "semver": "^7.7.4",
67
+ "yaml": "^2.8.4"
63
68
  },
64
69
  "devDependencies": {
65
70
  "@eslint/js": "^9.38.0",
@@ -0,0 +1,142 @@
1
+ import { chmod, mkdir, readFile, writeFile } from "node:fs/promises"
2
+ import path from "node:path"
3
+ import process from "node:process"
4
+
5
+ export function readRuntimeScriptContext() {
6
+ return {
7
+ runtimeRoot: requiredEnv("HAGISCRIPT_RUNTIME_ROOT"),
8
+ runtimeHome: requiredEnv("HAGICODE_RUNTIME_HOME"),
9
+ runtimeDataHome: requiredEnv("HAGICODE_RUNTIME_DATA_HOME"),
10
+ binDir: requiredEnv("HAGISCRIPT_RUNTIME_BIN_DIR"),
11
+ configDir: requiredEnv("HAGISCRIPT_RUNTIME_CONFIG_DIR"),
12
+ logsDir: requiredEnv("HAGISCRIPT_RUNTIME_LOGS_DIR"),
13
+ dataDir: requiredEnv("HAGISCRIPT_RUNTIME_DATA_DIR"),
14
+ statePath: requiredEnv("HAGISCRIPT_RUNTIME_STATE_PATH"),
15
+ componentName: requiredEnv("HAGISCRIPT_RUNTIME_COMPONENT_NAME"),
16
+ componentType: requiredEnv("HAGISCRIPT_RUNTIME_COMPONENT_TYPE"),
17
+ componentRoot: requiredEnv("HAGISCRIPT_RUNTIME_COMPONENT_ROOT"),
18
+ componentConfigDir: requiredEnv("HAGISCRIPT_RUNTIME_COMPONENT_CONFIG_DIR"),
19
+ componentDataDir: requiredEnv("HAGISCRIPT_RUNTIME_COMPONENT_DATA_DIR"),
20
+ componentLogsDir: requiredEnv("HAGISCRIPT_RUNTIME_COMPONENT_LOGS_DIR"),
21
+ componentPm2Home: requiredEnv("HAGISCRIPT_RUNTIME_COMPONENT_PM2_HOME"),
22
+ templateDir: requiredEnv("HAGISCRIPT_RUNTIME_TEMPLATE_DIR"),
23
+ componentVersion: process.env.HAGISCRIPT_RUNTIME_COMPONENT_VERSION?.trim() || null,
24
+ phase: process.env.HAGISCRIPT_RUNTIME_PHASE?.trim() || "install",
25
+ purge: process.env.HAGISCRIPT_RUNTIME_PURGE === "1"
26
+ }
27
+ }
28
+
29
+ export async function ensureDirectory(directory) {
30
+ await mkdir(directory, { recursive: true })
31
+ }
32
+
33
+ export async function writeJsonFile(filePath, value) {
34
+ await ensureDirectory(path.dirname(filePath))
35
+ await writeFile(filePath, `${JSON.stringify(value, null, 2)}\n`, "utf8")
36
+ }
37
+
38
+ export async function writeComponentMarker(context, extra = {}) {
39
+ const markerPath = path.join(context.componentRoot, ".hagicode-runtime.json")
40
+ await writeJsonFile(markerPath, {
41
+ component: context.componentName,
42
+ type: context.componentType,
43
+ version: context.componentVersion,
44
+ phase: context.phase,
45
+ runtimeRoot: context.runtimeRoot,
46
+ generatedAt: new Date().toISOString(),
47
+ ...extra
48
+ })
49
+ return markerPath
50
+ }
51
+
52
+ export async function materializeTemplate(templateName, destinationPath, variables) {
53
+ const templatePath = path.join(readRuntimeScriptContext().templateDir, templateName)
54
+ const template = await readFile(templatePath, "utf8")
55
+ let rendered = template
56
+
57
+ for (const [key, value] of Object.entries(variables)) {
58
+ rendered = rendered.replaceAll(`{{${key}}}`, String(value))
59
+ }
60
+
61
+ await ensureDirectory(path.dirname(destinationPath))
62
+ await writeFile(destinationPath, rendered, "utf8")
63
+ return destinationPath
64
+ }
65
+
66
+ export async function writeNodeEntrypoint(filePath, message) {
67
+ await ensureDirectory(path.dirname(filePath))
68
+ await writeFile(
69
+ filePath,
70
+ `#!/usr/bin/env node\nprocess.stdout.write(${JSON.stringify(message)} + "\\n")\n`,
71
+ "utf8"
72
+ )
73
+ await makeExecutable(filePath)
74
+ return filePath
75
+ }
76
+
77
+ export async function writeManagedServiceEntrypoint(filePath, serviceName) {
78
+ await ensureDirectory(path.dirname(filePath))
79
+ await writeFile(
80
+ filePath,
81
+ `#!/usr/bin/env node
82
+ const serviceName = ${JSON.stringify(serviceName)}
83
+ process.stdout.write(serviceName + " ready\\n")
84
+ const timer = setInterval(() => {
85
+ process.stdout.write("")
86
+ }, 60_000)
87
+ const shutdown = (signal) => {
88
+ clearInterval(timer)
89
+ process.stdout.write(serviceName + " shutting down via " + signal + "\\n")
90
+ process.exit(0)
91
+ }
92
+ process.on("SIGINT", () => shutdown("SIGINT"))
93
+ process.on("SIGTERM", () => shutdown("SIGTERM"))
94
+ `,
95
+ "utf8"
96
+ )
97
+ await makeExecutable(filePath)
98
+ return filePath
99
+ }
100
+
101
+ export async function writeCommandWrapper(binDir, commandName, scriptPath) {
102
+ await ensureDirectory(binDir)
103
+
104
+ if (process.platform === "win32") {
105
+ const wrapperPath = path.join(binDir, `${commandName}.cmd`)
106
+ const relativeTarget = path.relative(path.dirname(wrapperPath), scriptPath).replaceAll("/", "\\")
107
+ await writeFile(
108
+ wrapperPath,
109
+ `@echo off\r\nnode "%~dp0\\${relativeTarget}" %*\r\n`,
110
+ "utf8"
111
+ )
112
+ return wrapperPath
113
+ }
114
+
115
+ const wrapperPath = path.join(binDir, commandName)
116
+ const relativeTarget = path.relative(path.dirname(wrapperPath), scriptPath).replaceAll("\\", "/")
117
+ await writeFile(
118
+ wrapperPath,
119
+ `#!/usr/bin/env sh\nexec node "$(dirname "$0")/${relativeTarget}" "$@"\n`,
120
+ "utf8"
121
+ )
122
+ await makeExecutable(wrapperPath)
123
+ return wrapperPath
124
+ }
125
+
126
+ function requiredEnv(name) {
127
+ const value = process.env[name]?.trim()
128
+
129
+ if (!value) {
130
+ throw new Error(`Missing runtime script environment variable: ${name}`)
131
+ }
132
+
133
+ return value
134
+ }
135
+
136
+ async function makeExecutable(filePath) {
137
+ if (process.platform === "win32") {
138
+ return
139
+ }
140
+
141
+ await chmod(filePath, 0o755)
142
+ }
@@ -0,0 +1,136 @@
1
+ runtime:
2
+ name: "hagicode-runtime"
3
+ version: "1.0.0"
4
+
5
+ paths:
6
+ runtimeRoot: "~/.hagicode/runtime"
7
+ runtimeHome: "program"
8
+ runtimeDataRoot: "runtime-data"
9
+ bin: "bin"
10
+ config: "config"
11
+ logs: "logs"
12
+ data: "data"
13
+ stateFile: "state.json"
14
+ componentsRoot: "components"
15
+ componentDataRoot: "components"
16
+ defaultPm2Home: "pm2"
17
+ npmPrefix: "npm"
18
+ nodeRuntime: "components/node/runtime"
19
+ dotnetRuntime: "components/dotnet/runtime"
20
+ vendoredRoot: "components/bundled"
21
+
22
+ components:
23
+ - name: "node"
24
+ type: "runtime"
25
+ source: "desktop-bundled-node"
26
+ version: "22.22.2"
27
+ channelVersion: "22"
28
+ installScript: "scripts/install-node.mjs"
29
+ verifyScript: "scripts/verify-node.mjs"
30
+
31
+ - name: "dotnet"
32
+ type: "runtime"
33
+ source: "desktop-embedded-dotnet"
34
+ version: "10.0.5"
35
+ channelVersion: "10.0"
36
+ installScript: "scripts/install-dotnet.mjs"
37
+ verifyScript: "scripts/verify-dotnet.mjs"
38
+
39
+ - name: "npm-packages"
40
+ type: "package"
41
+ source: "desktop-managed-prefix"
42
+ installScript: "scripts/install-npm-packages.mjs"
43
+ updateScript: "scripts/update-npm-packages.mjs"
44
+ removeScript: "scripts/remove-npm-packages.mjs"
45
+ packageCatalog:
46
+ - id: "hagiscript"
47
+ packageName: "@hagicode/hagiscript"
48
+ installSpec: "@hagicode/hagiscript@>=0.1.6"
49
+ binName: "hagiscript"
50
+ - id: "openspec"
51
+ packageName: "@fission-ai/openspec"
52
+ installSpec: "@fission-ai/openspec@1.3.1"
53
+ binName: "openspec"
54
+ - id: "skills"
55
+ packageName: "skills"
56
+ installSpec: "skills@1.5.1"
57
+ binName: "skills"
58
+ - id: "pm2"
59
+ packageName: "pm2"
60
+ installSpec: "pm2@7.0.1"
61
+ binName: "pm2"
62
+ - id: "claude-code"
63
+ packageName: "@anthropic-ai/claude-code"
64
+ installSpec: "@anthropic-ai/claude-code"
65
+ binName: "claude"
66
+ - id: "codex"
67
+ packageName: "@openai/codex"
68
+ installSpec: "@openai/codex"
69
+ binName: "codex"
70
+ - id: "github-copilot"
71
+ packageName: "@github/copilot"
72
+ installSpec: "@github/copilot"
73
+ binName: "copilot"
74
+ - id: "codebuddy"
75
+ packageName: "@tencent-ai/codebuddy-code"
76
+ installSpec: "@tencent-ai/codebuddy-code"
77
+ binName: "codebuddy"
78
+ - id: "opencode"
79
+ packageName: "opencode-ai"
80
+ installSpec: "opencode-ai"
81
+ binName: "opencode"
82
+ - id: "qoder"
83
+ packageName: "@qoder-ai/qodercli"
84
+ installSpec: "@qoder-ai/qodercli"
85
+ binName: "qodercli"
86
+ - id: "gemini"
87
+ packageName: "@google/gemini-cli"
88
+ installSpec: "@google/gemini-cli"
89
+ binName: "gemini"
90
+
91
+ - name: "omniroute"
92
+ type: "bundled-runtime"
93
+ source: "desktop-vendored-runtime"
94
+ version: "3.6.9"
95
+ runtimeDataDir: "services/omniroute"
96
+ installScript: "scripts/install-omniroute.mjs"
97
+ configureScript: "scripts/configure-omniroute.mjs"
98
+ pm2:
99
+ appName: "hagicode-omniroute"
100
+ cwd: "."
101
+ script: "current/omniroute-launcher.mjs"
102
+
103
+ - name: "code-server"
104
+ type: "bundled-runtime"
105
+ source: "desktop-vendored-runtime"
106
+ version: "4.117.0"
107
+ runtimeDataDir: "services/code-server"
108
+ installScript: "scripts/install-code-server.mjs"
109
+ configureScript: "scripts/configure-code-server.mjs"
110
+ pm2:
111
+ appName: "hagicode-code-server"
112
+ cwd: "."
113
+ script: "current/code-server-launcher.mjs"
114
+
115
+ phases:
116
+ install:
117
+ order:
118
+ - "node"
119
+ - "dotnet"
120
+ - "npm-packages"
121
+ - "omniroute"
122
+ - "code-server"
123
+ remove:
124
+ order:
125
+ - "code-server"
126
+ - "omniroute"
127
+ - "npm-packages"
128
+ - "dotnet"
129
+ - "node"
130
+ update:
131
+ order:
132
+ - "node"
133
+ - "dotnet"
134
+ - "npm-packages"
135
+ - "omniroute"
136
+ - "code-server"
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env node
2
+ import path from "node:path"
3
+ import process from "node:process"
4
+ import {
5
+ materializeTemplate,
6
+ readRuntimeScriptContext
7
+ } from "../lib/runtime-script-lib.mjs"
8
+
9
+ const context = readRuntimeScriptContext()
10
+ const configPath = path.join(context.componentConfigDir, "config.yaml")
11
+ await materializeTemplate("code-server-config.yaml", configPath, {
12
+ DATA_DIR: context.runtimeDataHome
13
+ })
14
+ process.stdout.write(`Configured code-server template at ${configPath}\n`)
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env node
2
+ import path from "node:path"
3
+ import process from "node:process"
4
+ import {
5
+ materializeTemplate,
6
+ readRuntimeScriptContext
7
+ } from "../lib/runtime-script-lib.mjs"
8
+
9
+ const context = readRuntimeScriptContext()
10
+ const configPath = path.join(context.componentConfigDir, "config.yaml")
11
+ await materializeTemplate("omniroute-config.yaml", configPath, {
12
+ RUNTIME_ROOT: context.runtimeHome,
13
+ DATA_DIR: context.runtimeDataHome,
14
+ LOGS_DIR: context.componentLogsDir
15
+ })
16
+ process.stdout.write(`Configured omniroute template at ${configPath}\n`)
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env node
2
+ import path from "node:path"
3
+ import process from "node:process"
4
+ import {
5
+ ensureDirectory,
6
+ materializeTemplate,
7
+ readRuntimeScriptContext,
8
+ writeCommandWrapper,
9
+ writeComponentMarker,
10
+ writeManagedServiceEntrypoint
11
+ } from "../lib/runtime-script-lib.mjs"
12
+
13
+ const context = readRuntimeScriptContext()
14
+ const currentRoot = path.join(context.componentRoot, "current")
15
+ const launcherPath = path.join(currentRoot, "code-server-launcher.mjs")
16
+ const configPath = path.join(context.componentConfigDir, "config.yaml")
17
+
18
+ await ensureDirectory(currentRoot)
19
+ await materializeTemplate("code-server-config.yaml", configPath, {
20
+ DATA_DIR: context.runtimeDataHome
21
+ })
22
+ await writeManagedServiceEntrypoint(
23
+ launcherPath,
24
+ "code-server"
25
+ )
26
+ await writeCommandWrapper(context.binDir, "code-server", launcherPath)
27
+ await writeComponentMarker(context, {
28
+ configPath,
29
+ launcherPath,
30
+ runtimeHome: context.runtimeHome,
31
+ runtimeDataHome: context.runtimeDataHome,
32
+ pm2Home: context.componentPm2Home,
33
+ ownership: "vendored-runtime"
34
+ })
35
+ process.stdout.write(`Prepared code-server assets in ${currentRoot}\n`)
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env node
2
+ import path from "node:path"
3
+ import process from "node:process"
4
+ import {
5
+ ensureDirectory,
6
+ readRuntimeScriptContext,
7
+ writeComponentMarker,
8
+ writeJsonFile
9
+ } from "../lib/runtime-script-lib.mjs"
10
+
11
+ const context = readRuntimeScriptContext()
12
+ const currentRoot = path.join(context.componentRoot, "current")
13
+
14
+ await ensureDirectory(currentRoot)
15
+ await writeJsonFile(path.join(currentRoot, "runtime-manifest.json"), {
16
+ component: context.componentName,
17
+ channelVersion: context.componentVersion,
18
+ runtimeRoot: context.runtimeRoot
19
+ })
20
+ await writeComponentMarker(context, {
21
+ currentRoot,
22
+ ownership: "hagiscript-managed"
23
+ })
24
+ process.stdout.write(`Prepared .NET runtime placeholder in ${currentRoot}\n`)
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ import process from "node:process"
3
+
4
+ process.stdout.write("node component is managed by the built-in runtime handler\n")
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ import process from "node:process"
3
+
4
+ process.stdout.write("npm package synchronization is managed by the built-in runtime handler\n")
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env node
2
+ import path from "node:path"
3
+ import process from "node:process"
4
+ import {
5
+ ensureDirectory,
6
+ materializeTemplate,
7
+ readRuntimeScriptContext,
8
+ writeCommandWrapper,
9
+ writeComponentMarker,
10
+ writeManagedServiceEntrypoint
11
+ } from "../lib/runtime-script-lib.mjs"
12
+
13
+ const context = readRuntimeScriptContext()
14
+ const currentRoot = path.join(context.componentRoot, "current")
15
+ const launcherPath = path.join(currentRoot, "omniroute-launcher.mjs")
16
+ const configPath = path.join(context.componentConfigDir, "config.yaml")
17
+
18
+ await ensureDirectory(currentRoot)
19
+ await materializeTemplate("omniroute-config.yaml", configPath, {
20
+ RUNTIME_ROOT: context.runtimeHome,
21
+ DATA_DIR: context.runtimeDataHome,
22
+ LOGS_DIR: context.componentLogsDir
23
+ })
24
+ await writeManagedServiceEntrypoint(
25
+ launcherPath,
26
+ "omniroute"
27
+ )
28
+ await writeCommandWrapper(context.binDir, "omniroute", launcherPath)
29
+ await writeComponentMarker(context, {
30
+ configPath,
31
+ launcherPath,
32
+ runtimeHome: context.runtimeHome,
33
+ runtimeDataHome: context.runtimeDataHome,
34
+ pm2Home: context.componentPm2Home,
35
+ ownership: "vendored-runtime"
36
+ })
37
+ process.stdout.write(`Prepared omniroute assets in ${currentRoot}\n`)
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ import process from "node:process"
3
+
4
+ process.stdout.write("npm package removal falls back to managed prefix cleanup when needed\n")
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ import process from "node:process"
3
+
4
+ process.stdout.write("npm package updates are managed by the built-in runtime handler\n")
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env node
2
+ import path from "node:path"
3
+ import { access } from "node:fs/promises"
4
+ import process from "node:process"
5
+ import { readRuntimeScriptContext } from "../lib/runtime-script-lib.mjs"
6
+
7
+ const context = readRuntimeScriptContext()
8
+ const markerPath = path.join(context.componentRoot, ".hagicode-runtime.json")
9
+ await access(markerPath)
10
+ process.stdout.write(`Verified .NET runtime marker at ${markerPath}\n`)
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ import process from "node:process"
3
+
4
+ process.stdout.write("node verification is managed by the built-in runtime handler\n")
@@ -0,0 +1,5 @@
1
+ bind-addr: 127.0.0.1:8080
2
+ auth: none
3
+ user-data-dir: "{{DATA_DIR}}"
4
+ extensions-dir: "{{DATA_DIR}}/extensions"
5
+ log: info
@@ -0,0 +1,4 @@
1
+ runtimeHome: "{{RUNTIME_ROOT}}"
2
+ listen: "127.0.0.1:39001"
3
+ dataDir: "{{DATA_DIR}}"
4
+ logDir: "{{LOGS_DIR}}"