@xrystal/core 3.54.0 → 3.55.4

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/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # @xrystal/core
2
2
 
3
- > **EN** — Microservice runtime: Express or Elysia HTTP, DI loaders, live `tmp.yml`, standardized API responses.
4
- > **TR** — Microservice runtime: Express veya Elysia HTTP, DI loader'lar, canlı `tmp.yml`, standart API cevapları.
3
+ > **EN** — Runtime framework: API services & frontends, workspace CLI, DI loaders, live `tmp.yml`, multi-protocol.
4
+ > **TR** — Runtime framework: API & frontend, workspace CLI, DI loader'lar, canlı `tmp.yml`, çoklu protokol.
5
5
 
6
6
  **CLI:** `xry` · **Version:** `3.52.5` · [npm](https://www.npmjs.com/package/@xrystal/core)
7
7
 
@@ -258,7 +258,7 @@ bun run dev
258
258
  | `xry create <name> --workspace` | Outer `./tmp.yml` + **api/general** + admin/web | Dış tmp + api/general |
259
259
  | `xry tmp` | Inner `x/tmp.yml` or outer workspace tmp; **`end.version` = schema (1)** | tmp.yml · şema sürümü |
260
260
  | `xry sync` | Inner tsconfig + pin `@xrystal/core` + registry (workspace mode) | tsconfig + core pin |
261
- | `xry tp connect` / `xry tp dev <deploy>` | Telepresence cluster connect / local intercept | Telepresence bağlan / local intercept |
261
+ | `xry tp connect --ns dev` / `xry tp intercept <deploy> --ns dev` | Telepresence connect / local intercept (`dev` = alias, not namespace) | Telepresence bağlan / local intercept |
262
262
  | `xry workspaces` | List `~/.xrystal` workspaces + linked projects | Kayıtlı workspace listesi |
263
263
  | `xry dev` | Watch `source/index.ts` + dev env | `source/index.ts` watch + dev env |
264
264
  | `xry build` | `tsc` full tree → dist (auto default) + alias/fix post-steps | `tsc` ile tüm `source/` → dist |
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "author": "Yusuf Yasir KAYGUSUZ",
3
3
  "name": "@xrystal/core",
4
- "version": "3.54.0",
5
- "description": "microservice runtime library",
4
+ "version": "3.55.4",
5
+ "description": "Runtime framework and CLI for API services, frontends, and multi-repo workspaces",
6
6
  "publishConfig": {
7
7
  "access": "public",
8
8
  "registry": "https://registry.npmjs.org/"
@@ -0,0 +1,77 @@
1
+ import chalk from 'chalk'
2
+
3
+ import { printCommandFooter, printCommandHeader } from '../helpers/banner.mjs'
4
+ import { CLI_PRIMARY_NAME } from '../helpers/cli-identity.mjs'
5
+ import { getCliLang, setCliLang, t } from '../helpers/cli-i18n.mjs'
6
+ import { CliLangEnum } from '../helpers/cli-lang.mjs'
7
+ import { readCliPackageJson } from '../helpers/project-root.mjs'
8
+ import {
9
+ clearCliConfigLang,
10
+ configFilePath,
11
+ getCliConfigLang,
12
+ listSupportedCliLangs,
13
+ readXrystalConfig,
14
+ setCliConfigLang,
15
+ } from '../helpers/xrystal-config.mjs'
16
+
17
+ function printConfigDoc(doc) {
18
+ console.log(chalk.gray(` file: ${configFilePath()}`))
19
+ console.log(chalk.bold.white('\n cli'))
20
+ const lang = doc.cli?.lang ?? chalk.dim('(not set — default en)')
21
+ console.log(` lang: ${lang}`)
22
+ if (doc.updatedAt) {
23
+ console.log(chalk.gray(`\n updated: ${doc.updatedAt}`))
24
+ }
25
+ }
26
+
27
+ export function registerConfigCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
28
+ const config = cli
29
+ .command('config')
30
+ .description('~/.xrystal/config.json — persistent CLI preferences')
31
+
32
+ config
33
+ .command('show', { isDefault: true })
34
+ .description('Show ~/.xrystal/config.json')
35
+ .action(() => {
36
+ const version = readCliPackageJson().version
37
+ printCommandHeader({ cliName, command: 'config', version })
38
+ printConfigDoc(readXrystalConfig())
39
+ console.log(chalk.dim(`\n active lang: ${getCliLang()} (session)`))
40
+ printCommandFooter({ version })
41
+ })
42
+
43
+ config
44
+ .command('lang [code]')
45
+ .description('Get or set CLI language (en | tr) — saved to ~/.xrystal/config.json')
46
+ .action((code) => {
47
+ const version = readCliPackageJson().version
48
+ printCommandHeader({ cliName, command: 'config lang', version })
49
+
50
+ if (!code) {
51
+ const saved = getCliConfigLang()
52
+ console.log(chalk.gray(` saved: ${saved ?? 'en (default)'}`))
53
+ console.log(chalk.gray(` active: ${getCliLang()}`))
54
+ console.log(chalk.dim(`\n set: ${cliName} config lang tr`))
55
+ printCommandFooter({ version })
56
+ return
57
+ }
58
+
59
+ if (code === 'reset' || code === 'clear') {
60
+ clearCliConfigLang()
61
+ setCliLang(CliLangEnum.EN)
62
+ console.log(chalk.green(' lang reset → en (default)'))
63
+ printCommandFooter({ version })
64
+ return
65
+ }
66
+
67
+ const supported = listSupportedCliLangs()
68
+ const normalized = setCliConfigLang(code)
69
+ setCliLang(normalized)
70
+ console.log(chalk.green(` lang → ${normalized}`))
71
+ console.log(chalk.gray(` saved: ${configFilePath()}`))
72
+ if (!supported.includes(normalized)) {
73
+ console.log(chalk.yellow(` note: supported: ${supported.join(', ')}`))
74
+ }
75
+ printCommandFooter({ version })
76
+ })
77
+ }
@@ -19,7 +19,10 @@ import { readCliPackageJson } from '../helpers/project-root.mjs'
19
19
  import { setupProjectGitHooks } from '../scripts/install-git-hooks.mjs'
20
20
  import { CLI_PRIMARY_NAME } from '../helpers/cli-identity.mjs'
21
21
  import { scaffoldWorkspace } from '../helpers/workspace-scaffold.mjs'
22
+ import { scaffoldFrontendProject } from '../helpers/scaffold-frontend.mjs'
22
23
  import { syncRegistryFromPath } from '../helpers/xrystal-registry.mjs'
24
+ import { syncOneProject, printSyncProjectResult } from '../helpers/sync-project.mjs'
25
+ import { GlobalTypeEnum, WorkspaceSlotEnum } from '../helpers/cli-enums.mjs'
23
26
 
24
27
  export function registerCreateCommand(cli, { cliName = CLI_PRIMARY_NAME, runtimeName, packageManager, installCommand, devCommand }) {
25
28
  cli
@@ -81,7 +84,7 @@ export function registerCreateCommand(cli, { cliName = CLI_PRIMARY_NAME, runtime
81
84
  console.log(chalk.gray(' registered in ~/.xrystal'))
82
85
  } catch {}
83
86
  console.log(chalk.cyan(` ${cliName} sync --all`))
84
- console.log(chalk.cyan(` ${cliName} telepresence dev general`))
87
+ console.log(chalk.cyan(` ${cliName} tp intercept general --ns dev`))
85
88
  printCommandFooter({ version })
86
89
  } catch (error) {
87
90
  console.error(chalk.red(`\n✗ ${error.message}\n`))
@@ -90,7 +93,6 @@ export function registerCreateCommand(cli, { cliName = CLI_PRIMARY_NAME, runtime
90
93
  return
91
94
  }
92
95
 
93
- const { WorkspaceSlotEnum } = await import('../helpers/cli-enums.mjs')
94
96
  const slot = options.mobile
95
97
  ? WorkspaceSlotEnum.MOBILE
96
98
  : options.web
@@ -139,25 +141,45 @@ export function registerCreateCommand(cli, { cliName = CLI_PRIMARY_NAME, runtime
139
141
  if (entries.length === 0) fs.rmdirSync(targetPath)
140
142
  }
141
143
 
142
- const spinner = ora(`${runtimeName} — cloning template...`).start()
144
+ const isFrontendSlot = slot === WorkspaceSlotEnum.WEB || slot === WorkspaceSlotEnum.MOBILE
145
+ const spinner = ora(
146
+ isFrontendSlot
147
+ ? `${runtimeName} — scaffolding frontend...`
148
+ : `${runtimeName} — cloning template...`,
149
+ ).start()
143
150
 
144
151
  try {
145
- if (isCurrentDir) {
146
- execSync(`git clone --depth 1 ${Constants.templateRepoUri} .`, { cwd: targetPath, stdio: 'ignore' })
152
+ let tmpResult
153
+ if (isFrontendSlot) {
154
+ if (!isCurrentDir) {
155
+ fs.mkdirSync(path.dirname(targetPath), { recursive: true })
156
+ }
157
+ const coreVersion = readCliPackageJson().version
158
+ const frontend = scaffoldFrontendProject(isCurrentDir ? targetPath : targetPath, {
159
+ projectName: name,
160
+ coreVersion,
161
+ installCommand,
162
+ cliName,
163
+ })
164
+ tmpResult = { tmpFilePath: frontend.tmpFilePath, created: true }
147
165
  } else {
148
- fs.mkdirSync(path.dirname(targetPath), { recursive: true })
149
- execSync(`git clone --depth 1 ${Constants.templateRepoUri} "${targetPath}"`, { stdio: 'ignore' })
150
- }
166
+ if (isCurrentDir) {
167
+ execSync(`git clone --depth 1 ${Constants.templateRepoUri} .`, { cwd: targetPath, stdio: 'ignore' })
168
+ } else {
169
+ fs.mkdirSync(path.dirname(targetPath), { recursive: true })
170
+ execSync(`git clone --depth 1 ${Constants.templateRepoUri} "${targetPath}"`, { stdio: 'ignore' })
171
+ }
151
172
 
152
- const gitFolder = path.join(targetPath, '.git')
153
- if (fs.existsSync(gitFolder)) fs.rmSync(gitFolder, { recursive: true, force: true })
173
+ const gitFolder = path.join(targetPath, '.git')
174
+ if (fs.existsSync(gitFolder)) fs.rmSync(gitFolder, { recursive: true, force: true })
154
175
 
155
- try {
156
- execSync('git init', { cwd: targetPath, stdio: 'ignore' })
157
- } catch {
158
- }
176
+ try {
177
+ execSync('git init', { cwd: targetPath, stdio: 'ignore' })
178
+ } catch {
179
+ }
159
180
 
160
- const tmpResult = ensureTmpFile(targetPath)
181
+ tmpResult = ensureTmpFile(targetPath)
182
+ }
161
183
  const parsedTmp = yaml.parse(fs.readFileSync(tmpResult.tmpFilePath, 'utf8'))
162
184
  const resolvedTmp = resolveObjWithHandlebars(parsedTmp, parsedTmp)
163
185
  const mainPath = resolveMainFolderPath(resolvedTmp?.configs)
@@ -167,10 +189,12 @@ export function registerCreateCommand(cli, { cliName = CLI_PRIMARY_NAME, runtime
167
189
  fs.mkdirSync(projectMainFolderPath, { recursive: true })
168
190
  }
169
191
 
170
- spinner.succeed(chalk.green('Template cloned and git initialized'))
171
- console.log(chalk.blue(`\n📦 Installing dependencies (${packageManager})...`))
192
+ spinner.succeed(chalk.green(isFrontendSlot ? 'Frontend scaffold ready' : 'Template cloned and git initialized'))
172
193
 
173
- execSync(installCommand, { cwd: targetPath, stdio: 'inherit' })
194
+ if (!isFrontendSlot) {
195
+ console.log(chalk.blue(`\n📦 Installing dependencies (${packageManager})...`))
196
+ execSync(installCommand, { cwd: targetPath, stdio: 'inherit' })
197
+ }
174
198
 
175
199
  try {
176
200
  const hookResult = setupProjectGitHooks(targetPath, { cliName })
@@ -206,14 +230,29 @@ export function registerCreateCommand(cli, { cliName = CLI_PRIMARY_NAME, runtime
206
230
  console.log('')
207
231
  }
208
232
 
233
+ const coreVersion = readCliPackageJson().version
234
+ const syncResult = syncOneProject({
235
+ path: targetPath,
236
+ name,
237
+ type: isFrontendSlot ? GlobalTypeEnum.FRONTEND : GlobalTypeEnum.API_SERVICE,
238
+ slot,
239
+ tmp: tmpResult.tmpFilePath,
240
+ }, coreVersion, { tmpPath: tmpResult.tmpFilePath, tmpCreated: Boolean(tmpResult.created) })
241
+ if (!syncResult.failed) {
242
+ console.log(chalk.gray('\n sync (toolchain + core pin):'))
243
+ printSyncProjectResult(syncResult)
244
+ }
245
+
209
246
  if (inWorkspace) {
210
247
  try {
211
248
  syncRegistryFromPath(workspaceRoot)
212
249
  console.log(chalk.gray(' registered in ~/.xrystal'))
213
250
  } catch {
214
251
  }
215
- console.log(chalk.gray(` next: ${cliName} sync --all (from workspace root)`))
216
- printCommandFooter({ version: readCliPackageJson().version })
252
+ if (!isFrontendSlot) {
253
+ console.log(chalk.gray(` next: ${cliName} sync --all (from workspace root)`))
254
+ }
255
+ printCommandFooter({ version: coreVersion })
217
256
  }
218
257
 
219
258
  const relativePath = path.relative(process.cwd(), targetPath)
@@ -0,0 +1,23 @@
1
+ import chalk from 'chalk'
2
+
3
+ import { printCommandFooter, printCommandHeader } from '../helpers/banner.mjs'
4
+ import { CLI_PRIMARY_NAME } from '../helpers/cli-identity.mjs'
5
+ import { formatScopeGuide, formatSyncHelp } from '../helpers/cli-help.mjs'
6
+ import { getCliLang, t } from '../helpers/cli-i18n.mjs'
7
+ import { readCliPackageJson } from '../helpers/project-root.mjs'
8
+
9
+ export function registerGuideCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
10
+ cli
11
+ .command('guide')
12
+ .description('Scope guide — standalone vs workspace commands (en | tr via xry config lang)')
13
+ .option('--lang <code>', 'CLI language: en | tr')
14
+ .action(() => {
15
+ const version = readCliPackageJson().version
16
+ printCommandHeader({ cliName, command: 'guide', version })
17
+ console.log(chalk.gray(` lang: ${getCliLang()}`))
18
+ console.log(formatScopeGuide({ cliName }))
19
+ console.log(formatSyncHelp({ cliName }))
20
+ console.log(chalk.dim(` ${t('tips.guide')}`))
21
+ printCommandFooter({ version })
22
+ })
23
+ }
@@ -4,11 +4,11 @@ import path from 'node:path'
4
4
  import { printCommandFooter, printCommandHeader } from '../helpers/banner.mjs'
5
5
  import { CLI_PRIMARY_NAME } from '../helpers/cli-identity.mjs'
6
6
  import { readCliPackageJson } from '../helpers/project-root.mjs'
7
- import { ensureTmpFile } from '../helpers/tmp-layout.mjs'
8
7
  import { ensureTmpSchemaVersion } from '../helpers/tmp-schema-version.mjs'
9
8
  import { resolveSyncScope } from '../helpers/sync-scope.mjs'
10
9
  import { runWorkspaceSelfHeal } from '../helpers/workspace-heal.mjs'
11
10
  import { printSyncProjectResult, syncOneProject } from '../helpers/sync-project.mjs'
11
+ import { ensureSyncProjectTmp, previewSyncProjectTmp } from '../helpers/sync-tmp.mjs'
12
12
  import { formatSyncHelp } from '../helpers/cli-help.mjs'
13
13
 
14
14
  /** Sync tsconfig + @xrystal/core pin from tmp.yml layout. */
@@ -69,17 +69,22 @@ export function registerSyncCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
69
69
  let failed = 0
70
70
  for (const entry of scope.entries) {
71
71
  if (options.dryRun) {
72
- const preview = syncOneProject(entry, coreVersion, { dryRun: true, tmpPath: entry.tmp ?? null })
72
+ const tmpPreview = previewSyncProjectTmp(entry)
73
+ const preview = syncOneProject(entry, coreVersion, {
74
+ dryRun: true,
75
+ tmpPath: tmpPreview.tmpPath,
76
+ tmpWouldCreate: tmpPreview.wouldCreate,
77
+ })
73
78
  printSyncProjectResult(preview)
74
79
  continue
75
80
  }
76
81
 
77
- let tmpPath = entry.tmp ?? null
78
- if (!tmpPath && scope.mode === 'standalone') {
79
- tmpPath = ensureTmpFile(entry.path).tmpFilePath
80
- }
81
-
82
- const result = syncOneProject(entry, coreVersion, { dryRun: false, tmpPath })
82
+ const ensured = ensureSyncProjectTmp(entry)
83
+ const result = syncOneProject(entry, coreVersion, {
84
+ dryRun: false,
85
+ tmpPath: ensured.tmpPath,
86
+ tmpCreated: ensured.created,
87
+ })
83
88
  printSyncProjectResult(result)
84
89
  if (result.failed) failed += 1
85
90
  }
@@ -1,11 +1,11 @@
1
1
  import { execSync } from 'node:child_process'
2
- import fs from 'node:fs'
3
2
  import path from 'node:path'
4
3
  import chalk from 'chalk'
5
4
 
6
5
  import { printCommandFooter, printCommandHeader } from '../helpers/banner.mjs'
7
6
  import { CLI_PRIMARY_NAME } from '../helpers/cli-identity.mjs'
8
7
  import { readCliPackageJson } from '../helpers/project-root.mjs'
8
+ import { resolveInfraHelperScript } from '../helpers/resolve-infra-helper.mjs'
9
9
  import {
10
10
  ensureServiceTelepresenceEnv,
11
11
  resolveTelepresenceServiceDir,
@@ -13,21 +13,6 @@ import {
13
13
  } from '../helpers/telepresence-layout.mjs'
14
14
  import { findWorkspaceRoot } from '../helpers/workspace-resolve.mjs'
15
15
 
16
- function resolveInfraHelper(name) {
17
- const envRoot = process.env.XRYSTAL_INFRA_DIR ?? process.env.XRYSTAL_INFRA_ROOT
18
- const candidates = [
19
- envRoot,
20
- path.resolve(process.cwd(), '../-infrastructure-'),
21
- path.resolve(process.cwd(), '../../-infrastructure-'),
22
- ].filter(Boolean)
23
-
24
- for (const root of candidates) {
25
- const script = path.join(root, 'scripts', 'helpers', name)
26
- if (fs.existsSync(script)) return script
27
- }
28
- return null
29
- }
30
-
31
16
  function runHelper(scriptPath, args, { cwd } = {}) {
32
17
  execSync(`bash "${scriptPath}" ${args.map((a) => JSON.stringify(a)).join(' ')}`, {
33
18
  cwd: cwd ?? process.cwd(),
@@ -36,37 +21,49 @@ function runHelper(scriptPath, args, { cwd } = {}) {
36
21
  })
37
22
  }
38
23
 
24
+ function requireInfraScript(name) {
25
+ const script = resolveInfraHelperScript(name)
26
+ if (!script) {
27
+ console.error(chalk.red(`\n✗ ${name} not found — set XRYSTAL_INFRA_DIR to -infrastructure- repo\n`))
28
+ process.exit(1)
29
+ }
30
+ return script
31
+ }
32
+
33
+ function parsePort(value) {
34
+ return value && /^\d+$/.test(String(value)) ? String(value) : '3000'
35
+ }
36
+
39
37
  export function registerTelepresenceCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
40
38
  const tp = cli
41
39
  .command('telepresence')
42
40
  .alias('tp')
43
- .description('Local Telepresence intercept against cluster (dev/test)')
41
+ .description('Local Telepresence intercept against cluster (dev/test namespaces)')
44
42
  .addHelpText(
45
43
  'after',
46
44
  `
47
45
  ${chalk.gray('Examples:')}
48
- ${cliName} telepresence connect
49
- ${cliName} tp dev general
50
- ${cliName} tp dev gateway 3000
46
+ ${cliName} tp connect --ns dev
47
+ ${cliName} tp intercept general --ns dev
48
+ ${cliName} tp dev gateway 3000 --ns test
51
49
  ${cliName} telepresence quit
50
+ ${cliName} tp install
52
51
 
53
- ${chalk.gray('Deploy names:')} ${TELEPRESENCE_DEPLOYMENTS.join(', ')}
54
- ${chalk.gray('Set')} XRYSTAL_INFRA_DIR ${chalk.gray('to point at -infrastructure- repo (optional).')}
52
+ ${chalk.gray('intercept/dev')} = local intercept + run process (NOT the k8s namespace)
53
+ ${chalk.gray('--ns')} = Kubernetes namespace (default: dev)
54
+ ${chalk.gray('<deploy>')} = ${TELEPRESENCE_DEPLOYMENTS.join(', ')}
55
+ ${chalk.gray('Infra scripts:')} XRYSTAL_INFRA_DIR ${chalk.gray('or sibling')} ../-infrastructure-
55
56
  `,
56
57
  )
57
58
 
58
59
  tp
59
60
  .command('connect')
60
- .description('Connect local machine to cluster namespace (default NS=dev)')
61
+ .description('Connect local machine to cluster namespace')
61
62
  .option('--ns <namespace>', 'Kubernetes namespace', 'dev')
62
63
  .action((options) => {
63
64
  const version = readCliPackageJson().version
64
65
  printCommandHeader({ cliName, command: 'telepresence connect', version })
65
- const script = resolveInfraHelper('telepresence-connect.sh')
66
- if (!script) {
67
- console.error(chalk.red('\n✗ telepresence-connect.sh not found — set XRYSTAL_INFRA_DIR\n'))
68
- process.exit(1)
69
- }
66
+ const script = requireInfraScript('telepresence-connect.sh')
70
67
  process.env.NS = options.ns
71
68
  runHelper(script, [`NS=${options.ns}`])
72
69
  printCommandFooter({ version })
@@ -78,29 +75,43 @@ export function registerTelepresenceCommand(cli, { cliName = CLI_PRIMARY_NAME }
78
75
  .action(() => {
79
76
  const version = readCliPackageJson().version
80
77
  printCommandHeader({ cliName, command: 'telepresence quit', version })
81
- const script = resolveInfraHelper('telepresence-quit.sh')
82
- if (!script) {
83
- console.error(chalk.red('\n✗ telepresence-quit.sh not found — set XRYSTAL_INFRA_DIR\n'))
84
- process.exit(1)
85
- }
78
+ const script = requireInfraScript('telepresence-quit.sh')
86
79
  runHelper(script, [])
87
80
  printCommandFooter({ version })
88
81
  })
89
82
 
90
83
  tp
91
- .command('dev <deploy> [port]')
92
- .description('Intercept cluster deployment and run local dev server')
84
+ .command('install')
85
+ .description('Install Telepresence OSS client (~2.31.x, matches cluster chart)')
86
+ .action(() => {
87
+ const version = readCliPackageJson().version
88
+ printCommandHeader({ cliName, command: 'telepresence install', version })
89
+ const script = requireInfraScript('telepresence-client-install.sh')
90
+ runHelper(script, [])
91
+ printCommandFooter({ version })
92
+ })
93
+
94
+ const intercept = tp
95
+ .command('intercept')
96
+ .alias('dev')
97
+ .description('Intercept cluster deployment and run local process (--ns = k8s namespace, not this subcommand name)')
98
+ .argument('<deploy>', `Deployment name (${TELEPRESENCE_DEPLOYMENTS.join(', ')})`)
99
+ .argument('[port]', 'Local listen port', '3000')
100
+ .option('--ns <namespace>', 'Kubernetes namespace', 'dev')
93
101
  .allowUnknownOption()
94
- .action((deploy, port, _options, command) => {
102
+ .allowExcessArguments()
103
+ .action((deploy, port, options, command) => {
95
104
  const version = readCliPackageJson().version
96
105
  const deployName = String(deploy ?? '').trim()
106
+ const ns = String(options.ns ?? 'dev').trim() || 'dev'
107
+
97
108
  if (!TELEPRESENCE_DEPLOYMENTS.includes(deployName)) {
98
109
  console.error(chalk.red(`\n✗ Unknown deploy "${deployName}"\n`))
99
110
  console.error(chalk.gray(` Use: ${TELEPRESENCE_DEPLOYMENTS.join(', ')}\n`))
100
111
  process.exit(1)
101
112
  }
102
113
 
103
- printCommandHeader({ cliName, command: `telepresence dev ${deployName}`, version })
114
+ printCommandHeader({ cliName, command: `telepresence intercept ${deployName}`, version })
104
115
 
105
116
  const workspaceRoot = findWorkspaceRoot(process.cwd())
106
117
  let svcDir = resolveTelepresenceServiceDir(workspaceRoot ?? process.cwd(), deployName)
@@ -111,24 +122,24 @@ export function registerTelepresenceCommand(cli, { cliName = CLI_PRIMARY_NAME }
111
122
  svcDir = process.cwd()
112
123
  }
113
124
 
114
- ensureServiceTelepresenceEnv(svcDir)
125
+ const env = ensureServiceTelepresenceEnv(svcDir)
126
+ process.env.TELEPRESENCE_ENV_FILE = env.envRel
127
+ process.env.NS = ns
128
+ if (workspaceRoot) process.env.XRYSTAL_WORKSPACE = workspaceRoot
129
+
130
+ console.log(chalk.gray(` deploy: ${deployName}`))
131
+ console.log(chalk.gray(` ns: ${ns}`))
115
132
  console.log(chalk.gray(` service: ${svcDir}`))
116
- console.log(chalk.gray(` env: x/environments/.env.telepresence\n`))
133
+ console.log(chalk.gray(` env: ${env.envRel}${env.created ? chalk.green(' (created)') : ''}\n`))
117
134
 
118
- const intercept = resolveInfraHelper('telepresence-intercept.sh')
119
- if (!intercept) {
120
- console.error(chalk.red('\n✗ telepresence-intercept.sh not found — set XRYSTAL_INFRA_DIR\n'))
121
- process.exit(1)
122
- }
135
+ const interceptScript = requireInfraScript('telepresence-intercept.sh')
123
136
 
124
- const portArg = port && /^\d+$/.test(String(port)) ? String(port) : '3000'
125
- const rest = command.args.slice(port && /^\d+$/.test(String(port)) ? 2 : 1)
137
+ const portArg = parsePort(port)
138
+ const rest = command.args.slice(/^\d+$/.test(String(port ?? '')) ? 2 : 1)
126
139
  const localCmd = rest.length ? rest : ['bun', 'run', 'dev']
127
- const args = [deployName, portArg, '--', ...localCmd]
140
+ const args = [`NS=${ns}`, deployName, portArg, '--', ...localCmd]
128
141
 
129
- process.env.NS = process.env.NS ?? 'dev'
130
- if (workspaceRoot) process.env.XRYSTAL_WORKSPACE = workspaceRoot
131
- runHelper(intercept, args, { cwd: svcDir })
142
+ runHelper(interceptScript, args, { cwd: svcDir })
132
143
  printCommandFooter({ version })
133
144
  })
134
145
  }
@@ -14,7 +14,6 @@ import {
14
14
  } from '../helpers/tmp-layout.mjs'
15
15
  import { formatLoaderSummary, summarizeLoaders } from '../helpers/tmp-config.mjs'
16
16
  import { packageDefaults } from '../helpers/package-defaults.mjs'
17
- import { ensureTmpSchemaVersion, readTmpSchemaVersion } from '../helpers/tmp-schema-version.mjs'
18
17
  import { getCliContext } from '../helpers/cli-context-guard.mjs'
19
18
  import { ensureOuterWorkspaceTmp } from '../helpers/workspace-tmp.mjs'
20
19
  import { ProjectScopeKindEnum } from '../helpers/cli-enums.mjs'
@@ -26,17 +25,15 @@ function ensureTmpForContext(ctx) {
26
25
  tmpFilePath: outer.tmpFilePath,
27
26
  created: outer.created,
28
27
  layout: null,
29
- schema: outer.schema,
30
28
  }
31
29
  }
32
- const result = ensureTmpFile(ctx.projectRoot)
33
- return { ...result, schema: ensureTmpSchemaVersion(result.tmpFilePath) }
30
+ return ensureTmpFile(ctx.projectRoot)
34
31
  }
35
32
 
36
33
  export function registerTmpCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
37
34
  cli
38
35
  .command('tmp')
39
- .description('Ensure tmp.yml for current scope (outer workspace or inner service)')
36
+ .description('Create missing tmp.yml and show loader profile for current scope')
40
37
  .option('--dry-run', 'Show target path without writing')
41
38
  .action((options) => {
42
39
  const ctx = getCliContext()
@@ -64,14 +61,6 @@ export function registerTmpCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
64
61
  console.log(chalk.gray(` root: ${root}`))
65
62
  console.log(result.created ? chalk.green(` created ${rel}`) : chalk.gray(` ok ${rel}`))
66
63
 
67
- const schemaVersion = readTmpSchemaVersion(result.tmpFilePath)
68
- if (schemaVersion) {
69
- const schemaLabel = result.schema?.patched
70
- ? chalk.green(` end.version → ${schemaVersion} (schema)`)
71
- : chalk.gray(` end.version: ${schemaVersion} (schema)`)
72
- console.log(schemaLabel)
73
- }
74
-
75
64
  if (ctx.kind !== ProjectScopeKindEnum.WORKSPACE_ROOT) {
76
65
  try {
77
66
  const tmp = yaml.parse(fs.readFileSync(result.tmpFilePath, 'utf8'))
@@ -12,6 +12,11 @@ import {
12
12
  watchDaemonStatus,
13
13
  watchLogPath,
14
14
  } from '../helpers/xrystal-watch-spawn.mjs'
15
+ import {
16
+ installWatchService,
17
+ uninstallWatchService,
18
+ watchServiceStatus,
19
+ } from '../helpers/xrystal-watch-service.mjs'
15
20
 
16
21
  export function registerWatchCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
17
22
  const watch = cli
@@ -88,4 +93,58 @@ export function registerWatchCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
88
93
  .action(() => {
89
94
  ensureWatchDaemon({ quiet: false })
90
95
  })
96
+
97
+ watch
98
+ .command('install')
99
+ .description('Install OS service (macOS launchd / Linux systemd user) — survives reboot')
100
+ .action(() => {
101
+ const version = readCliPackageJson().version
102
+ printCommandHeader({ cliName, command: 'watch install', version })
103
+ try {
104
+ const result = installWatchService()
105
+ console.log(chalk.green(` ${result.platform} service installed`))
106
+ console.log(chalk.gray(` unit: ${result.unitPath}`))
107
+ console.log(chalk.gray(` log: ${watchLogPath()}`))
108
+ } catch (error) {
109
+ console.error(chalk.red(`\n✗ ${error.message}\n`))
110
+ process.exit(1)
111
+ }
112
+ printCommandFooter({ version })
113
+ })
114
+
115
+ watch
116
+ .command('uninstall')
117
+ .description('Remove OS service (launchd / systemd user)')
118
+ .action(() => {
119
+ const version = readCliPackageJson().version
120
+ printCommandHeader({ cliName, command: 'watch uninstall', version })
121
+ try {
122
+ const result = uninstallWatchService()
123
+ console.log(chalk.green(` ${result.platform} service removed`))
124
+ } catch (error) {
125
+ console.error(chalk.red(`\n✗ ${error.message}\n`))
126
+ process.exit(1)
127
+ }
128
+ printCommandFooter({ version })
129
+ })
130
+
131
+ watch
132
+ .command('service')
133
+ .description('Show launchd/systemd install state')
134
+ .action(() => {
135
+ const version = readCliPackageJson().version
136
+ printCommandHeader({ cliName, command: 'watch service', version })
137
+ const svc = watchServiceStatus()
138
+ if (!svc.platform) {
139
+ console.log(chalk.yellow(' OS service not supported on this platform'))
140
+ } else if (!svc.installed) {
141
+ console.log(chalk.yellow(` not installed (${svc.platform})`))
142
+ console.log(chalk.dim(`\n tip: ${cliName} watch install`))
143
+ } else {
144
+ console.log(chalk.gray(` platform: ${svc.platform}`))
145
+ console.log(chalk.gray(` unit: ${svc.unitPath}`))
146
+ console.log(svc.running ? chalk.green(' running') : chalk.yellow(' installed (not active)'))
147
+ }
148
+ printCommandFooter({ version })
149
+ })
91
150
  }
@@ -16,6 +16,7 @@ var defaults_default = {
16
16
  tmpExtension: ".yml",
17
17
  tmpSchemaVersion: 1,
18
18
  apiServiceTemplateRel: "x/templates/api-service/tmp.yml",
19
+ frontendTemplateRel: "x/templates/frontend/tmp.yml",
19
20
  templateRepoUri: "https://github.com/xdloper/api-gpt-svc",
20
21
  publicFolderName: "public",
21
22
  kafkaLogsTopic: "log",
@@ -24,8 +25,8 @@ var defaults_default = {
24
25
  brand: {
25
26
  primary: "xrystal",
26
27
  secondary: "core",
27
- tagline: "microservice runtime library",
28
- capabilities: "loaders · tmp.yml · dto · i18n · multi-protocol · scaffold"
28
+ tagline: "runtime framework for APIs, frontends & workspaces",
29
+ capabilities: "loaders · tmp.yml · workspace · dto · i18n · multi-protocol · scaffold"
29
30
  },
30
31
  runtimes: {
31
32
  bun: {
@@ -11,6 +11,7 @@ var defaults_default = {
11
11
  tmpExtension: ".yml",
12
12
  tmpSchemaVersion: 1,
13
13
  apiServiceTemplateRel: "x/templates/api-service/tmp.yml",
14
+ frontendTemplateRel: "x/templates/frontend/tmp.yml",
14
15
  templateRepoUri: "https://github.com/xdloper/api-gpt-svc",
15
16
  publicFolderName: "public",
16
17
  kafkaLogsTopic: "log",
@@ -19,8 +20,8 @@ var defaults_default = {
19
20
  brand: {
20
21
  primary: "xrystal",
21
22
  secondary: "core",
22
- tagline: "microservice runtime library",
23
- capabilities: "loaders · tmp.yml · dto · i18n · multi-protocol · scaffold"
23
+ tagline: "runtime framework for APIs, frontends & workspaces",
24
+ capabilities: "loaders · tmp.yml · workspace · dto · i18n · multi-protocol · scaffold"
24
25
  },
25
26
  runtimes: {
26
27
  bun: {