@agimon-ai/po 0.0.0-alpha.2 → 0.0.0-alpha.21
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 +14 -11
- package/dist/antigravity.mjs +1 -2
- package/dist/baseCommand.mjs +1 -2
- package/dist/bin/cli.cjs +37 -14
- package/dist/bin/cli.cjs.map +1 -1
- package/dist/bin/cli.mjs +34 -14
- package/dist/bin/cli.mjs.map +1 -1
- package/dist/bin/{doomRunner.cjs → poRunner.cjs} +5 -5
- package/dist/bin/poRunner.cjs.map +1 -0
- package/dist/bin/{doomRunner.d.mts → poRunner.d.mts} +2 -2
- package/dist/bin/poRunner.d.mts.map +1 -0
- package/dist/bin/{doomRunner.mjs → poRunner.mjs} +5 -5
- package/dist/bin/poRunner.mjs.map +1 -0
- package/dist/builders/cli/extensionAssembler/index.cjs +14 -12
- package/dist/builders/cli/extensionAssembler/index.cjs.map +1 -1
- package/dist/builders/cli/extensionAssembler/index.d.mts +2 -1
- package/dist/builders/cli/extensionAssembler/index.d.mts.map +1 -1
- package/dist/builders/cli/extensionAssembler/index.mjs +14 -12
- package/dist/builders/cli/extensionAssembler/index.mjs.map +1 -1
- package/dist/catalog/index.json +68 -51
- package/dist/cliApp.mjs +1 -2
- package/dist/codex.mjs +1 -2
- package/dist/compatibilityCommand.mjs +1 -2
- package/dist/compatibilityContext.mjs +1 -2
- package/dist/compatibilityOptions.mjs +1 -2
- package/dist/config.cjs +57 -12
- package/dist/config.d.mts +3 -3
- package/dist/config.mjs +3 -3
- package/dist/doctorCommand.mjs +1 -2
- package/dist/emitMcpCommand.mjs +1 -2
- package/dist/explainCommand.mjs +1 -2
- package/dist/extensions/server.cjs +11 -7
- package/dist/extensions/server.cjs.map +1 -1
- package/dist/extensions/server.d.mts +2 -2
- package/dist/extensions/server.d.mts.map +1 -1
- package/dist/extensions/server.mjs +12 -8
- package/dist/extensions/server.mjs.map +1 -1
- package/dist/harnessContext.mjs +1 -2
- package/dist/harnessState.cjs +66 -11
- package/dist/harnessState.d.mts +2 -2
- package/dist/harnessState.mjs +1 -2
- package/dist/index.cjs +60 -15
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +3 -3
- package/dist/initCommand.mjs +1 -2
- package/dist/matrixOptions.mjs +1 -2
- package/dist/options.mjs +1 -2
- package/dist/process.mjs +1 -2
- package/dist/projectTrust.cjs +2 -2
- package/dist/projectTrust.d.mts +2 -2
- package/dist/projectTrust.mjs +1 -2
- package/dist/repository.cjs +1 -1
- package/dist/repository.d.mts +2 -2
- package/dist/repository.mjs +1 -2
- package/dist/router.mjs +1 -2
- package/dist/shared.mjs +1 -2
- package/dist/src/bin/agentDirectory.cjs +18 -12
- package/dist/src/bin/agentDirectory.cjs.map +1 -1
- package/dist/src/bin/agentDirectory.mjs +15 -12
- package/dist/src/bin/agentDirectory.mjs.map +1 -1
- package/dist/src/builders/apiContractExport/index.cjs +6 -6
- package/dist/src/builders/apiContractExport/index.cjs.map +1 -1
- package/dist/src/builders/apiContractExport/index.mjs +9 -9
- package/dist/src/builders/apiContractExport/index.mjs.map +1 -1
- package/dist/src/builders/cli/entryResolution.cjs +3 -3
- package/dist/src/builders/cli/entryResolution.cjs.map +1 -1
- package/dist/src/builders/cli/entryResolution.mjs +3 -3
- package/dist/src/builders/cli/entryResolution.mjs.map +1 -1
- package/dist/src/builders/cli/harnessContext.cjs +5 -5
- package/dist/src/builders/cli/harnessContext.cjs.map +1 -1
- package/dist/src/builders/cli/harnessContext.mjs +7 -7
- package/dist/src/builders/cli/harnessContext.mjs.map +1 -1
- package/dist/src/builders/hooks/index.cjs +1 -1
- package/dist/src/builders/hooks/index.cjs.map +1 -1
- package/dist/src/builders/hooks/index.mjs +2 -2
- package/dist/src/builders/hooks/index.mjs.map +1 -1
- package/dist/src/builders/server/backgroundSync.cjs +13 -1
- package/dist/src/builders/server/backgroundSync.cjs.map +1 -1
- package/dist/src/builders/server/backgroundSync.mjs +13 -1
- package/dist/src/builders/server/backgroundSync.mjs.map +1 -1
- package/dist/src/builders/server/bundlerService.cjs +151 -0
- package/dist/src/builders/server/bundlerService.cjs.map +1 -0
- package/dist/src/builders/server/bundlerService.mjs +151 -0
- package/dist/src/builders/server/bundlerService.mjs.map +1 -0
- package/dist/src/builders/server/computerUseBinding.cjs +2 -2
- package/dist/src/builders/server/computerUseBinding.cjs.map +1 -1
- package/dist/src/builders/server/computerUseBinding.mjs +3 -3
- package/dist/src/builders/server/computerUseBinding.mjs.map +1 -1
- package/dist/src/builders/server/defaultWorkspace.cjs +1 -1
- package/dist/src/builders/server/defaultWorkspace.cjs.map +1 -1
- package/dist/src/builders/server/defaultWorkspace.mjs +2 -2
- package/dist/src/builders/server/defaultWorkspace.mjs.map +1 -1
- package/dist/src/builders/server/idleRestart.cjs +3 -3
- package/dist/src/builders/server/idleRestart.cjs.map +1 -1
- package/dist/src/builders/server/idleRestart.mjs +3 -3
- package/dist/src/builders/server/idleRestart.mjs.map +1 -1
- package/dist/src/builders/server/index.cjs +6 -6
- package/dist/src/builders/server/index.cjs.map +1 -1
- package/dist/src/builders/server/index.mjs +6 -6
- package/dist/src/builders/server/index.mjs.map +1 -1
- package/dist/src/builders/server/logSink.cjs +3 -3
- package/dist/src/builders/server/logSink.cjs.map +1 -1
- package/dist/src/builders/server/logSink.mjs +2 -2
- package/dist/src/builders/server/logSink.mjs.map +1 -1
- package/dist/src/builders/server/mcpBundle.cjs.map +1 -1
- package/dist/src/builders/server/mcpBundle.d.mts +2 -2
- package/dist/src/builders/server/mcpBundle.mjs.map +1 -1
- package/dist/src/builders/server/packageUrl.cjs +25 -18
- package/dist/src/builders/server/packageUrl.cjs.map +1 -1
- package/dist/src/builders/server/packageUrl.mjs +25 -18
- package/dist/src/builders/server/packageUrl.mjs.map +1 -1
- package/dist/src/builders/server/runtime.cjs +157 -168
- package/dist/src/builders/server/runtime.cjs.map +1 -1
- package/dist/src/builders/server/runtime.mjs +161 -171
- package/dist/src/builders/server/runtime.mjs.map +1 -1
- package/dist/src/builders/server/selectionStatus.cjs +3 -3
- package/dist/src/builders/server/selectionStatus.cjs.map +1 -1
- package/dist/src/builders/server/selectionStatus.mjs +3 -3
- package/dist/src/builders/server/selectionStatus.mjs.map +1 -1
- package/dist/src/builders/server/sessionArguments.cjs.map +1 -1
- package/dist/src/builders/server/sessionArguments.mjs.map +1 -1
- package/dist/src/builders/server/watcherService.cjs +65 -0
- package/dist/src/builders/server/watcherService.cjs.map +1 -0
- package/dist/src/builders/server/watcherService.mjs +61 -0
- package/dist/src/builders/server/watcherService.mjs.map +1 -0
- package/dist/src/builders/server/webTemplateDecision.cjs +1 -1
- package/dist/src/builders/server/webTemplateDecision.cjs.map +1 -1
- package/dist/src/builders/server/webTemplateDecision.mjs +2 -2
- package/dist/src/builders/server/webTemplateDecision.mjs.map +1 -1
- package/dist/src/builders/web/bundle.cjs.map +1 -1
- package/dist/src/builders/web/bundle.d.mts +4 -3
- package/dist/src/builders/web/bundle.mjs.map +1 -1
- package/dist/src/builders/web/bundleAssetPolicy.d.mts +1 -0
- package/dist/src/builders/web/index.cjs +1 -1
- package/dist/src/builders/web/index.cjs.map +1 -1
- package/dist/src/builders/web/index.d.mts +1 -0
- package/dist/src/builders/web/index.mjs +1 -1
- package/dist/src/builders/web/index.mjs.map +1 -1
- package/dist/src/builders/web/webPluginGenerate.cjs +4 -15
- package/dist/src/builders/web/webPluginGenerate.cjs.map +1 -1
- package/dist/src/builders/web/webPluginGenerate.d.mts +5 -9
- package/dist/src/builders/web/webPluginGenerate.d.mts.map +1 -1
- package/dist/src/builders/web/webPluginGenerate.mjs +4 -15
- package/dist/src/builders/web/webPluginGenerate.mjs.map +1 -1
- package/dist/src/builders/web/webPluginVite.d.mts +1 -0
- package/dist/src/cli/cliApp.cjs +1 -1
- package/dist/src/cli/cliApp.cjs.map +1 -1
- package/dist/src/cli/cliApp.mjs +1 -1
- package/dist/src/cli/cliApp.mjs.map +1 -1
- package/dist/src/cli/commands/compat/index.cjs +1 -1
- package/dist/src/cli/commands/compat/index.cjs.map +1 -1
- package/dist/src/cli/commands/compat/index.mjs +1 -1
- package/dist/src/cli/commands/compat/index.mjs.map +1 -1
- package/dist/src/cli/commands/doctor/index.cjs +2 -2
- package/dist/src/cli/commands/doctor/index.cjs.map +1 -1
- package/dist/src/cli/commands/doctor/index.d.mts +1 -0
- package/dist/src/cli/commands/doctor/index.d.mts.map +1 -1
- package/dist/src/cli/commands/doctor/index.mjs +4 -4
- package/dist/src/cli/commands/doctor/index.mjs.map +1 -1
- package/dist/src/cli/commands/explain/index.cjs +3 -1
- package/dist/src/cli/commands/explain/index.cjs.map +1 -1
- package/dist/src/cli/commands/explain/index.d.mts.map +1 -1
- package/dist/src/cli/commands/explain/index.mjs +4 -2
- package/dist/src/cli/commands/explain/index.mjs.map +1 -1
- package/dist/src/cli/commands/init/index.cjs +2 -2
- package/dist/src/cli/commands/init/index.cjs.map +1 -1
- package/dist/src/cli/commands/init/index.mjs +3 -3
- package/dist/src/cli/commands/init/index.mjs.map +1 -1
- package/dist/src/cli/commands/init/presenter.cjs +1 -1
- package/dist/src/cli/commands/init/presenter.cjs.map +1 -1
- package/dist/src/cli/commands/init/presenter.mjs +2 -2
- package/dist/src/cli/commands/init/presenter.mjs.map +1 -1
- package/dist/src/cli/commands/sync/index.cjs +4 -4
- package/dist/src/cli/commands/sync/index.cjs.map +1 -1
- package/dist/src/cli/commands/sync/index.d.mts +1 -0
- package/dist/src/cli/commands/sync/index.mjs +7 -7
- package/dist/src/cli/commands/sync/index.mjs.map +1 -1
- package/dist/src/cli/commands/sync/presenter.cjs +1 -1
- package/dist/src/cli/commands/sync/presenter.cjs.map +1 -1
- package/dist/src/cli/commands/sync/presenter.d.mts +1 -1
- package/dist/src/cli/commands/sync/presenter.mjs +1 -1
- package/dist/src/cli/commands/sync/presenter.mjs.map +1 -1
- package/dist/src/cli/commands/web/index.cjs +2 -1
- package/dist/src/cli/commands/web/index.cjs.map +1 -1
- package/dist/src/cli/commands/web/index.mjs +2 -1
- package/dist/src/cli/commands/web/index.mjs.map +1 -1
- package/dist/src/cli/harnessOptions.cjs +1 -1
- package/dist/src/cli/harnessOptions.cjs.map +1 -1
- package/dist/src/cli/harnessOptions.mjs +2 -2
- package/dist/src/cli/harnessOptions.mjs.map +1 -1
- package/dist/src/cli/help.cjs +2 -0
- package/dist/src/cli/help.cjs.map +1 -1
- package/dist/src/cli/help.mjs +2 -0
- package/dist/src/cli/help.mjs.map +1 -1
- package/dist/src/cli/matrixOptions.cjs +1 -1
- package/dist/src/cli/matrixOptions.cjs.map +1 -1
- package/dist/src/cli/matrixOptions.d.mts +1 -1
- package/dist/src/cli/matrixOptions.mjs +1 -1
- package/dist/src/cli/matrixOptions.mjs.map +1 -1
- package/dist/src/cli/server/run.cjs +1 -1
- package/dist/src/cli/server/run.cjs.map +1 -1
- package/dist/src/cli/server/run.mjs +2 -2
- package/dist/src/cli/server/run.mjs.map +1 -1
- package/dist/src/composition/harnessState/index.cjs +66 -11
- package/dist/src/composition/harnessState/index.cjs.map +1 -1
- package/dist/src/composition/harnessState/index.d.mts +3 -3
- package/dist/src/composition/harnessState/index.mjs +2 -2
- package/dist/src/composition/harnessState/index.mjs.map +1 -1
- package/dist/src/composition/layerPackageInstaller/index.cjs +5 -4
- package/dist/src/composition/layerPackageInstaller/index.cjs.map +1 -1
- package/dist/src/composition/layerPackageInstaller/index.mjs +6 -5
- package/dist/src/composition/layerPackageInstaller/index.mjs.map +1 -1
- package/dist/src/composition/poHomeMigration/index.cjs +1 -1
- package/dist/src/composition/poHomeMigration/index.cjs.map +1 -1
- package/dist/src/composition/poHomeMigration/index.mjs +1 -1
- package/dist/src/composition/poHomeMigration/index.mjs.map +1 -1
- package/dist/src/composition/projectTrust/index.cjs +6 -6
- package/dist/src/composition/projectTrust/index.cjs.map +1 -1
- package/dist/src/composition/projectTrust/index.d.mts +7 -7
- package/dist/src/composition/projectTrust/index.d.mts.map +1 -1
- package/dist/src/composition/projectTrust/index.mjs +6 -6
- package/dist/src/composition/projectTrust/index.mjs.map +1 -1
- package/dist/src/composition/repository/index.cjs +8 -8
- package/dist/src/composition/repository/index.cjs.map +1 -1
- package/dist/src/composition/repository/index.d.mts +5 -5
- package/dist/src/composition/repository/index.d.mts.map +1 -1
- package/dist/src/composition/repository/index.mjs +10 -10
- package/dist/src/composition/repository/index.mjs.map +1 -1
- package/dist/src/composition/syncService/index.cjs +29 -9
- package/dist/src/composition/syncService/index.cjs.map +1 -1
- package/dist/src/composition/syncService/index.d.mts.map +1 -1
- package/dist/src/composition/syncService/index.mjs +31 -11
- package/dist/src/composition/syncService/index.mjs.map +1 -1
- package/dist/src/composition/syncService/localBuilds.cjs +7 -2
- package/dist/src/composition/syncService/localBuilds.cjs.map +1 -1
- package/dist/src/composition/syncService/localBuilds.mjs +7 -2
- package/dist/src/composition/syncService/localBuilds.mjs.map +1 -1
- package/dist/src/extensions/setupDiagnostics.cjs +3 -3
- package/dist/src/extensions/setupDiagnostics.cjs.map +1 -1
- package/dist/src/extensions/setupDiagnostics.mjs +3 -3
- package/dist/src/extensions/setupDiagnostics.mjs.map +1 -1
- package/dist/utils.mjs +1 -2
- package/docs/server/api-export.md +3 -3
- package/docs/server/api.md +23 -22
- package/docs/server/getting-started.md +7 -7
- package/docs/server/index.md +4 -4
- package/docs/server/ipc.md +7 -11
- package/docs/server/lifecycle.md +17 -17
- package/docs/server/security.md +8 -8
- package/package.json +42 -45
- package/src/prompts/po-author-extension/SKILL.md +1 -1
- package/src/prompts/po-author-extension/references/extension-contract.md +4 -4
- package/dist/bin/doomRunner.cjs.map +0 -1
- package/dist/bin/doomRunner.d.mts.map +0 -1
- package/dist/bin/doomRunner.mjs.map +0 -1
|
@@ -4,7 +4,7 @@ import { InitPresenter } from "./presenter.mjs";
|
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import os from "node:os";
|
|
6
6
|
import { removePoPiSettings } from "@agimon-ai/po-core/piSettings";
|
|
7
|
-
import {
|
|
7
|
+
import { globalPoConfigDirectory, initializeGlobalPoConfig } from "@agimon-ai/po-config";
|
|
8
8
|
//#region src/cli/commands/init/index.ts
|
|
9
9
|
const INIT_COMMAND = "init";
|
|
10
10
|
const FORCE_FLAG = "--force";
|
|
@@ -24,11 +24,11 @@ async function runInit(args, homeDirectory = os.homedir(), output = process.stdo
|
|
|
24
24
|
if (unknown !== void 0) throw new Error(`po init does not accept ${unknown}`);
|
|
25
25
|
const presenter = new InitPresenter(output, environment);
|
|
26
26
|
presenter.brand();
|
|
27
|
-
const configDirectory =
|
|
27
|
+
const configDirectory = globalPoConfigDirectory(homeDirectory);
|
|
28
28
|
presenter.stage(1, SETUP_STAGE_COUNT, "WRITE CONFIGURATION", configDirectory);
|
|
29
29
|
let configResult;
|
|
30
30
|
try {
|
|
31
|
-
configResult =
|
|
31
|
+
configResult = initializeGlobalPoConfig(homeDirectory, { force: flags.includes(FORCE_FLAG) });
|
|
32
32
|
presenter.stageReady("Configuration files are ready.");
|
|
33
33
|
} catch (error) {
|
|
34
34
|
presenter.stageFailed("Configuration setup failed.", ["Fix the reported path or permissions, then run po init again."]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../../src/cli/commands/init/index.ts"],"sourcesContent":["import os from 'node:os';\nimport path from 'node:path';\n\nimport { type
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../../src/cli/commands/init/index.ts"],"sourcesContent":["import os from 'node:os';\nimport path from 'node:path';\n\nimport { type GlobalPoInitResult, globalPoConfigDirectory, initializeGlobalPoConfig } from '@agimon-ai/po-config';\nimport { removePoPiSettings } from '@agimon-ai/po-core/piSettings';\n\nimport { wantsHelp } from '../../router';\nimport { initHelp } from './help';\nimport { InitPresenter, type InitOutput } from './presenter';\n\nconst INIT_COMMAND = 'init';\nconst FORCE_FLAG = '--force';\nconst SETUP_STAGE_COUNT = 2;\n\nfunction setupFailure(activity: string, target: string, error: unknown): Error {\n const detail = error instanceof Error ? error.message : String(error);\n return new Error(`po init failed while ${activity} at ${target}: ${detail}`, { cause: error });\n}\n\n/** Handles the repository-independent `po init` command. */\nexport async function runInit(\n args: string[],\n homeDirectory = os.homedir(),\n output: InitOutput = process.stdout,\n environment: NodeJS.ProcessEnv = process.env,\n): Promise<number> {\n const flags = args.slice(1);\n const unknown = flags.find((flag) => flag !== FORCE_FLAG);\n if (wantsHelp(args)) {\n process.stdout.write(initHelp());\n return 0;\n }\n if (unknown !== undefined) throw new Error(`po init does not accept ${unknown}`);\n\n const presenter = new InitPresenter(output, environment);\n presenter.brand();\n\n const configDirectory = globalPoConfigDirectory(homeDirectory);\n presenter.stage(1, SETUP_STAGE_COUNT, 'WRITE CONFIGURATION', configDirectory);\n let configResult: GlobalPoInitResult;\n try {\n configResult = initializeGlobalPoConfig(homeDirectory, { force: flags.includes(FORCE_FLAG) });\n presenter.stageReady('Configuration files are ready.');\n } catch (error) {\n presenter.stageFailed('Configuration setup failed.', [\n 'Fix the reported path or permissions, then run po init again.',\n ]);\n throw setupFailure('writing configuration', configDirectory, error);\n }\n\n // Po no longer registers with Pi; init only removes what earlier versions wrote.\n const agentDirectory = path.join(homeDirectory, '.pi', 'agent');\n presenter.stage(2, SETUP_STAGE_COUNT, 'REMOVE PI REGISTRATION', agentDirectory);\n let removed: string[];\n try {\n removed = removePoPiSettings(agentDirectory);\n presenter.stageReady(removed.length > 0 ? 'Removed Po entries from Pi.' : 'No Po entries in Pi.');\n } catch (error) {\n presenter.stageFailed('Pi cleanup failed.', [\n `Your Po configuration remains at ${configResult.directory}.`,\n 'Fix the reported settings or filesystem issue, then run po init again.',\n ]);\n throw setupFailure('removing Po from Pi settings', agentDirectory, error);\n }\n\n presenter.complete(configResult, removed);\n return 0;\n}\n\n/** Compatibility API. Executables call the command function directly. */\nexport class InitCommand {\n readonly name = INIT_COMMAND;\n\n matches(args: string[]): boolean {\n return args[0] === this.name;\n }\n\n async execute(\n args: string[],\n homeDirectory = os.homedir(),\n output: InitOutput = process.stdout,\n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,gCAAgC,sBAAsB;CAClG,SAAS,OAAO;EACd,UAAU,YAAY,sBAAsB,CAC1C,oCAAoC,aAAa,UAAU,IAC3D,wEACF,CAAC;EACD,MAAM,aAAa,gCAAgC,gBAAgB,KAAK;CAC1E;CAEA,UAAU,SAAS,cAAc,OAAO;CACxC,OAAO;AACT;;AAGA,IAAa,cAAb,MAAyB;CACvB,OAAgB;CAEhB,QAAQ,MAAyB;EAC/B,OAAO,KAAK,OAAO,KAAK;CAC1B;CAEA,MAAM,QACJ,MACA,gBAAgB,GAAG,QAAQ,GAC3B,SAAqB,QAAQ,QAC7B,cAAiC,QAAQ,KACxB;EACjB,OAAO,QAAQ,MAAM,eAAe,QAAQ,WAAW;CACzD;AACF"}
|
|
@@ -112,7 +112,7 @@ var InitPresenter = class {
|
|
|
112
112
|
const lines = [
|
|
113
113
|
this.sectionHeading("PO CONFIGURATION"),
|
|
114
114
|
` ${this.palette.path(result.directory)}`,
|
|
115
|
-
..._agimon_ai_po_config.
|
|
115
|
+
..._agimon_ai_po_config.GLOBAL_PO_SEED_FILES.map((fileName) => {
|
|
116
116
|
const status = seedFileStatus(result, fileName);
|
|
117
117
|
return ` ${this.fileStatus(status)} ${this.palette.key(fileName.padEnd(13))} ${this.palette.muted("—")} ${require_constants.SEED_FILE_GUIDANCE[fileName]}`;
|
|
118
118
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presenter.cjs","names":["DEFAULT_THEME","GLOBAL_DOOM_SEED_FILES","SEED_FILE_GUIDANCE"],"sources":["../../../../../src/cli/commands/init/presenter.ts"],"sourcesContent":["import { GLOBAL_DOOM_SEED_FILES, type GlobalDoomInitResult } from '@agimon-ai/po-config';\nimport { DEFAULT_THEME } from '@agimon-ai/po-ui/theme';\n\nimport { SEED_FILE_GUIDANCE } from './constants';\n\nconst FORCE_COLOR_ENV = 'FORCE_COLOR';\nconst NO_COLOR_ENV = 'NO_COLOR';\nconst DUMB_TERMINAL = 'dumb';\nconst ANSI_PREFIX = '\\u001B[';\nconst ANSI_RESET = `${ANSI_PREFIX}0m`;\nconst SECTION_RULE = '─'.repeat(72);\nconst READY_RULE = '━━━━━━━━';\n\nexport interface InitOutput {\n write: NodeJS.WritableStream['write'];\n isTTY?: boolean;\n}\n\ntype SeedFile = (typeof GLOBAL_DOOM_SEED_FILES)[number];\ntype SeedFileStatus = 'CREATED' | 'KEPT' | 'REPLACED';\ntype Paint = (text: string) => string;\n\ninterface InitPalette {\n accent: Paint;\n badge: Paint;\n error: Paint;\n heading: Paint;\n key: Paint;\n kept: Paint;\n muted: Paint;\n path: Paint;\n strong: Paint;\n success: Paint;\n warning: Paint;\n}\n\ninterface PaintOptions {\n background?: string;\n bold?: boolean;\n}\n\nfunction colorEnabled(output: InitOutput, environment: NodeJS.ProcessEnv): boolean {\n const forced = environment[FORCE_COLOR_ENV];\n if (forced === '0') return false;\n if (forced !== undefined) return true;\n if (environment[NO_COLOR_ENV] !== undefined) return false;\n return output.isTTY === true && environment.TERM !== DUMB_TERMINAL;\n}\n\nfunction rgbCode(prefix: 38 | 48, hex: string): string {\n const value = Number.parseInt(hex.slice(1), 16);\n const red = (value >> 16) & 0xff;\n const green = (value >> 8) & 0xff;\n const blue = value & 0xff;\n return `${String(prefix)};2;${String(red)};${String(green)};${String(blue)}`;\n}\n\nfunction painter(enabled: boolean, foreground: string, options: PaintOptions = {}): Paint {\n if (!enabled) return (text) => text;\n const codes = [rgbCode(38, foreground)];\n if (options.background) codes.push(rgbCode(48, options.background));\n if (options.bold) codes.unshift('1');\n const opening = `${ANSI_PREFIX}${codes.join(';')}m`;\n return (text) => `${opening}${text}${ANSI_RESET}`;\n}\n\nfunction createPalette(enabled: boolean): InitPalette {\n const { vars } = DEFAULT_THEME;\n const accent = painter(enabled, vars.green);\n const badgePaint = painter(enabled, vars.bg, { background: vars.green, bold: true });\n return {\n accent,\n badge: enabled ? (text) => badgePaint(` ${text} `) : (text) => text,\n error: painter(enabled, vars.red, { bold: true }),\n heading: painter(enabled, vars.green, { bold: true }),\n key: painter(enabled, vars.cyan),\n kept: painter(enabled, vars.violet),\n muted: painter(enabled, vars.comment),\n path: painter(enabled, vars.cyan),\n strong: painter(enabled, vars.fg, { bold: true }),\n success: painter(enabled, vars.green, { bold: true }),\n warning: painter(enabled, vars.yellow),\n };\n}\n\nfunction seedFileStatus(result: GlobalDoomInitResult, fileName: SeedFile): SeedFileStatus {\n if (result.created.includes(fileName)) return 'CREATED';\n if (result.replaced.includes(fileName)) return 'REPLACED';\n if (result.preserved.includes(fileName)) return 'KEPT';\n throw new Error(`po init did not classify generated file: ${fileName}`);\n}\n\n/** Streams the init command using the same Po Jade semantic palette as the Pi TUI. */\nexport class InitPresenter {\n private readonly output: InitOutput;\n private readonly palette: InitPalette;\n\n constructor(output: InitOutput, environment: NodeJS.ProcessEnv) {\n this.output = output;\n this.palette = createPalette(colorEnabled(output, environment));\n }\n\n brand(): void {\n const color = this.palette;\n this.write([\n color.muted('BOOT / INIT'),\n `${color.accent('Po')} ${color.heading('INITIALIZE')}`,\n color.muted('Po handles it.'),\n `${color.accent(READY_RULE)} ${color.heading('SETUP')}`,\n '',\n ]);\n }\n\n stage(step: number, total: number, label: string, target: string): void {\n const color = this.palette;\n this.write([\n `${color.accent(`[${String(step)}/${String(total)}]`)} ${color.strong(label)}`,\n ` ${color.muted('TARGET')} ${color.path(target)}`,\n ]);\n }\n\n stageReady(message: string): void {\n this.write([` ${this.palette.success('● READY')} ${message}`]);\n }\n\n stageFailed(message: string, detail: readonly string[]): void {\n this.write([\n ` ${this.palette.error('● FAILED')} ${message}`,\n ...detail.map((line) => ` ${this.palette.warning(line)}`),\n ]);\n }\n\n complete(config: GlobalDoomInitResult, removedPiEntries: readonly string[]): void {\n this.write(['', ...this.formatPiCleanup(removedPiEntries)]);\n this.write(['', ...this.formatConfigResult(config)]);\n this.write([\n '',\n this.sectionHeading('NEXT'),\n ` ${this.palette.accent('01')} Open ${this.palette.path(config.directory)}.`,\n ` ${this.palette.accent('02')} Edit the YAML files to match how you want Po to work.`,\n ` ${this.palette.accent('03')} From the repository you want to configure, run:`,\n '',\n ` ${this.palette.badge('po sync')}`,\n '',\n `${this.palette.success(READY_RULE)} ${this.palette.success('READY')} Edit your config, then sync it.`,\n ]);\n }\n\n private formatPiCleanup(removed: readonly string[]): string[] {\n return [\n this.sectionHeading('PI CLEANUP'),\n removed.length === 0\n ? ` ${this.palette.success('Pi settings carry no Po entries.')}`\n : ` ${this.palette.warning(`Removed ${String(removed.length)} Po entr${removed.length === 1 ? 'y' : 'ies'}.`)} ${this.palette.muted('Unrelated settings were preserved.')}`,\n ...removed.map((entry) => ` ${this.palette.path(entry)}`),\n ];\n }\n\n private formatConfigResult(result: GlobalDoomInitResult): string[] {\n const lines = [\n this.sectionHeading('PO CONFIGURATION'),\n ` ${this.palette.path(result.directory)}`,\n ...GLOBAL_DOOM_SEED_FILES.map((fileName) => {\n const status = seedFileStatus(result, fileName);\n return ` ${this.fileStatus(status)} ${this.palette.key(fileName.padEnd(13))} ${this.palette.muted('—')} ${SEED_FILE_GUIDANCE[fileName]}`;\n }),\n ];\n if (result.preserved.length > 0) {\n lines.push(` ${this.palette.kept('KEPT')} ${this.palette.muted('files retain your existing edits.')}`);\n }\n if (result.replaced.length > 0) {\n lines.push(\n ` ${this.palette.warning('REPLACED')} ${this.palette.muted(\n 'files were restored from the templates because --force was used.',\n )}`,\n );\n }\n return lines;\n }\n\n private fileStatus(status: SeedFileStatus): string {\n const padded = status.padEnd(8);\n if (status === 'CREATED') return this.palette.accent(padded);\n if (status === 'REPLACED') return this.palette.warning(padded);\n return this.palette.kept(padded);\n }\n\n private sectionHeading(title: string): string {\n return `${this.palette.muted(SECTION_RULE)}\\n${this.palette.heading(title)}`;\n }\n\n private write(lines: readonly string[]): void {\n this.output.write(`${lines.join('\\n')}\\n`);\n }\n}\n"],"mappings":";;;;AAKA,MAAM,kBAAkB;AACxB,MAAM,eAAe;AACrB,MAAM,gBAAgB;AACtB,MAAM,cAAc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SEED_FILES, type GlobalPoInitResult } from '@agimon-ai/po-config';\nimport { DEFAULT_THEME } from '@agimon-ai/po-ui/theme';\n\nimport { SEED_FILE_GUIDANCE } from './constants';\n\nconst FORCE_COLOR_ENV = 'FORCE_COLOR';\nconst NO_COLOR_ENV = 'NO_COLOR';\nconst DUMB_TERMINAL = 'dumb';\nconst ANSI_PREFIX = '\\u001B[';\nconst ANSI_RESET = `${ANSI_PREFIX}0m`;\nconst SECTION_RULE = '─'.repeat(72);\nconst READY_RULE = '━━━━━━━━';\n\nexport interface InitOutput {\n write: NodeJS.WritableStream['write'];\n isTTY?: boolean;\n}\n\ntype SeedFile = (typeof GLOBAL_PO_SEED_FILES)[number];\ntype SeedFileStatus = 'CREATED' | 'KEPT' | 'REPLACED';\ntype Paint = (text: string) => string;\n\ninterface InitPalette {\n accent: Paint;\n badge: Paint;\n error: Paint;\n heading: Paint;\n key: Paint;\n kept: Paint;\n muted: Paint;\n path: Paint;\n strong: Paint;\n success: Paint;\n warning: Paint;\n}\n\ninterface PaintOptions {\n background?: string;\n bold?: boolean;\n}\n\nfunction colorEnabled(output: InitOutput, environment: NodeJS.ProcessEnv): boolean {\n const forced = environment[FORCE_COLOR_ENV];\n if (forced === '0') return false;\n if (forced !== undefined) return true;\n if (environment[NO_COLOR_ENV] !== undefined) return false;\n return output.isTTY === true && environment.TERM !== DUMB_TERMINAL;\n}\n\nfunction rgbCode(prefix: 38 | 48, hex: string): string {\n const value = Number.parseInt(hex.slice(1), 16);\n const red = (value >> 16) & 0xff;\n const green = (value >> 8) & 0xff;\n const blue = value & 0xff;\n return `${String(prefix)};2;${String(red)};${String(green)};${String(blue)}`;\n}\n\nfunction painter(enabled: boolean, foreground: string, options: PaintOptions = {}): Paint {\n if (!enabled) return (text) => text;\n const codes = [rgbCode(38, foreground)];\n if (options.background) codes.push(rgbCode(48, options.background));\n if (options.bold) codes.unshift('1');\n const opening = `${ANSI_PREFIX}${codes.join(';')}m`;\n return (text) => `${opening}${text}${ANSI_RESET}`;\n}\n\nfunction createPalette(enabled: boolean): InitPalette {\n const { vars } = DEFAULT_THEME;\n const accent = painter(enabled, vars.green);\n const badgePaint = painter(enabled, vars.bg, { background: vars.green, bold: true });\n return {\n accent,\n badge: enabled ? (text) => badgePaint(` ${text} `) : (text) => text,\n error: painter(enabled, vars.red, { bold: true }),\n heading: painter(enabled, vars.green, { bold: true }),\n key: painter(enabled, vars.cyan),\n kept: painter(enabled, vars.violet),\n muted: painter(enabled, vars.comment),\n path: painter(enabled, vars.cyan),\n strong: painter(enabled, vars.fg, { bold: true }),\n success: painter(enabled, vars.green, { bold: true }),\n warning: painter(enabled, vars.yellow),\n };\n}\n\nfunction seedFileStatus(result: GlobalPoInitResult, fileName: SeedFile): SeedFileStatus {\n if (result.created.includes(fileName)) return 'CREATED';\n if (result.replaced.includes(fileName)) return 'REPLACED';\n if (result.preserved.includes(fileName)) return 'KEPT';\n throw new Error(`po init did not classify generated file: ${fileName}`);\n}\n\n/** Streams the init command using the same Po Jade semantic palette as the Pi TUI. */\nexport class InitPresenter {\n private readonly output: InitOutput;\n private readonly palette: InitPalette;\n\n constructor(output: InitOutput, environment: NodeJS.ProcessEnv) {\n this.output = output;\n this.palette = createPalette(colorEnabled(output, environment));\n }\n\n brand(): void {\n const color = this.palette;\n this.write([\n color.muted('BOOT / INIT'),\n `${color.accent('Po')} ${color.heading('INITIALIZE')}`,\n color.muted('Po handles it.'),\n `${color.accent(READY_RULE)} ${color.heading('SETUP')}`,\n '',\n ]);\n }\n\n stage(step: number, total: number, label: string, target: string): void {\n const color = this.palette;\n this.write([\n `${color.accent(`[${String(step)}/${String(total)}]`)} ${color.strong(label)}`,\n ` ${color.muted('TARGET')} ${color.path(target)}`,\n ]);\n }\n\n stageReady(message: string): void {\n this.write([` ${this.palette.success('● READY')} ${message}`]);\n }\n\n stageFailed(message: string, detail: readonly string[]): void {\n this.write([\n ` ${this.palette.error('● FAILED')} ${message}`,\n ...detail.map((line) => ` ${this.palette.warning(line)}`),\n ]);\n }\n\n complete(config: GlobalPoInitResult, removedPiEntries: readonly string[]): void {\n this.write(['', ...this.formatPiCleanup(removedPiEntries)]);\n this.write(['', ...this.formatConfigResult(config)]);\n this.write([\n '',\n this.sectionHeading('NEXT'),\n ` ${this.palette.accent('01')} Open ${this.palette.path(config.directory)}.`,\n ` ${this.palette.accent('02')} Edit the YAML files to match how you want Po to work.`,\n ` ${this.palette.accent('03')} From the repository you want to configure, run:`,\n '',\n ` ${this.palette.badge('po sync')}`,\n '',\n `${this.palette.success(READY_RULE)} ${this.palette.success('READY')} Edit your config, then sync it.`,\n ]);\n }\n\n private formatPiCleanup(removed: readonly string[]): string[] {\n return [\n this.sectionHeading('PI CLEANUP'),\n removed.length === 0\n ? ` ${this.palette.success('Pi settings carry no Po entries.')}`\n : ` ${this.palette.warning(`Removed ${String(removed.length)} Po entr${removed.length === 1 ? 'y' : 'ies'}.`)} ${this.palette.muted('Unrelated settings were preserved.')}`,\n ...removed.map((entry) => ` ${this.palette.path(entry)}`),\n ];\n }\n\n private formatConfigResult(result: GlobalPoInitResult): string[] {\n const lines = [\n this.sectionHeading('PO CONFIGURATION'),\n ` ${this.palette.path(result.directory)}`,\n ...GLOBAL_PO_SEED_FILES.map((fileName) => {\n const status = seedFileStatus(result, fileName);\n return ` ${this.fileStatus(status)} ${this.palette.key(fileName.padEnd(13))} ${this.palette.muted('—')} ${SEED_FILE_GUIDANCE[fileName]}`;\n }),\n ];\n if (result.preserved.length > 0) {\n lines.push(` ${this.palette.kept('KEPT')} ${this.palette.muted('files retain your existing edits.')}`);\n }\n if (result.replaced.length > 0) {\n lines.push(\n ` ${this.palette.warning('REPLACED')} ${this.palette.muted(\n 'files were restored from the templates because --force was used.',\n )}`,\n );\n }\n return lines;\n }\n\n private fileStatus(status: SeedFileStatus): string {\n const padded = status.padEnd(8);\n if (status === 'CREATED') return this.palette.accent(padded);\n if (status === 'REPLACED') return this.palette.warning(padded);\n return this.palette.kept(padded);\n }\n\n private sectionHeading(title: string): string {\n return `${this.palette.muted(SECTION_RULE)}\\n${this.palette.heading(title)}`;\n }\n\n private write(lines: readonly string[]): void {\n this.output.write(`${lines.join('\\n')}\\n`);\n }\n}\n"],"mappings":";;;;AAKA,MAAM,kBAAkB;AACxB,MAAM,eAAe;AACrB,MAAM,gBAAgB;AACtB,MAAM,cAAc;AACpB,MAAM,aAAa,GAAG,YAAY;AAClC,MAAM,eAAe,IAAI,OAAO,EAAE;AAClC,MAAM,aAAa;AA8BnB,SAAS,aAAa,QAAoB,aAAyC;CACjF,MAAM,SAAS,YAAY;CAC3B,IAAI,WAAW,KAAK,OAAO;CAC3B,IAAI,WAAW,KAAA,GAAW,OAAO;CACjC,IAAI,YAAY,kBAAkB,KAAA,GAAW,OAAO;CACpD,OAAO,OAAO,UAAU,QAAQ,YAAY,SAAS;AACvD;AAEA,SAAS,QAAQ,QAAiB,KAAqB;CACrD,MAAM,QAAQ,OAAO,SAAS,IAAI,MAAM,CAAC,GAAG,EAAE;CAC9C,MAAM,MAAO,SAAS,KAAM;CAC5B,MAAM,QAAS,SAAS,IAAK;CAC7B,MAAM,OAAO,QAAQ;CACrB,OAAO,GAAG,OAAO,MAAM,EAAE,KAAK,OAAO,GAAG,EAAE,GAAG,OAAO,KAAK,EAAE,GAAG,OAAO,IAAI;AAC3E;AAEA,SAAS,QAAQ,SAAkB,YAAoB,UAAwB,CAAC,GAAU;CACxF,IAAI,CAAC,SAAS,QAAQ,SAAS;CAC/B,MAAM,QAAQ,CAAC,QAAQ,IAAI,UAAU,CAAC;CACtC,IAAI,QAAQ,YAAY,MAAM,KAAK,QAAQ,IAAI,QAAQ,UAAU,CAAC;CAClE,IAAI,QAAQ,MAAM,MAAM,QAAQ,GAAG;CACnC,MAAM,UAAU,GAAG,cAAc,MAAM,KAAK,GAAG,EAAE;CACjD,QAAQ,SAAS,GAAG,UAAU,OAAO;AACvC;AAEA,SAAS,cAAc,SAA+B;CACpD,MAAM,EAAE,SAASA,uBAAAA;CACjB,MA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AAO,MAAM,GAAG,MAAM,KAAK,IAAI,EAAE,GAAG;CAC3C;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SEED_FILE_GUIDANCE } from "./constants.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { GLOBAL_PO_SEED_FILES } from "@agimon-ai/po-config";
|
|
3
3
|
import { DEFAULT_THEME } from "@agimon-ai/po-ui/theme";
|
|
4
4
|
//#region src/cli/commands/init/presenter.ts
|
|
5
5
|
const FORCE_COLOR_ENV = "FORCE_COLOR";
|
|
@@ -112,7 +112,7 @@ var InitPresenter = class {
|
|
|
112
112
|
const lines = [
|
|
113
113
|
this.sectionHeading("PO CONFIGURATION"),
|
|
114
114
|
` ${this.palette.path(result.directory)}`,
|
|
115
|
-
...
|
|
115
|
+
...GLOBAL_PO_SEED_FILES.map((fileName) => {
|
|
116
116
|
const status = seedFileStatus(result, fileName);
|
|
117
117
|
return ` ${this.fileStatus(status)} ${this.palette.key(fileName.padEnd(13))} ${this.palette.muted("—")} ${SEED_FILE_GUIDANCE[fileName]}`;
|
|
118
118
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presenter.mjs","names":[],"sources":["../../../../../src/cli/commands/init/presenter.ts"],"sourcesContent":["import { GLOBAL_DOOM_SEED_FILES, type GlobalDoomInitResult } from '@agimon-ai/po-config';\nimport { DEFAULT_THEME } from '@agimon-ai/po-ui/theme';\n\nimport { SEED_FILE_GUIDANCE } from './constants';\n\nconst FORCE_COLOR_ENV = 'FORCE_COLOR';\nconst NO_COLOR_ENV = 'NO_COLOR';\nconst DUMB_TERMINAL = 'dumb';\nconst ANSI_PREFIX = '\\u001B[';\nconst ANSI_RESET = `${ANSI_PREFIX}0m`;\nconst SECTION_RULE = '─'.repeat(72);\nconst READY_RULE = '━━━━━━━━';\n\nexport interface InitOutput {\n write: NodeJS.WritableStream['write'];\n isTTY?: boolean;\n}\n\ntype SeedFile = (typeof GLOBAL_DOOM_SEED_FILES)[number];\ntype SeedFileStatus = 'CREATED' | 'KEPT' | 'REPLACED';\ntype Paint = (text: string) => string;\n\ninterface InitPalette {\n accent: Paint;\n badge: Paint;\n error: Paint;\n heading: Paint;\n key: Paint;\n kept: Paint;\n muted: Paint;\n path: Paint;\n strong: Paint;\n success: Paint;\n warning: Paint;\n}\n\ninterface PaintOptions {\n background?: string;\n bold?: boolean;\n}\n\nfunction colorEnabled(output: InitOutput, environment: NodeJS.ProcessEnv): boolean {\n const forced = environment[FORCE_COLOR_ENV];\n if (forced === '0') return false;\n if (forced !== undefined) return true;\n if (environment[NO_COLOR_ENV] !== undefined) return false;\n return output.isTTY === true && environment.TERM !== DUMB_TERMINAL;\n}\n\nfunction rgbCode(prefix: 38 | 48, hex: string): string {\n const value = Number.parseInt(hex.slice(1), 16);\n const red = (value >> 16) & 0xff;\n const green = (value >> 8) & 0xff;\n const blue = value & 0xff;\n return `${String(prefix)};2;${String(red)};${String(green)};${String(blue)}`;\n}\n\nfunction painter(enabled: boolean, foreground: string, options: PaintOptions = {}): Paint {\n if (!enabled) return (text) => text;\n const codes = [rgbCode(38, foreground)];\n if (options.background) codes.push(rgbCode(48, options.background));\n if (options.bold) codes.unshift('1');\n const opening = `${ANSI_PREFIX}${codes.join(';')}m`;\n return (text) => `${opening}${text}${ANSI_RESET}`;\n}\n\nfunction createPalette(enabled: boolean): InitPalette {\n const { vars } = DEFAULT_THEME;\n const accent = painter(enabled, vars.green);\n const badgePaint = painter(enabled, vars.bg, { background: vars.green, bold: true });\n return {\n accent,\n badge: enabled ? (text) => badgePaint(` ${text} `) : (text) => text,\n error: painter(enabled, vars.red, { bold: true }),\n heading: painter(enabled, vars.green, { bold: true }),\n key: painter(enabled, vars.cyan),\n kept: painter(enabled, vars.violet),\n muted: painter(enabled, vars.comment),\n path: painter(enabled, vars.cyan),\n strong: painter(enabled, vars.fg, { bold: true }),\n success: painter(enabled, vars.green, { bold: true }),\n warning: painter(enabled, vars.yellow),\n };\n}\n\nfunction seedFileStatus(result: GlobalDoomInitResult, fileName: SeedFile): SeedFileStatus {\n if (result.created.includes(fileName)) return 'CREATED';\n if (result.replaced.includes(fileName)) return 'REPLACED';\n if (result.preserved.includes(fileName)) return 'KEPT';\n throw new Error(`po init did not classify generated file: ${fileName}`);\n}\n\n/** Streams the init command using the same Po Jade semantic palette as the Pi TUI. */\nexport class InitPresenter {\n private readonly output: InitOutput;\n private readonly palette: InitPalette;\n\n constructor(output: InitOutput, environment: NodeJS.ProcessEnv) {\n this.output = output;\n this.palette = createPalette(colorEnabled(output, environment));\n }\n\n brand(): void {\n const color = this.palette;\n this.write([\n color.muted('BOOT / INIT'),\n `${color.accent('Po')} ${color.heading('INITIALIZE')}`,\n color.muted('Po handles it.'),\n `${color.accent(READY_RULE)} ${color.heading('SETUP')}`,\n '',\n ]);\n }\n\n stage(step: number, total: number, label: string, target: string): void {\n const color = this.palette;\n this.write([\n `${color.accent(`[${String(step)}/${String(total)}]`)} ${color.strong(label)}`,\n ` ${color.muted('TARGET')} ${color.path(target)}`,\n ]);\n }\n\n stageReady(message: string): void {\n this.write([` ${this.palette.success('● READY')} ${message}`]);\n }\n\n stageFailed(message: string, detail: readonly string[]): void {\n this.write([\n ` ${this.palette.error('● FAILED')} ${message}`,\n ...detail.map((line) => ` ${this.palette.warning(line)}`),\n ]);\n }\n\n complete(config: GlobalDoomInitResult, removedPiEntries: readonly string[]): void {\n this.write(['', ...this.formatPiCleanup(removedPiEntries)]);\n this.write(['', ...this.formatConfigResult(config)]);\n this.write([\n '',\n this.sectionHeading('NEXT'),\n ` ${this.palette.accent('01')} Open ${this.palette.path(config.directory)}.`,\n ` ${this.palette.accent('02')} Edit the YAML files to match how you want Po to work.`,\n ` ${this.palette.accent('03')} From the repository you want to configure, run:`,\n '',\n ` ${this.palette.badge('po sync')}`,\n '',\n `${this.palette.success(READY_RULE)} ${this.palette.success('READY')} Edit your config, then sync it.`,\n ]);\n }\n\n private formatPiCleanup(removed: readonly string[]): string[] {\n return [\n this.sectionHeading('PI CLEANUP'),\n removed.length === 0\n ? ` ${this.palette.success('Pi settings carry no Po entries.')}`\n : ` ${this.palette.warning(`Removed ${String(removed.length)} Po entr${removed.length === 1 ? 'y' : 'ies'}.`)} ${this.palette.muted('Unrelated settings were preserved.')}`,\n ...removed.map((entry) => ` ${this.palette.path(entry)}`),\n ];\n }\n\n private formatConfigResult(result: GlobalDoomInitResult): string[] {\n const lines = [\n this.sectionHeading('PO CONFIGURATION'),\n ` ${this.palette.path(result.directory)}`,\n ...GLOBAL_DOOM_SEED_FILES.map((fileName) => {\n const status = seedFileStatus(result, fileName);\n return ` ${this.fileStatus(status)} ${this.palette.key(fileName.padEnd(13))} ${this.palette.muted('—')} ${SEED_FILE_GUIDANCE[fileName]}`;\n }),\n ];\n if (result.preserved.length > 0) {\n lines.push(` ${this.palette.kept('KEPT')} ${this.palette.muted('files retain your existing edits.')}`);\n }\n if (result.replaced.length > 0) {\n lines.push(\n ` ${this.palette.warning('REPLACED')} ${this.palette.muted(\n 'files were restored from the templates because --force was used.',\n )}`,\n );\n }\n return lines;\n }\n\n private fileStatus(status: SeedFileStatus): string {\n const padded = status.padEnd(8);\n if (status === 'CREATED') return this.palette.accent(padded);\n if (status === 'REPLACED') return this.palette.warning(padded);\n return this.palette.kept(padded);\n }\n\n private sectionHeading(title: string): string {\n return `${this.palette.muted(SECTION_RULE)}\\n${this.palette.heading(title)}`;\n }\n\n private write(lines: readonly string[]): void {\n this.output.write(`${lines.join('\\n')}\\n`);\n }\n}\n"],"mappings":";;;;AAKA,MAAM,kBAAkB;AACxB,MAAM,eAAe;AACrB,MAAM,gBAAgB;AACtB,MAAM,cAAc;AACpB,MAAM,aAAa,GAAG,YAAY;AAClC,MAAM,eAAe,IAAI,OAAO,EAAE;AAClC,MAAM,aAAa;AA8BnB,SAAS,aAAa,QAAoB,aAAyC;CACjF,MAAM,SAAS,YAAY;CAC3B,IAAI,WAAW,KAAK,OAAO;CAC3B,IAAI,WAAW,KAAA,GAAW,OA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O,KAAK,KAAK,WAAW,MAAM,EAAE,GAAG,KAAK,QAAQ,IAAI,SAAS,OAAO,EAAE,CAAC,EAAE,GAAG,KAAK,QAAQ,MAAM,GAAG,EAAE,GAAG,mBAAmB;GAChI,CAAC;EACH;EACA,IAAI,OAAO,UAAU,SAAS,GAC5B,MAAM,KAAK,KAAK,KAAK,QAAQ,KAAK,MAAM,EAAE,GAAG,KAAK,QAAQ,MAAM,mCAAmC,GAAG;EAExG,IAAI,OAAO,SAAS,SAAS,GAC3B,MAAM,KACJ,KAAK,KAAK,QAAQ,QAAQ,UAAU,EAAE,GAAG,KAAK,QAAQ,MACpD,kEACF,GACF;EAEF,OAAO;CACT;CAEA,WAAmB,QAAgC;EACjD,MAAM,SAAS,OAAO,OAAO,CAAC;EAC9B,IAAI,WAAW,WAAW,OAAO,KAAK,QAAQ,OAAO,MAAM;EAC3D,IAAI,WAAW,YAAY,OAAO,KAAK,QAAQ,QAAQ,MAAM;EAC7D,OAAO,KAAK,QAAQ,KAAK,MAAM;CACjC;CAEA,eAAuB,OAAuB;EAC5C,OAAO,GAAG,KAAK,QAAQ,MAAM,YAAY,EAAE,IAAI,KAAK,QAAQ,QAAQ,KAAK;CAC3E;CAEA,MAAc,OAAgC;EAC5C,KAAK,OAAO,MAAM,GAAG,MAAM,KAAK,IAAI,EAAE,GAAG;CAC3C;AACF"}
|
|
1
|
+
{"version":3,"file":"presenter.mjs","names":[],"sources":["../../../../../src/cli/commands/init/presenter.ts"],"sourcesContent":["import { GLOBAL_PO_SEED_FILES, type GlobalPoInitResult } from '@agimon-ai/po-config';\nimport { DEFAULT_THEME } from '@agimon-ai/po-ui/theme';\n\nimport { SEED_FILE_GUIDANCE } from './constants';\n\nconst FORCE_COLOR_ENV = 'FORCE_COLOR';\nconst NO_COLOR_ENV = 'NO_COLOR';\nconst DUMB_TERMINAL = 'dumb';\nconst ANSI_PREFIX = '\\u001B[';\nconst ANSI_RESET = `${ANSI_PREFIX}0m`;\nconst SECTION_RULE = '─'.repeat(72);\nconst READY_RULE = '━━━━━━━━';\n\nexport interface InitOutput {\n write: NodeJS.WritableStream['write'];\n isTTY?: boolean;\n}\n\ntype SeedFile = (typeof GLOBAL_PO_SEED_FILES)[number];\ntype SeedFileStatus = 'CREATED' | 'KEPT' | 'REPLACED';\ntype Paint = (text: string) => string;\n\ninterface InitPalette {\n accent: Paint;\n badge: Paint;\n error: Paint;\n heading: Paint;\n key: Paint;\n kept: Paint;\n muted: Paint;\n path: Paint;\n strong: Paint;\n success: Paint;\n warning: Paint;\n}\n\ninterface PaintOptions {\n background?: string;\n bold?: boolean;\n}\n\nfunction colorEnabled(output: InitOutput, environment: NodeJS.ProcessEnv): boolean {\n const forced = environment[FORCE_COLOR_ENV];\n if (forced === '0') return false;\n if (forced !== undefined) return true;\n if (environment[NO_COLOR_ENV] !== undefined) return false;\n return output.isTTY === true && environment.TERM !== DUMB_TERMINAL;\n}\n\nfunction rgbCode(prefix: 38 | 48, hex: string): string {\n const value = Number.parseInt(hex.slice(1), 16);\n const red = (value >> 16) & 0xff;\n const green = (value >> 8) & 0xff;\n const blue = value & 0xff;\n return `${String(prefix)};2;${String(red)};${String(green)};${String(blue)}`;\n}\n\nfunction painter(enabled: boolean, foreground: string, options: PaintOptions = {}): Paint {\n if (!enabled) return (text) => text;\n const codes = [rgbCode(38, foreground)];\n if (options.background) codes.push(rgbCode(48, options.background));\n if (options.bold) codes.unshift('1');\n const opening = `${ANSI_PREFIX}${codes.join(';')}m`;\n return (text) => `${opening}${text}${ANSI_RESET}`;\n}\n\nfunction createPalette(enabled: boolean): InitPalette {\n const { vars } = DEFAULT_THEME;\n const accent = painter(enabled, vars.green);\n const badgePaint = painter(enabled, vars.bg, { background: vars.green, bold: true });\n return {\n accent,\n badge: enabled ? (text) => badgePaint(` ${text} `) : (text) => text,\n error: painter(enabled, vars.red, { bold: true }),\n heading: painter(enabled, vars.green, { bold: true }),\n key: painter(enabled, vars.cyan),\n kept: painter(enabled, vars.violet),\n muted: painter(enabled, vars.comment),\n path: painter(enabled, vars.cyan),\n strong: painter(enabled, vars.fg, { bold: true }),\n success: painter(enabled, vars.green, { bold: true }),\n warning: painter(enabled, vars.yellow),\n };\n}\n\nfunction seedFileStatus(result: GlobalPoInitResult, fileName: SeedFile): SeedFileStatus {\n if (result.created.includes(fileName)) return 'CREATED';\n if (result.replaced.includes(fileName)) return 'REPLACED';\n if (result.preserved.includes(fileName)) return 'KEPT';\n throw new Error(`po init did not classify generated file: ${fileName}`);\n}\n\n/** Streams the init command using the same Po Jade semantic palette as the Pi TUI. */\nexport class InitPresenter {\n private readonly output: InitOutput;\n private readonly palette: InitPalette;\n\n constructor(output: InitOutput, environment: NodeJS.ProcessEnv) {\n this.output = output;\n this.palette = createPalette(colorEnabled(output, environment));\n }\n\n brand(): void {\n const color = this.palette;\n this.write([\n color.muted('BOOT / INIT'),\n `${color.accent('Po')} ${color.heading('INITIALIZE')}`,\n color.muted('Po handles it.'),\n `${color.accent(READY_RULE)} ${color.heading('SETUP')}`,\n '',\n ]);\n }\n\n stage(step: number, total: number, label: string, target: string): void {\n const color = this.palette;\n this.write([\n `${color.accent(`[${String(step)}/${String(total)}]`)} ${color.strong(label)}`,\n ` ${color.muted('TARGET')} ${color.path(target)}`,\n ]);\n }\n\n stageReady(message: string): void {\n this.write([` ${this.palette.success('● READY')} ${message}`]);\n }\n\n stageFailed(message: string, detail: readonly string[]): void {\n this.write([\n ` ${this.palette.error('● FAILED')} ${message}`,\n ...detail.map((line) => ` ${this.palette.warning(line)}`),\n ]);\n }\n\n complete(config: GlobalPoInitResult, removedPiEntries: readonly string[]): void {\n this.write(['', ...this.formatPiCleanup(removedPiEntries)]);\n this.write(['', ...this.formatConfigResult(config)]);\n this.write([\n '',\n this.sectionHeading('NEXT'),\n ` ${this.palette.accent('01')} Open ${this.palette.path(config.directory)}.`,\n ` ${this.palette.accent('02')} Edit the YAML files to match how you want Po to work.`,\n ` ${this.palette.accent('03')} From the repository you want to configure, run:`,\n '',\n ` ${this.palette.badge('po sync')}`,\n '',\n `${this.palette.success(READY_RULE)} ${this.palette.success('READY')} Edit your config, then sync it.`,\n ]);\n }\n\n private formatPiCleanup(removed: readonly string[]): string[] {\n return [\n this.sectionHeading('PI CLEANUP'),\n removed.length === 0\n ? ` ${this.palette.success('Pi settings carry no Po entries.')}`\n : ` ${this.palette.warning(`Removed ${String(removed.length)} Po entr${removed.length === 1 ? 'y' : 'ies'}.`)} ${this.palette.muted('Unrelated settings were preserved.')}`,\n ...removed.map((entry) => ` ${this.palette.path(entry)}`),\n ];\n }\n\n private formatConfigResult(result: GlobalPoInitResult): string[] {\n const lines = [\n this.sectionHeading('PO CONFIGURATION'),\n ` ${this.palette.path(result.directory)}`,\n ...GLOBAL_PO_SEED_FILES.map((fileName) => {\n const status = seedFileStatus(result, fileName);\n return ` ${this.fileStatus(status)} ${this.palette.key(fileName.padEnd(13))} ${this.palette.muted('—')} ${SEED_FILE_GUIDANCE[fileName]}`;\n }),\n ];\n if (result.preserved.length > 0) {\n lines.push(` ${this.palette.kept('KEPT')} ${this.palette.muted('files retain your existing edits.')}`);\n }\n if (result.replaced.length > 0) {\n lines.push(\n ` ${this.palette.warning('REPLACED')} ${this.palette.muted(\n 'files were restored from the templates because --force was used.',\n )}`,\n );\n }\n return lines;\n }\n\n private fileStatus(status: SeedFileStatus): string {\n const padded = status.padEnd(8);\n if (status === 'CREATED') return this.palette.accent(padded);\n if (status === 'REPLACED') return this.palette.warning(padded);\n return this.palette.kept(padded);\n }\n\n private sectionHeading(title: string): string {\n return `${this.palette.muted(SECTION_RULE)}\\n${this.palette.heading(title)}`;\n }\n\n private write(lines: readonly string[]): void {\n this.output.write(`${lines.join('\\n')}\\n`);\n }\n}\n"],"mappings":";;;;AAKA,MAAM,kBAAkB;AACxB,MAAM,eAAe;AACrB,MAAM,gBAAgB;AACtB,MAAM,cAAc;AACpB,MAAM,aAAa,GAAG,YAAY;AAClC,MAAM,eAAe,IAAI,OAAO,EAAE;AAClC,MAAM,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AAkB;GACtC,KAAK,KAAK,QAAQ,KAAK,OAAO,SAAS;GACvC,GAAG,qBAAqB,KAAK,aAAa;IACxC,MAAM,SAAS,eAAe,QAAQ,QAAQ;IAC9C,OAAO,KAAK,KAAK,WAAW,MAAM,EAAE,GAAG,KAAK,QAAQ,IAAI,SAAS,OAAO,EAAE,CAAC,EAAE,GAAG,KAAK,QAAQ,MAAM,GAAG,EAAE,GAAG,mBAAmB;GAChI,CAAC;EACH;EACA,IAAI,OAAO,UAAU,SAAS,GAC5B,MAAM,KAAK,KAAK,KAAK,QAAQ,KAAK,MAAM,EAAE,GAAG,KAAK,QAAQ,MAAM,mCAAmC,GAAG;EAExG,IAAI,OAAO,SAAS,SAAS,GAC3B,MAAM,KACJ,KAAK,KAAK,QAAQ,QAAQ,UAAU,EAAE,GAAG,KAAK,QAAQ,MACpD,kEACF,GACF;EAEF,OAAO;CACT;CAEA,WAAmB,QAAgC;EACjD,MAAM,SAAS,OAAO,OAAO,CAAC;EAC9B,IAAI,WAAW,WAAW,OAAO,KAAK,QAAQ,OAAO,MAAM;EAC3D,IAAI,WAAW,YAAY,OAAO,KAAK,QAAQ,QAAQ,MAAM;EAC7D,OAAO,KAAK,QAAQ,KAAK,MAAM;CACjC;CAEA,eAAuB,OAAuB;EAC5C,OAAO,GAAG,KAAK,QAAQ,MAAM,YAAY,EAAE,IAAI,KAAK,QAAQ,QAAQ,KAAK;CAC3E;CAEA,MAAc,OAAgC;EAC5C,KAAK,OAAO,MAAM,GAAG,MAAM,KAAK,IAAI,EAAE,GAAG;CAC3C;AACF"}
|
|
@@ -42,9 +42,9 @@ const HARNESS_ROOT_ENV = "PO_ROOT";
|
|
|
42
42
|
const PRIVATE_DIRECTORY_MODE = 448;
|
|
43
43
|
/** Resolves the configuration source and the root whose packages are installed. */
|
|
44
44
|
function resolveSyncRoots(args, environment = process.env, currentDirectory = process.cwd(), homeDirectory = environment.HOME ?? node_os.default.homedir()) {
|
|
45
|
-
const globalRoot = (0, _agimon_ai_po_config_config.
|
|
45
|
+
const globalRoot = (0, _agimon_ai_po_config_config.globalPoConfigDirectory)(homeDirectory);
|
|
46
46
|
const inheritedRoot = environment[HARNESS_ROOT_ENV];
|
|
47
|
-
const sourceRoot = inheritedRoot ? node_path.default.resolve(inheritedRoot) : require_index$1.
|
|
47
|
+
const sourceRoot = inheritedRoot ? node_path.default.resolve(inheritedRoot) : require_index$1.resolvePoConfigurationRoot(currentDirectory, homeDirectory);
|
|
48
48
|
const globalOnly = args.includes(GLOBAL_OPTION);
|
|
49
49
|
return {
|
|
50
50
|
globalOnly,
|
|
@@ -108,7 +108,7 @@ function syncReadiness(targetRoot, homeDirectory, environment) {
|
|
|
108
108
|
const config = (0, _agimon_ai_po_config_majorModes.loadMajorModesConfigLenient)(root, homeDirectory, environment).config;
|
|
109
109
|
return require_index$4.missingLayerPackageSpecifiers(config, Object.keys(config.layers), require_builders_cli_extensionAssembler_index.createLayerResolvers(root, environment));
|
|
110
110
|
};
|
|
111
|
-
const globalRoot = (0, _agimon_ai_po_config_config.
|
|
111
|
+
const globalRoot = (0, _agimon_ai_po_config_config.globalPoConfigDirectory)(homeDirectory);
|
|
112
112
|
const packages = [...missingIn(targetRoot).map((specifier) => `configured package is not installed: ${specifier}`), ...node_path.default.resolve(targetRoot) === node_path.default.resolve(globalRoot) ? [] : missingIn(globalRoot).map((specifier) => `global package is not installed: ${specifier} (run po sync --global)`)];
|
|
113
113
|
if (packages.length > 0) return {
|
|
114
114
|
packages,
|
|
@@ -155,7 +155,7 @@ async function synchronize(args, environment = process.env, currentDirectory = p
|
|
|
155
155
|
mode: PRIVATE_DIRECTORY_MODE
|
|
156
156
|
});
|
|
157
157
|
const modes = (0, _agimon_ai_po_config_majorModes.loadMajorModesConfigLenient)(sourceRoot, homeDirectory, scopedEnvironment);
|
|
158
|
-
const diagnostics = [...require_index$6.
|
|
158
|
+
const diagnostics = [...require_index$6.loadPoConfigLenient(sourceRoot, homeDirectory).diagnostics, ...modes.diagnostics];
|
|
159
159
|
if (json && diagnostics.length > 0) jsonLine(output, {
|
|
160
160
|
type: "config",
|
|
161
161
|
diagnostics
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["os","globalDoomConfigDirectory","path","resolveDoomConfigurationRoot","HARNESS_STATE_POINTER","PO_MAJOR_MODE_ENV","PO_DOMAINS_ENV","PO_PROFILE_ENV","SyncProgress","formatSyncResult","loadMajorModesConfigLenient","missingLayerPackageSpecifiers","createLayerResolvers","globalWebPluginRoots","readGlobalWebBuildStatus","readGlobalNativeBuildStatus","loadDoomConfigLenient","runSyncService","syncParentPid","syncExitCode"],"sources":["../../../../../src/cli/commands/sync/index.ts"],"sourcesContent":["import fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\n\nimport { globalDoomConfigDirectory } from '@agimon-ai/po-config/config';\nimport { loadMajorModesConfigLenient } from '@agimon-ai/po-config/majorModes';\nimport type { ConfigDiagnostic } from '@agimon-ai/po-config/types';\n\nimport { createLayerResolvers } from '../../../builders/cli/extensionAssembler';\nimport { readGlobalNativeBuildStatus } from '../../../builders/native';\nimport { syncParentPid } from '../../../builders/server/backgroundSync';\nimport { readGlobalWebBuildStatus } from '../../../builders/web';\nimport { HARNESS_STATE_POINTER } from '../../../composition/harnessState';\nimport { missingLayerPackageSpecifiers } from '../../../composition/layerPackageInstaller';\nimport { loadDoomConfigLenient } from '../../../composition/projectTrust';\nimport { resolveDoomConfigurationRoot } from '../../../composition/repository';\nimport {\n formatSyncResult,\n globalWebPluginRoots,\n runSync as runSyncService,\n type SyncDeps,\n type SyncEvent,\n syncExitCode,\n} from '../../../composition/syncService';\nimport { PO_DOMAINS_ENV, PO_MAJOR_MODE_ENV, PO_PROFILE_ENV } from '../../matrixOptions';\nimport { SyncProgress, type SyncProgressOutput, type SyncStepDone } from './presenter';\n\n/**\n * `po sync`: install what every root's configuration names and ensure the global builds.\n *\n * The roots are the Po home, every registered workspace and the current repository, which\n * sync registers unless `--global` is given. The server composes every session live from\n * configuration and installed packages, so sync only makes sure the packages are there\n * and the one global web build (and the MCP app build) for the current plugin set exists.\n * Then, when no other Po host runs, it prunes old builds and the package store.\n */\n\nconst SYNC_COMMAND = 'sync';\nconst CHECK_OPTION = '--check';\nconst GLOBAL_OPTION = '--global';\nconst JSON_OPTION = '--json';\nconst SYNC_OPTIONS = new Set([CHECK_OPTION, GLOBAL_OPTION, JSON_OPTION]);\nconst HARNESS_ROOT_ENV = 'PO_ROOT';\nconst PRIVATE_DIRECTORY_MODE = 0o700;\n\nexport interface SyncRoots {\n globalOnly: boolean;\n globalRoot: string;\n sourceRoot: string;\n targetRoot: string;\n}\n\n/** Resolves the configuration source and the root whose packages are installed. */\nexport function resolveSyncRoots(\n args: readonly string[],\n environment: NodeJS.ProcessEnv = process.env,\n currentDirectory = process.cwd(),\n homeDirectory = environment.HOME ?? os.homedir(),\n): SyncRoots {\n const globalRoot = globalDoomConfigDirectory(homeDirectory);\n const inheritedRoot = environment[HARNESS_ROOT_ENV];\n const sourceRoot = inheritedRoot\n ? path.resolve(inheritedRoot)\n : resolveDoomConfigurationRoot(currentDirectory, homeDirectory);\n const globalOnly = args.includes(GLOBAL_OPTION);\n return { globalOnly, globalRoot, sourceRoot, targetRoot: globalOnly ? globalRoot : sourceRoot };\n}\n\nconst GLOBAL_SCOPE_INHERITED_KEYS = [\n HARNESS_ROOT_ENV,\n HARNESS_STATE_POINTER,\n PO_MAJOR_MODE_ENV,\n PO_DOMAINS_ENV,\n PO_PROFILE_ENV,\n] as const;\n\n/** Removes workspace-only state before a global root is resolved. */\nexport function environmentForSyncScope(environment: NodeJS.ProcessEnv, globalOnly: boolean): NodeJS.ProcessEnv {\n if (!globalOnly) return environment;\n const scoped = { ...environment };\n for (const key of GLOBAL_SCOPE_INHERITED_KEYS) delete scoped[key];\n return scoped;\n}\n\ntype SyncOutput = SyncProgressOutput;\n\nexport interface SyncCommandOptions {\n /** Test/embedding override; normal CLI execution uses the process home. */\n homeDirectory?: string;\n /** Test seams for the install, build and bundle steps and the lock. */\n deps?: Partial<SyncDeps>;\n}\n\n/**\n * Reports the config keys sync chose to ignore.\n *\n * Never fatal. A key nobody recognises is usually a config written for another\n * version of a layer, and refusing to build over it is worse than proceeding\n * without it. The strict check lives in `po doctor`.\n */\nfunction writeConfigDiagnostics(diagnostics: readonly ConfigDiagnostic[], output: SyncOutput): void {\n if (diagnostics.length === 0) return;\n const lines = diagnostics.map((entry) => ` ${entry.filePath}: ${entry.path}`).join('\\n');\n output.write(\n `config: ignored ${String(diagnostics.length)} unsupported key(s); run po doctor for the strict check\\n${lines}\\n`,\n );\n}\n\n/** Renders service events through the step presenter, as text for a terminal or a pipe. */\nfunction textRenderer(output: SyncOutput): (event: SyncEvent) => void {\n const progress = new SyncProgress(output);\n const open = new Map<string, SyncStepDone>();\n return (event) => {\n if (event.type === 'start') open.set(event.label, progress.start(event.label, event.message));\n else if (event.type === 'done') {\n open.get(event.label)?.(event.summary);\n open.delete(event.label);\n } else if (event.type === 'line') progress.line(event.label, event.message);\n else output.write(formatSyncResult(event.result));\n };\n}\n\nfunction jsonLine(output: SyncOutput, value: unknown): void {\n output.write(`${JSON.stringify(value)}\\n`);\n}\n\n/**\n * What `--check` and `po doctor` report.\n *\n * Problems are missing packages, in this root and in the global configuration every session\n * also loads, and a missing global web or native build. Warnings are roots the web build leaves out\n * (another admitted workspace whose configuration cannot be composed): worth saying, but\n * not something this sync can fix, so they never make the check fail.\n */\nexport function syncReadiness(\n targetRoot: string,\n homeDirectory: string,\n environment: NodeJS.ProcessEnv,\n): { packages: string[]; web: string[]; native: string[]; warnings: string[] } {\n const missingIn = (root: string): string[] => {\n const config = loadMajorModesConfigLenient(root, homeDirectory, environment).config;\n return missingLayerPackageSpecifiers(config, Object.keys(config.layers), createLayerResolvers(root, environment));\n };\n const globalRoot = globalDoomConfigDirectory(homeDirectory);\n const packages = [\n ...missingIn(targetRoot).map((specifier) => `configured package is not installed: ${specifier}`),\n ...(path.resolve(targetRoot) === path.resolve(globalRoot)\n ? []\n : missingIn(globalRoot).map(\n (specifier) => `global package is not installed: ${specifier} (run po sync --global)`,\n )),\n ];\n // Plugin roots resolve from installed packages, so the build key means nothing until they are.\n if (packages.length > 0) return { packages, web: [], native: [], warnings: [] };\n const warnings: string[] = [];\n const pluginRoots = globalWebPluginRoots(targetRoot, homeDirectory, environment, (message) => warnings.push(message));\n const status = readGlobalWebBuildStatus({ poHome: globalRoot, pluginRoots, environment });\n const web =\n status.status === 'missing'\n ? [`global web build ${status.key} is missing`]\n : status.status === 'failed'\n ? [`global web build cannot be resolved: ${status.reason}`]\n : [];\n const nativeStatus = readGlobalNativeBuildStatus({ poHome: globalRoot, pluginRoots });\n const native =\n nativeStatus.status === 'missing'\n ? [`global native build ${nativeStatus.key} is missing`]\n : nativeStatus.status === 'failed'\n ? [`global native build cannot be resolved: ${nativeStatus.reason}`]\n : [];\n return { packages, web, native, warnings };\n}\n\n/**\n * Installs every root's configured packages, then ensures the global web build and the MCP app build.\n *\n * Exit codes: 0 when the sync is ok or had nothing to do, 1 when it failed or only partly\n * succeeded, 75 when another sync holds the lock. With `--json`, each progress event is one\n * JSON line and the final line is the `SyncReport`.\n */\nexport async function synchronize(\n args: string[],\n environment: NodeJS.ProcessEnv = process.env,\n currentDirectory = process.cwd(),\n output: SyncOutput = process.stdout,\n commandOptions: SyncCommandOptions = {},\n): Promise<number> {\n const unknown = args.slice(1).filter((argument) => !SYNC_OPTIONS.has(argument));\n if (unknown.length > 0) throw new Error(`Unknown po sync option(s): ${unknown.join(' ')}`);\n const check = args.includes(CHECK_OPTION);\n const json = args.includes(JSON_OPTION);\n const homeDirectory = commandOptions.homeDirectory ?? environment.HOME ?? os.homedir();\n const { globalOnly, globalRoot, sourceRoot, targetRoot } = resolveSyncRoots(\n args,\n environment,\n currentDirectory,\n homeDirectory,\n );\n const scopedEnvironment = environmentForSyncScope(environment, globalOnly);\n if (globalOnly && !check) fs.mkdirSync(globalRoot, { recursive: true, mode: PRIVATE_DIRECTORY_MODE });\n // Sync tolerates keys it does not recognise so a config written against a\n // different version cannot break a build. `po doctor` reports them.\n const modes = loadMajorModesConfigLenient(sourceRoot, homeDirectory, scopedEnvironment);\n const diagnostics = [...loadDoomConfigLenient(sourceRoot, homeDirectory).diagnostics, ...modes.diagnostics];\n if (json && diagnostics.length > 0) jsonLine(output, { type: 'config', diagnostics });\n else if (!json) writeConfigDiagnostics(diagnostics, output);\n\n if (check) {\n const readiness = syncReadiness(targetRoot, homeDirectory, scopedEnvironment);\n for (const warning of readiness.warnings) output.write(`warning: ${warning}\\n`);\n const problems = [...readiness.packages, ...readiness.web, ...readiness.native];\n if (problems.length === 0) {\n output.write('po sync is up to date\\n');\n return 0;\n }\n output.write(`po sync is out of date:\\n${problems.map((entry) => ` ${entry}`).join('\\n')}\\n`);\n return 1;\n }\n\n const report = await runSyncService(\n {\n homeDirectory,\n environment: scopedEnvironment,\n globalRoot,\n // --global covers every root but registers no repository.\n ...(globalOnly ? {} : { repoRoot: sourceRoot }),\n // A host's background job leaves a rerun marker when the lock is held instead of failing.\n origin: syncParentPid(environment) === undefined ? 'cli' : 'background',\n onEvent: json ? (event) => jsonLine(output, event) : textRenderer(output),\n },\n commandOptions.deps,\n );\n if (json) jsonLine(output, { type: 'report', report });\n else for (const error of report.errors) output.write(`error: ${error}\\n`);\n return syncExitCode(report.status);\n}\n\n/** Compatibility API. Executables call the command function directly. */\nexport class SyncCommand {\n readonly name = SYNC_COMMAND;\n private readonly homeDirectory: string | undefined;\n\n constructor(options: SyncCommandOptions = {}) {\n this.homeDirectory = options.homeDirectory;\n }\n\n matches(args: string[]): boolean {\n return args[0] === this.name;\n }\n\n async execute(\n args: string[],\n environment: NodeJS.ProcessEnv = process.env,\n currentDirectory = process.cwd(),\n output: SyncOutput = process.stdout,\n ): Promise<number> {\n return synchronize(args, environment, currentDirectory, output, { homeDirectory: this.homeDirectory });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAq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Q,EAAE,eAAe,KAAK,cAAc,CAAC;CACvG;AACF"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["os","globalPoConfigDirectory","path","resolvePoConfigurationRoot","HARNESS_STATE_POINTER","PO_MAJOR_MODE_ENV","PO_DOMAINS_ENV","PO_PROFILE_ENV","SyncProgress","formatSyncResult","loadMajorModesConfigLenient","missingLayerPackageSpecifiers","createLayerResolvers","globalWebPluginRoots","readGlobalWebBuildStatus","readGlobalNativeBuildStatus","loadPoConfigLenient","runSyncService","syncParentPid","syncExitCode"],"sources":["../../../../../src/cli/commands/sync/index.ts"],"sourcesContent":["import fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\n\nimport { globalPoConfigDirectory } from '@agimon-ai/po-config/config';\nimport { loadMajorModesConfigLenient } from '@agimon-ai/po-config/majorModes';\nimport type { ConfigDiagnostic } from '@agimon-ai/po-config/types';\n\nimport { createLayerResolvers } from '../../../builders/cli/extensionAssembler';\nimport { readGlobalNativeBuildStatus } from '../../../builders/native';\nimport { syncParentPid } from '../../../builders/server/backgroundSync';\nimport { readGlobalWebBuildStatus } from '../../../builders/web';\nimport { HARNESS_STATE_POINTER } from '../../../composition/harnessState';\nimport { missingLayerPackageSpecifiers } from '../../../composition/layerPackageInstaller';\nimport { loadPoConfigLenient } from '../../../composition/projectTrust';\nimport { resolvePoConfigurationRoot } from '../../../composition/repository';\nimport {\n formatSyncResult,\n globalWebPluginRoots,\n runSync as runSyncService,\n type SyncDeps,\n type SyncEvent,\n syncExitCode,\n} from '../../../composition/syncService';\nimport { PO_DOMAINS_ENV, PO_MAJOR_MODE_ENV, PO_PROFILE_ENV } from '../../matrixOptions';\nimport { SyncProgress, type SyncProgressOutput, type SyncStepDone } from './presenter';\n\n/**\n * `po sync`: install what every root's configuration names and ensure the global builds.\n *\n * The roots are the Po home, every registered workspace and the current repository, which\n * sync registers unless `--global` is given. The server composes every session live from\n * configuration and installed packages, so sync only makes sure the packages are there\n * and the one global web build (and the MCP app build) for the current plugin set exists.\n * Then, when no other Po host runs, it prunes old builds and the package store.\n */\n\nconst SYNC_COMMAND = 'sync';\nconst CHECK_OPTION = '--check';\nconst GLOBAL_OPTION = '--global';\nconst JSON_OPTION = '--json';\nconst SYNC_OPTIONS = new Set([CHECK_OPTION, GLOBAL_OPTION, JSON_OPTION]);\nconst HARNESS_ROOT_ENV = 'PO_ROOT';\nconst PRIVATE_DIRECTORY_MODE = 0o700;\n\nexport interface SyncRoots {\n globalOnly: boolean;\n globalRoot: string;\n sourceRoot: string;\n targetRoot: string;\n}\n\n/** Resolves the configuration source and the root whose packages are installed. */\nexport function resolveSyncRoots(\n args: readonly string[],\n environment: NodeJS.ProcessEnv = process.env,\n currentDirectory = process.cwd(),\n homeDirectory = environment.HOME ?? os.homedir(),\n): SyncRoots {\n const globalRoot = globalPoConfigDirectory(homeDirectory);\n const inheritedRoot = environment[HARNESS_ROOT_ENV];\n const sourceRoot = inheritedRoot\n ? path.resolve(inheritedRoot)\n : resolvePoConfigurationRoot(currentDirectory, homeDirectory);\n const globalOnly = args.includes(GLOBAL_OPTION);\n return { globalOnly, globalRoot, sourceRoot, targetRoot: globalOnly ? globalRoot : sourceRoot };\n}\n\nconst GLOBAL_SCOPE_INHERITED_KEYS = [\n HARNESS_ROOT_ENV,\n HARNESS_STATE_POINTER,\n PO_MAJOR_MODE_ENV,\n PO_DOMAINS_ENV,\n PO_PROFILE_ENV,\n] as const;\n\n/** Removes workspace-only state before a global root is resolved. */\nexport function environmentForSyncScope(environment: NodeJS.ProcessEnv, globalOnly: boolean): NodeJS.ProcessEnv {\n if (!globalOnly) return environment;\n const scoped = { ...environment };\n for (const key of GLOBAL_SCOPE_INHERITED_KEYS) delete scoped[key];\n return scoped;\n}\n\ntype SyncOutput = SyncProgressOutput;\n\nexport interface SyncCommandOptions {\n /** Test/embedding override; normal CLI execution uses the process home. */\n homeDirectory?: string;\n /** Test seams for the install, build and bundle steps and the lock. */\n deps?: Partial<SyncDeps>;\n}\n\n/**\n * Reports the config keys sync chose to ignore.\n *\n * Never fatal. A key nobody recognises is usually a config written for another\n * version of a layer, and refusing to build over it is worse than proceeding\n * without it. The strict check lives in `po doctor`.\n */\nfunction writeConfigDiagnostics(diagnostics: readonly ConfigDiagnostic[], output: SyncOutput): void {\n if (diagnostics.length === 0) return;\n const lines = diagnostics.map((entry) => ` ${entry.filePath}: ${entry.path}`).join('\\n');\n output.write(\n `config: ignored ${String(diagnostics.length)} unsupported key(s); run po doctor for the strict check\\n${lines}\\n`,\n );\n}\n\n/** Renders service events through the step presenter, as text for a terminal or a pipe. */\nfunction textRenderer(output: SyncOutput): (event: SyncEvent) => void {\n const progress = new SyncProgress(output);\n const open = new Map<string, SyncStepDone>();\n return (event) => {\n if (event.type === 'start') open.set(event.label, progress.start(event.label, event.message));\n else if (event.type === 'done') {\n open.get(event.label)?.(event.summary);\n open.delete(event.label);\n } else if (event.type === 'line') progress.line(event.label, event.message);\n else output.write(formatSyncResult(event.result));\n };\n}\n\nfunction jsonLine(output: SyncOutput, value: unknown): void {\n output.write(`${JSON.stringify(value)}\\n`);\n}\n\n/**\n * What `--check` and `po doctor` report.\n *\n * Problems are missing packages, in this root and in the global configuration every session\n * also loads, and a missing global web or native build. Warnings are roots the web build leaves out\n * (another admitted workspace whose configuration cannot be composed): worth saying, but\n * not something this sync can fix, so they never make the check fail.\n */\nexport function syncReadiness(\n targetRoot: string,\n homeDirectory: string,\n environment: NodeJS.ProcessEnv,\n): { packages: string[]; web: string[]; native: string[]; warnings: string[] } {\n const missingIn = (root: string): string[] => {\n const config = loadMajorModesConfigLenient(root, homeDirectory, environment).config;\n return missingLayerPackageSpecifiers(config, Object.keys(config.layers), createLayerResolvers(root, environment));\n };\n const globalRoot = globalPoConfigDirectory(homeDirectory);\n const packages = [\n ...missingIn(targetRoot).map((specifier) => `configured package is not installed: ${specifier}`),\n ...(path.resolve(targetRoot) === path.resolve(globalRoot)\n ? []\n : missingIn(globalRoot).map(\n (specifier) => `global package is not installed: ${specifier} (run po sync --global)`,\n )),\n ];\n // Plugin roots resolve from installed packages, so the build key means nothing until they are.\n if (packages.length > 0) return { packages, web: [], native: [], warnings: [] };\n const warnings: string[] = [];\n const pluginRoots = globalWebPluginRoots(targetRoot, homeDirectory, environment, (message) => warnings.push(message));\n const status = readGlobalWebBuildStatus({ poHome: globalRoot, pluginRoots, environment });\n const web =\n status.status === 'missing'\n ? [`global web build ${status.key} is missing`]\n : status.status === 'failed'\n ? [`global web build cannot be resolved: ${status.reason}`]\n : [];\n const nativeStatus = readGlobalNativeBuildStatus({ poHome: globalRoot, pluginRoots });\n const native =\n nativeStatus.status === 'missing'\n ? [`global native build ${nativeStatus.key} is missing`]\n : nativeStatus.status === 'failed'\n ? [`global native build cannot be resolved: ${nativeStatus.reason}`]\n : [];\n return { packages, web, native, warnings };\n}\n\n/**\n * Installs every root's configured packages, then ensures the global web build and the MCP app build.\n *\n * Exit codes: 0 when the sync is ok or had nothing to do, 1 when it failed or only partly\n * succeeded, 75 when another sync holds the lock. With `--json`, each progress event is one\n * JSON line and the final line is the `SyncReport`.\n */\nexport async function synchronize(\n args: string[],\n environment: NodeJS.ProcessEnv = process.env,\n currentDirectory = process.cwd(),\n output: SyncOutput = process.stdout,\n commandOptions: SyncCommandOptions = {},\n): Promise<number> {\n const unknown = args.slice(1).filter((argument) => !SYNC_OPTIONS.has(argument));\n if (unknown.length > 0) throw new Error(`Unknown po sync option(s): ${unknown.join(' ')}`);\n const check = args.includes(CHECK_OPTION);\n const json = args.includes(JSON_OPTION);\n const homeDirectory = commandOptions.homeDirectory ?? environment.HOME ?? os.homedir();\n const { globalOnly, globalRoot, sourceRoot, targetRoot } = resolveSyncRoots(\n args,\n environment,\n currentDirectory,\n homeDirectory,\n );\n const scopedEnvironment = environmentForSyncScope(environment, globalOnly);\n if (globalOnly && !check) fs.mkdirSync(globalRoot, { recursive: true, mode: PRIVATE_DIRECTORY_MODE });\n // Sync tolerates keys it does not recognise so a config written against a\n // different version cannot break a build. `po doctor` reports them.\n const modes = loadMajorModesConfigLenient(sourceRoot, homeDirectory, scopedEnvironment);\n const diagnostics = [...loadPoConfigLenient(sourceRoot, homeDirectory).diagnostics, ...modes.diagnostics];\n if (json && diagnostics.length > 0) jsonLine(output, { type: 'config', diagnostics });\n else if (!json) writeConfigDiagnostics(diagnostics, output);\n\n if (check) {\n const readiness = syncReadiness(targetRoot, homeDirectory, scopedEnvironment);\n for (const warning of readiness.warnings) output.write(`warning: ${warning}\\n`);\n const problems = [...readiness.packages, ...readiness.web, ...readiness.native];\n if (problems.length === 0) {\n output.write('po sync is up to date\\n');\n return 0;\n }\n output.write(`po sync is out of date:\\n${problems.map((entry) => ` ${entry}`).join('\\n')}\\n`);\n return 1;\n }\n\n const report = await runSyncService(\n {\n homeDirectory,\n environment: scopedEnvironment,\n globalRoot,\n // --global covers every root but registers no repository.\n ...(globalOnly ? {} : { repoRoot: sourceRoot }),\n // A host's background job leaves a rerun marker when the lock is held instead of failing.\n origin: syncParentPid(environment) === undefined ? 'cli' : 'background',\n onEvent: json ? (event) => jsonLine(output, event) : textRenderer(output),\n },\n commandOptions.deps,\n );\n if (json) jsonLine(output, { type: 'report', report });\n else for (const error of report.errors) output.write(`error: ${error}\\n`);\n return syncExitCode(report.status);\n}\n\n/** Compatibility API. Executables call the command function directly. */\nexport class SyncCommand {\n readonly name = SYNC_COMMAND;\n private readonly homeDirectory: string | undefined;\n\n constructor(options: SyncCommandOptions = {}) {\n this.homeDirectory = options.homeDirectory;\n }\n\n matches(args: string[]): boolean {\n return args[0] === this.name;\n }\n\n async execute(\n args: string[],\n environment: NodeJS.ProcessEnv = process.env,\n currentDirectory = process.cwd(),\n output: SyncOutput = process.stdout,\n ): Promise<number> {\n return synchronize(args, environment, currentDirectory, output, { homeDirectory: this.homeDirectory });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,MAAM,eAAe;AACrB,MAAM,eAAe;AACrB,MAAM,gBAAgB;AACtB,MAAM,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@
|
|
|
1
1
|
import { PO_DOMAINS_ENV, PO_MAJOR_MODE_ENV, PO_PROFILE_ENV } from "../../matrixOptions.mjs";
|
|
2
2
|
import { HARNESS_STATE_POINTER } from "../../../composition/harnessState/index.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { resolvePoConfigurationRoot } from "../../../composition/repository/index.mjs";
|
|
4
4
|
import { createLayerResolvers } from "../../../../builders/cli/extensionAssembler/index.mjs";
|
|
5
5
|
import { readGlobalWebBuildStatus } from "../../../builders/web/index.mjs";
|
|
6
6
|
import { readGlobalNativeBuildStatus } from "../../../builders/native/index.mjs";
|
|
7
7
|
import { missingLayerPackageSpecifiers } from "../../../composition/layerPackageInstaller/index.mjs";
|
|
8
8
|
import { formatSyncResult, globalWebPluginRoots, runSync, syncExitCode } from "../../../composition/syncService/index.mjs";
|
|
9
9
|
import { syncParentPid } from "../../../builders/server/backgroundSync.mjs";
|
|
10
|
-
import {
|
|
10
|
+
import { loadPoConfigLenient as loadPoConfigLenient$1 } from "../../../composition/projectTrust/index.mjs";
|
|
11
11
|
import { SyncProgress } from "./presenter.mjs";
|
|
12
12
|
import fs from "node:fs";
|
|
13
13
|
import path from "node:path";
|
|
14
14
|
import os from "node:os";
|
|
15
|
-
import {
|
|
15
|
+
import { globalPoConfigDirectory } from "@agimon-ai/po-config/config";
|
|
16
16
|
import { loadMajorModesConfigLenient } from "@agimon-ai/po-config/majorModes";
|
|
17
17
|
//#region src/cli/commands/sync/index.ts
|
|
18
18
|
/**
|
|
@@ -37,9 +37,9 @@ const HARNESS_ROOT_ENV = "PO_ROOT";
|
|
|
37
37
|
const PRIVATE_DIRECTORY_MODE = 448;
|
|
38
38
|
/** Resolves the configuration source and the root whose packages are installed. */
|
|
39
39
|
function resolveSyncRoots(args, environment = process.env, currentDirectory = process.cwd(), homeDirectory = environment.HOME ?? os.homedir()) {
|
|
40
|
-
const globalRoot =
|
|
40
|
+
const globalRoot = globalPoConfigDirectory(homeDirectory);
|
|
41
41
|
const inheritedRoot = environment[HARNESS_ROOT_ENV];
|
|
42
|
-
const sourceRoot = inheritedRoot ? path.resolve(inheritedRoot) :
|
|
42
|
+
const sourceRoot = inheritedRoot ? path.resolve(inheritedRoot) : resolvePoConfigurationRoot(currentDirectory, homeDirectory);
|
|
43
43
|
const globalOnly = args.includes(GLOBAL_OPTION);
|
|
44
44
|
return {
|
|
45
45
|
globalOnly,
|
|
@@ -103,7 +103,7 @@ function syncReadiness(targetRoot, homeDirectory, environment) {
|
|
|
103
103
|
const config = loadMajorModesConfigLenient(root, homeDirectory, environment).config;
|
|
104
104
|
return missingLayerPackageSpecifiers(config, Object.keys(config.layers), createLayerResolvers(root, environment));
|
|
105
105
|
};
|
|
106
|
-
const globalRoot =
|
|
106
|
+
const globalRoot = globalPoConfigDirectory(homeDirectory);
|
|
107
107
|
const packages = [...missingIn(targetRoot).map((specifier) => `configured package is not installed: ${specifier}`), ...path.resolve(targetRoot) === path.resolve(globalRoot) ? [] : missingIn(globalRoot).map((specifier) => `global package is not installed: ${specifier} (run po sync --global)`)];
|
|
108
108
|
if (packages.length > 0) return {
|
|
109
109
|
packages,
|
|
@@ -150,7 +150,7 @@ async function synchronize(args, environment = process.env, currentDirectory = p
|
|
|
150
150
|
mode: PRIVATE_DIRECTORY_MODE
|
|
151
151
|
});
|
|
152
152
|
const modes = loadMajorModesConfigLenient(sourceRoot, homeDirectory, scopedEnvironment);
|
|
153
|
-
const diagnostics = [...
|
|
153
|
+
const diagnostics = [...loadPoConfigLenient$1(sourceRoot, homeDirectory).diagnostics, ...modes.diagnostics];
|
|
154
154
|
if (json && diagnostics.length > 0) jsonLine(output, {
|
|
155
155
|
type: "config",
|
|
156
156
|
diagnostics
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["loadDoomConfigLenient","runSyncService"],"sources":["../../../../../src/cli/commands/sync/index.ts"],"sourcesContent":["import fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\n\nimport { globalDoomConfigDirectory } from '@agimon-ai/po-config/config';\nimport { loadMajorModesConfigLenient } from '@agimon-ai/po-config/majorModes';\nimport type { ConfigDiagnostic } from '@agimon-ai/po-config/types';\n\nimport { createLayerResolvers } from '../../../builders/cli/extensionAssembler';\nimport { readGlobalNativeBuildStatus } from '../../../builders/native';\nimport { syncParentPid } from '../../../builders/server/backgroundSync';\nimport { readGlobalWebBuildStatus } from '../../../builders/web';\nimport { HARNESS_STATE_POINTER } from '../../../composition/harnessState';\nimport { missingLayerPackageSpecifiers } from '../../../composition/layerPackageInstaller';\nimport { loadDoomConfigLenient } from '../../../composition/projectTrust';\nimport { resolveDoomConfigurationRoot } from '../../../composition/repository';\nimport {\n formatSyncResult,\n globalWebPluginRoots,\n runSync as runSyncService,\n type SyncDeps,\n type SyncEvent,\n syncExitCode,\n} from '../../../composition/syncService';\nimport { PO_DOMAINS_ENV, PO_MAJOR_MODE_ENV, PO_PROFILE_ENV } from '../../matrixOptions';\nimport { SyncProgress, type SyncProgressOutput, type SyncStepDone } from './presenter';\n\n/**\n * `po sync`: install what every root's configuration names and ensure the global builds.\n *\n * The roots are the Po home, every registered workspace and the current repository, which\n * sync registers unless `--global` is given. The server composes every session live from\n * configuration and installed packages, so sync only makes sure the packages are there\n * and the one global web build (and the MCP app build) for the current plugin set exists.\n * Then, when no other Po host runs, it prunes old builds and the package store.\n */\n\nconst SYNC_COMMAND = 'sync';\nconst CHECK_OPTION = '--check';\nconst GLOBAL_OPTION = '--global';\nconst JSON_OPTION = '--json';\nconst SYNC_OPTIONS = new Set([CHECK_OPTION, GLOBAL_OPTION, JSON_OPTION]);\nconst HARNESS_ROOT_ENV = 'PO_ROOT';\nconst PRIVATE_DIRECTORY_MODE = 0o700;\n\nexport interface SyncRoots {\n globalOnly: boolean;\n globalRoot: string;\n sourceRoot: string;\n targetRoot: string;\n}\n\n/** Resolves the configuration source and the root whose packages are installed. */\nexport function resolveSyncRoots(\n args: readonly string[],\n environment: NodeJS.ProcessEnv = process.env,\n currentDirectory = process.cwd(),\n homeDirectory = environment.HOME ?? os.homedir(),\n): SyncRoots {\n const globalRoot = globalDoomConfigDirectory(homeDirectory);\n const inheritedRoot = environment[HARNESS_ROOT_ENV];\n const sourceRoot = inheritedRoot\n ? path.resolve(inheritedRoot)\n : resolveDoomConfigurationRoot(currentDirectory, homeDirectory);\n const globalOnly = args.includes(GLOBAL_OPTION);\n return { globalOnly, globalRoot, sourceRoot, targetRoot: globalOnly ? globalRoot : sourceRoot };\n}\n\nconst GLOBAL_SCOPE_INHERITED_KEYS = [\n HARNESS_ROOT_ENV,\n HARNESS_STATE_POINTER,\n PO_MAJOR_MODE_ENV,\n PO_DOMAINS_ENV,\n PO_PROFILE_ENV,\n] as const;\n\n/** Removes workspace-only state before a global root is resolved. */\nexport function environmentForSyncScope(environment: NodeJS.ProcessEnv, globalOnly: boolean): NodeJS.ProcessEnv {\n if (!globalOnly) return environment;\n const scoped = { ...environment };\n for (const key of GLOBAL_SCOPE_INHERITED_KEYS) delete scoped[key];\n return scoped;\n}\n\ntype SyncOutput = SyncProgressOutput;\n\nexport interface SyncCommandOptions {\n /** Test/embedding override; normal CLI execution uses the process home. */\n homeDirectory?: string;\n /** Test seams for the install, build and bundle steps and the lock. */\n deps?: Partial<SyncDeps>;\n}\n\n/**\n * Reports the config keys sync chose to ignore.\n *\n * Never fatal. A key nobody recognises is usually a config written for another\n * version of a layer, and refusing to build over it is worse than proceeding\n * without it. The strict check lives in `po doctor`.\n */\nfunction writeConfigDiagnostics(diagnostics: readonly ConfigDiagnostic[], output: SyncOutput): void {\n if (diagnostics.length === 0) return;\n const lines = diagnostics.map((entry) => ` ${entry.filePath}: ${entry.path}`).join('\\n');\n output.write(\n `config: ignored ${String(diagnostics.length)} unsupported key(s); run po doctor for the strict check\\n${lines}\\n`,\n );\n}\n\n/** Renders service events through the step presenter, as text for a terminal or a pipe. */\nfunction textRenderer(output: SyncOutput): (event: SyncEvent) => void {\n const progress = new SyncProgress(output);\n const open = new Map<string, SyncStepDone>();\n return (event) => {\n if (event.type === 'start') open.set(event.label, progress.start(event.label, event.message));\n else if (event.type === 'done') {\n open.get(event.label)?.(event.summary);\n open.delete(event.label);\n } else if (event.type === 'line') progress.line(event.label, event.message);\n else output.write(formatSyncResult(event.result));\n };\n}\n\nfunction jsonLine(output: SyncOutput, value: unknown): void {\n output.write(`${JSON.stringify(value)}\\n`);\n}\n\n/**\n * What `--check` and `po doctor` report.\n *\n * Problems are missing packages, in this root and in the global configuration every session\n * also loads, and a missing global web or native build. Warnings are roots the web build leaves out\n * (another admitted workspace whose configuration cannot be composed): worth saying, but\n * not something this sync can fix, so they never make the check fail.\n */\nexport function syncReadiness(\n targetRoot: string,\n homeDirectory: string,\n environment: NodeJS.ProcessEnv,\n): { packages: string[]; web: string[]; native: string[]; warnings: string[] } {\n const missingIn = (root: string): string[] => {\n const config = loadMajorModesConfigLenient(root, homeDirectory, environment).config;\n return missingLayerPackageSpecifiers(config, Object.keys(config.layers), createLayerResolvers(root, environment));\n };\n const globalRoot = globalDoomConfigDirectory(homeDirectory);\n const packages = [\n ...missingIn(targetRoot).map((specifier) => `configured package is not installed: ${specifier}`),\n ...(path.resolve(targetRoot) === path.resolve(globalRoot)\n ? []\n : missingIn(globalRoot).map(\n (specifier) => `global package is not installed: ${specifier} (run po sync --global)`,\n )),\n ];\n // Plugin roots resolve from installed packages, so the build key means nothing until they are.\n if (packages.length > 0) return { packages, web: [], native: [], warnings: [] };\n const warnings: string[] = [];\n const pluginRoots = globalWebPluginRoots(targetRoot, homeDirectory, environment, (message) => warnings.push(message));\n const status = readGlobalWebBuildStatus({ poHome: globalRoot, pluginRoots, environment });\n const web =\n status.status === 'missing'\n ? [`global web build ${status.key} is missing`]\n : status.status === 'failed'\n ? [`global web build cannot be resolved: ${status.reason}`]\n : [];\n const nativeStatus = readGlobalNativeBuildStatus({ poHome: globalRoot, pluginRoots });\n const native =\n nativeStatus.status === 'missing'\n ? [`global native build ${nativeStatus.key} is missing`]\n : nativeStatus.status === 'failed'\n ? [`global native build cannot be resolved: ${nativeStatus.reason}`]\n : [];\n return { packages, web, native, warnings };\n}\n\n/**\n * Installs every root's configured packages, then ensures the global web build and the MCP app build.\n *\n * Exit codes: 0 when the sync is ok or had nothing to do, 1 when it failed or only partly\n * succeeded, 75 when another sync holds the lock. With `--json`, each progress event is one\n * JSON line and the final line is the `SyncReport`.\n */\nexport async function synchronize(\n args: string[],\n environment: NodeJS.ProcessEnv = process.env,\n currentDirectory = process.cwd(),\n output: SyncOutput = process.stdout,\n commandOptions: SyncCommandOptions = {},\n): Promise<number> {\n const unknown = args.slice(1).filter((argument) => !SYNC_OPTIONS.has(argument));\n if (unknown.length > 0) throw new Error(`Unknown po sync option(s): ${unknown.join(' ')}`);\n const check = args.includes(CHECK_OPTION);\n const json = args.includes(JSON_OPTION);\n const homeDirectory = commandOptions.homeDirectory ?? environment.HOME ?? os.homedir();\n const { globalOnly, globalRoot, sourceRoot, targetRoot } = resolveSyncRoots(\n args,\n environment,\n currentDirectory,\n homeDirectory,\n );\n const scopedEnvironment = environmentForSyncScope(environment, globalOnly);\n if (globalOnly && !check) fs.mkdirSync(globalRoot, { recursive: true, mode: PRIVATE_DIRECTORY_MODE });\n // Sync tolerates keys it does not recognise so a config written against a\n // different version cannot break a build. `po doctor` reports them.\n const modes = loadMajorModesConfigLenient(sourceRoot, homeDirectory, scopedEnvironment);\n const diagnostics = [...loadDoomConfigLenient(sourceRoot, homeDirectory).diagnostics, ...modes.diagnostics];\n if (json && diagnostics.length > 0) jsonLine(output, { type: 'config', diagnostics });\n else if (!json) writeConfigDiagnostics(diagnostics, output);\n\n if (check) {\n const readiness = syncReadiness(targetRoot, homeDirectory, scopedEnvironment);\n for (const warning of readiness.warnings) output.write(`warning: ${warning}\\n`);\n const problems = [...readiness.packages, ...readiness.web, ...readiness.native];\n if (problems.length === 0) {\n output.write('po sync is up to date\\n');\n return 0;\n }\n output.write(`po sync is out of date:\\n${problems.map((entry) => ` ${entry}`).join('\\n')}\\n`);\n return 1;\n }\n\n const report = await runSyncService(\n {\n homeDirectory,\n environment: scopedEnvironment,\n globalRoot,\n // --global covers every root but registers no repository.\n ...(globalOnly ? {} : { repoRoot: sourceRoot }),\n // A host's background job leaves a rerun marker when the lock is held instead of failing.\n origin: syncParentPid(environment) === undefined ? 'cli' : 'background',\n onEvent: json ? (event) => jsonLine(output, event) : textRenderer(output),\n },\n commandOptions.deps,\n );\n if (json) jsonLine(output, { type: 'report', report });\n else for (const error of report.errors) output.write(`error: ${error}\\n`);\n return syncExitCode(report.status);\n}\n\n/** Compatibility API. Executables call the command function directly. */\nexport class SyncCommand {\n readonly name = SYNC_COMMAND;\n private readonly homeDirectory: string | undefined;\n\n constructor(options: SyncCommandOptions = {}) {\n this.homeDirectory = options.homeDirectory;\n }\n\n matches(args: string[]): boolean {\n return args[0] === this.name;\n }\n\n async execute(\n args: string[],\n environment: NodeJS.ProcessEnv = process.env,\n currentDirectory = process.cwd(),\n output: SyncOutput = process.stdout,\n ): Promise<number> {\n return synchronize(args, environment, currentDirectory, output, { homeDirectory: this.homeDirectory });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,MAAM,eAAe;AACrB,MAAM,eAAe;AACrB,MAAM,gBAAgB;AACtB,MAAM,cAAc;AACpB,MAAM,+BAAe,IAAI,IAAI;CAAC;CAAc;CAAe;AAAW,CAAC;AACvE,MAAM,mBAAmB;AACzB,MAAM,yBAAyB;;AAU/B,SAAgB,iBACd,MACA,cAAiC,QAAQ,KACzC,mBAAmB,QAAQ,IAAI,GAC/B,gBAAgB,YAAY,QAAQ,GAAG,QAAQ,GACpC;CACX,MAAM,aAAa,0BAA0B,aAAa;CAC1D,MAAM,gBAAgB,YAAY;CAClC,MAAM,aAAa,gBACf,KAAK,QAAQ,aAAa,IAC1B,6BAA6B,kBAAkB,aAAa;CAChE,MAAM,aAAa,KAAK,SAAS,aAAa;CAC9C,OAAO;EAAE;EAAY;EAAY;EAAY,YAAY,a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;EAAE,MAAM;EAAU;CAAO,CAAC;MAChD,KAAK,MAAM,SAAS,OAAO,QAAQ,OAAO,MAAM,aAAa,MAAM,GAAG;CAC3E,OAAO,aAAa,OAAO,MAAM;AACnC;;AAGA,IAAa,cAAb,MAAyB;CACvB,OAAgB;CAChB;CAEA,YAAY,UAA8B,CAAC,GAAG;EAC5C,KAAK,gBAAgB,QAAQ;CAC/B;CAEA,QAAQ,MAAyB;EAC/B,OAAO,KAAK,OAAO,KAAK;CAC1B;CAEA,MAAM,QACJ,MACA,cAAiC,QAAQ,KACzC,mBAAmB,QAAQ,IAAI,GAC/B,SAAqB,QAAQ,QACZ;EACjB,OAAO,YAAY,MAAM,aAAa,kBAAkB,QAAQ,EAAE,eAAe,KAAK,cAAc,CAAC;CACvG;AACF"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["loadPoConfigLenient","runSyncService"],"sources":["../../../../../src/cli/commands/sync/index.ts"],"sourcesContent":["import fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\n\nimport { globalPoConfigDirectory } from '@agimon-ai/po-config/config';\nimport { loadMajorModesConfigLenient } from '@agimon-ai/po-config/majorModes';\nimport type { ConfigDiagnostic } from '@agimon-ai/po-config/types';\n\nimport { createLayerResolvers } from '../../../builders/cli/extensionAssembler';\nimport { readGlobalNativeBuildStatus } from '../../../builders/native';\nimport { syncParentPid } from '../../../builders/server/backgroundSync';\nimport { readGlobalWebBuildStatus } from '../../../builders/web';\nimport { HARNESS_STATE_POINTER } from '../../../composition/harnessState';\nimport { missingLayerPackageSpecifiers } from '../../../composition/layerPackageInstaller';\nimport { loadPoConfigLenient } from '../../../composition/projectTrust';\nimport { resolvePoConfigurationRoot } from '../../../composition/repository';\nimport {\n formatSyncResult,\n globalWebPluginRoots,\n runSync as runSyncService,\n type SyncDeps,\n type SyncEvent,\n syncExitCode,\n} from '../../../composition/syncService';\nimport { PO_DOMAINS_ENV, PO_MAJOR_MODE_ENV, PO_PROFILE_ENV } from '../../matrixOptions';\nimport { SyncProgress, type SyncProgressOutput, type SyncStepDone } from './presenter';\n\n/**\n * `po sync`: install what every root's configuration names and ensure the global builds.\n *\n * The roots are the Po home, every registered workspace and the current repository, which\n * sync registers unless `--global` is given. The server composes every session live from\n * configuration and installed packages, so sync only makes sure the packages are there\n * and the one global web build (and the MCP app build) for the current plugin set exists.\n * Then, when no other Po host runs, it prunes old builds and the package store.\n */\n\nconst SYNC_COMMAND = 'sync';\nconst CHECK_OPTION = '--check';\nconst GLOBAL_OPTION = '--global';\nconst JSON_OPTION = '--json';\nconst SYNC_OPTIONS = new Set([CHECK_OPTION, GLOBAL_OPTION, JSON_OPTION]);\nconst HARNESS_ROOT_ENV = 'PO_ROOT';\nconst PRIVATE_DIRECTORY_MODE = 0o700;\n\nexport interface SyncRoots {\n globalOnly: boolean;\n globalRoot: string;\n sourceRoot: string;\n targetRoot: string;\n}\n\n/** Resolves the configuration source and the root whose packages are installed. */\nexport function resolveSyncRoots(\n args: readonly string[],\n environment: NodeJS.ProcessEnv = process.env,\n currentDirectory = process.cwd(),\n homeDirectory = environment.HOME ?? os.homedir(),\n): SyncRoots {\n const globalRoot = globalPoConfigDirectory(homeDirectory);\n const inheritedRoot = environment[HARNESS_ROOT_ENV];\n const sourceRoot = inheritedRoot\n ? path.resolve(inheritedRoot)\n : resolvePoConfigurationRoot(currentDirectory, homeDirectory);\n const globalOnly = args.includes(GLOBAL_OPTION);\n return { globalOnly, globalRoot, sourceRoot, targetRoot: globalOnly ? globalRoot : sourceRoot };\n}\n\nconst GLOBAL_SCOPE_INHERITED_KEYS = [\n HARNESS_ROOT_ENV,\n HARNESS_STATE_POINTER,\n PO_MAJOR_MODE_ENV,\n PO_DOMAINS_ENV,\n PO_PROFILE_ENV,\n] as const;\n\n/** Removes workspace-only state before a global root is resolved. */\nexport function environmentForSyncScope(environment: NodeJS.ProcessEnv, globalOnly: boolean): NodeJS.ProcessEnv {\n if (!globalOnly) return environment;\n const scoped = { ...environment };\n for (const key of GLOBAL_SCOPE_INHERITED_KEYS) delete scoped[key];\n return scoped;\n}\n\ntype SyncOutput = SyncProgressOutput;\n\nexport interface SyncCommandOptions {\n /** Test/embedding override; normal CLI execution uses the process home. */\n homeDirectory?: string;\n /** Test seams for the install, build and bundle steps and the lock. */\n deps?: Partial<SyncDeps>;\n}\n\n/**\n * Reports the config keys sync chose to ignore.\n *\n * Never fatal. A key nobody recognises is usually a config written for another\n * version of a layer, and refusing to build over it is worse than proceeding\n * without it. The strict check lives in `po doctor`.\n */\nfunction writeConfigDiagnostics(diagnostics: readonly ConfigDiagnostic[], output: SyncOutput): void {\n if (diagnostics.length === 0) return;\n const lines = diagnostics.map((entry) => ` ${entry.filePath}: ${entry.path}`).join('\\n');\n output.write(\n `config: ignored ${String(diagnostics.length)} unsupported key(s); run po doctor for the strict check\\n${lines}\\n`,\n );\n}\n\n/** Renders service events through the step presenter, as text for a terminal or a pipe. */\nfunction textRenderer(output: SyncOutput): (event: SyncEvent) => void {\n const progress = new SyncProgress(output);\n const open = new Map<string, SyncStepDone>();\n return (event) => {\n if (event.type === 'start') open.set(event.label, progress.start(event.label, event.message));\n else if (event.type === 'done') {\n open.get(event.label)?.(event.summary);\n open.delete(event.label);\n } else if (event.type === 'line') progress.line(event.label, event.message);\n else output.write(formatSyncResult(event.result));\n };\n}\n\nfunction jsonLine(output: SyncOutput, value: unknown): void {\n output.write(`${JSON.stringify(value)}\\n`);\n}\n\n/**\n * What `--check` and `po doctor` report.\n *\n * Problems are missing packages, in this root and in the global configuration every session\n * also loads, and a missing global web or native build. Warnings are roots the web build leaves out\n * (another admitted workspace whose configuration cannot be composed): worth saying, but\n * not something this sync can fix, so they never make the check fail.\n */\nexport function syncReadiness(\n targetRoot: string,\n homeDirectory: string,\n environment: NodeJS.ProcessEnv,\n): { packages: string[]; web: string[]; native: string[]; warnings: string[] } {\n const missingIn = (root: string): string[] => {\n const config = loadMajorModesConfigLenient(root, homeDirectory, environment).config;\n return missingLayerPackageSpecifiers(config, Object.keys(config.layers), createLayerResolvers(root, environment));\n };\n const globalRoot = globalPoConfigDirectory(homeDirectory);\n const packages = [\n ...missingIn(targetRoot).map((specifier) => `configured package is not installed: ${specifier}`),\n ...(path.resolve(targetRoot) === path.resolve(globalRoot)\n ? []\n : missingIn(globalRoot).map(\n (specifier) => `global package is not installed: ${specifier} (run po sync --global)`,\n )),\n ];\n // Plugin roots resolve from installed packages, so the build key means nothing until they are.\n if (packages.length > 0) return { packages, web: [], native: [], warnings: [] };\n const warnings: string[] = [];\n const pluginRoots = globalWebPluginRoots(targetRoot, homeDirectory, environment, (message) => warnings.push(message));\n const status = readGlobalWebBuildStatus({ poHome: globalRoot, pluginRoots, environment });\n const web =\n status.status === 'missing'\n ? [`global web build ${status.key} is missing`]\n : status.status === 'failed'\n ? [`global web build cannot be resolved: ${status.reason}`]\n : [];\n const nativeStatus = readGlobalNativeBuildStatus({ poHome: globalRoot, pluginRoots });\n const native =\n nativeStatus.status === 'missing'\n ? [`global native build ${nativeStatus.key} is missing`]\n : nativeStatus.status === 'failed'\n ? [`global native build cannot be resolved: ${nativeStatus.reason}`]\n : [];\n return { packages, web, native, warnings };\n}\n\n/**\n * Installs every root's configured packages, then ensures the global web build and the MCP app build.\n *\n * Exit codes: 0 when the sync is ok or had nothing to do, 1 when it failed or only partly\n * succeeded, 75 when another sync holds the lock. With `--json`, each progress event is one\n * JSON line and the final line is the `SyncReport`.\n */\nexport async function synchronize(\n args: string[],\n environment: NodeJS.ProcessEnv = process.env,\n currentDirectory = process.cwd(),\n output: SyncOutput = process.stdout,\n commandOptions: SyncCommandOptions = {},\n): Promise<number> {\n const unknown = args.slice(1).filter((argument) => !SYNC_OPTIONS.has(argument));\n if (unknown.length > 0) throw new Error(`Unknown po sync option(s): ${unknown.join(' ')}`);\n const check = args.includes(CHECK_OPTION);\n const json = args.includes(JSON_OPTION);\n const homeDirectory = commandOptions.homeDirectory ?? environment.HOME ?? os.homedir();\n const { globalOnly, globalRoot, sourceRoot, targetRoot } = resolveSyncRoots(\n args,\n environment,\n currentDirectory,\n homeDirectory,\n );\n const scopedEnvironment = environmentForSyncScope(environment, globalOnly);\n if (globalOnly && !check) fs.mkdirSync(globalRoot, { recursive: true, mode: PRIVATE_DIRECTORY_MODE });\n // Sync tolerates keys it does not recognise so a config written against a\n // different version cannot break a build. `po doctor` reports them.\n const modes = loadMajorModesConfigLenient(sourceRoot, homeDirectory, scopedEnvironment);\n const diagnostics = [...loadPoConfigLenient(sourceRoot, homeDirectory).diagnostics, ...modes.diagnostics];\n if (json && diagnostics.length > 0) jsonLine(output, { type: 'config', diagnostics });\n else if (!json) writeConfigDiagnostics(diagnostics, output);\n\n if (check) {\n const readiness = syncReadiness(targetRoot, homeDirectory, scopedEnvironment);\n for (const warning of readiness.warnings) output.write(`warning: ${warning}\\n`);\n const problems = [...readiness.packages, ...readiness.web, ...readiness.native];\n if (problems.length === 0) {\n output.write('po sync is up to date\\n');\n return 0;\n }\n output.write(`po sync is out of date:\\n${problems.map((entry) => ` ${entry}`).join('\\n')}\\n`);\n return 1;\n }\n\n const report = await runSyncService(\n {\n homeDirectory,\n environment: scopedEnvironment,\n globalRoot,\n // --global covers every root but registers no repository.\n ...(globalOnly ? {} : { repoRoot: sourceRoot }),\n // A host's background job leaves a rerun marker when the lock is held instead of failing.\n origin: syncParentPid(environment) === undefined ? 'cli' : 'background',\n onEvent: json ? (event) => jsonLine(output, event) : textRenderer(output),\n },\n commandOptions.deps,\n );\n if (json) jsonLine(output, { type: 'report', report });\n else for (const error of report.errors) output.write(`error: ${error}\\n`);\n return syncExitCode(report.status);\n}\n\n/** Compatibility API. Executables call the command function directly. */\nexport class SyncCommand {\n readonly name = SYNC_COMMAND;\n private readonly homeDirectory: string | undefined;\n\n constructor(options: SyncCommandOptions = {}) {\n this.homeDirectory = options.homeDirectory;\n }\n\n matches(args: string[]): boolean {\n return args[0] === this.name;\n }\n\n async execute(\n args: string[],\n environment: NodeJS.ProcessEnv = process.env,\n currentDirectory = process.cwd(),\n output: SyncOutput = process.stdout,\n ): Promise<number> {\n return synchronize(args, environment, currentDirectory, output, { homeDirectory: this.homeDirectory });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,MAAM,eAAe;AACrB,MAAM,eAAe;AACrB,MAAM,gBAAgB;AACtB,MAAM,cAAc;AACpB,MAAM,+BAAe,IAAI,IAAI;CAAC;CAAc;CAAe;AAAW,CAAC;AACvE,MAAM,mBAAmB;AACzB,MAAM,yBAAyB;;AAU/B,SAAgB,iBACd,MACA,cAAiC,QAAQ,KACzC,mBAAmB,QAAQ,IAAI,GAC/B,gBAAgB,YAAY,QAAQ,GAAG,QAAQ,GACpC;CACX,MAAM,aAAa,wBAAwB,aAAa;CACxD,MAAM,gBAAgB,YAAY;CAClC,MAAM,aAAa,gBACf,KAAK,QAAQ,aAAa,IAC1B,2BAA2B,kBAAkB,aAAa;CAC9D,MAAM,aAAa,KAAK,SAAS,aAAa;CAC9C,OAAO;EAAE;EAAY;EAAY;EAAY,YAAY,aAAa,aAAa;CAAW;AAChG;AAEA,MAAM,8BAA8B;CAClC;CACA;CACA;CACA;CACA;AACF;;AAGA,SAAgB,wBAAwB,aAAgC,YAAwC;CAC9G,IAAI,CAAC,YAAY,OAAO;CACxB,MAAM,SAAS,EAAE,GAAG,YAAY;CAChC,KAAK,MAAM,OAAO,6BAA6B,OAAO,OAAO;CAC7D,OAAO;AACT;;;;;;;;AAkBA,SAAS,uBAAuB,aAA0C,QAA0B;CAClG,IAAI,YAAY,WAAW,GAAG;CAC9B,MAAM,QAAQ,YAAY,KAAK,UAAU,KAAK,MAAM,SAAS,IAAI,MAAM,MAAM,CAAC,CAAC,KAAK,IAAI;CACxF,OAAO,MACL,qBAAqB,OAAO,YAAY,MAAM,EAAE,2DAA2D,MAAM,GACnH;AACF;;AAGA,SAAS,aAAa,QAAgD;CACpE,MAAM,WAAW,IAAI,aAAa,MAAM;CACxC,MAAM,uBAAO,IAAI,IAA0B;CAC3C,Q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MAAM,YAAY,cAAc,YAAY,eAAe,iBAAiB;EAC5E,KAAK,MAAM,WAAW,UAAU,UAAU,OAAO,MAAM,aAAa,QAAQ,GAAG;EAC/E,MAAM,WAAW;GAAC,GAAG,UAAU;GAAU,GAAG,UAAU;GAAK,GAAG,UAAU;EAAM;EAC9E,IAAI,SAAS,WAAW,GAAG;GACzB,OAAO,MAAM,yBAAyB;GACtC,OAAO;EACT;EACA,OAAO,MAAM,4BAA4B,SAAS,KAAK,UAAU,KAAK,OAAO,CAAC,CAAC,KAAK,IAAI,EAAE,GAAG;EAC7F,OAAO;CACT;CAEA,MAAM,SAAS,MAAMC,QACnB;EACE;EACA,aAAa;EACb;EAEA,GAAI,aAAa,CAAC,IAAI,EAAE,UAAU,WAAW;EAE7C,QAAQ,cAAc,WAAW,MAAM,KAAA,IAAY,QAAQ;EAC3D,SAAS,QAAQ,UAAU,SAAS,QAAQ,KAAK,IAAI,aAAa,MAAM;CAC1E,GACA,eAAe,IACjB;CACA,IAAI,MAAM,SAAS,QAAQ;EAAE,MAAM;EAAU;CAAO,CAAC;MAChD,KAAK,MAAM,SAAS,OAAO,QAAQ,OAAO,MAAM,aAAa,MAAM,GAAG;CAC3E,OAAO,aAAa,OAAO,MAAM;AACnC;;AAGA,IAAa,cAAb,MAAyB;CACvB,OAAgB;CAChB;CAEA,YAAY,UAA8B,CAAC,GAAG;EAC5C,KAAK,gBAAgB,QAAQ;CAC/B;CAEA,QAAQ,MAAyB;EAC/B,OAAO,KAAK,OAAO,KAAK;CAC1B;CAEA,MAAM,QACJ,MACA,cAAiC,QAAQ,KACzC,mBAAmB,QAAQ,IAAI,GAC/B,SAAqB,QAAQ,QACZ;EACjB,OAAO,YAAY,MAAM,aAAa,kBAAkB,QAAQ,EAAE,eAAe,KAAK,cAAc,CAAC;CACvG;AACF"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* the registry check, the mode build, and the runtime precompile. A terminal
|
|
7
7
|
* gets a live line that the finished step overwrites, so the transcript stays
|
|
8
8
|
* as short as the existing summary. Anything else (a pipe, CI, the embedded
|
|
9
|
-
*
|
|
9
|
+
* po runner) gets one line per completed step and no escape sequences.
|
|
10
10
|
*/
|
|
11
11
|
const LABEL_WIDTH = 10;
|
|
12
12
|
const CLEAR_LINE = `${String.fromCharCode(27)}[2K\r`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presenter.cjs","names":[],"sources":["../../../../../src/cli/commands/sync/presenter.ts"],"sourcesContent":["/**\n * Step-by-step progress for `po sync`.\n *\n * Sync spends almost all of its wall clock in three places a user cannot see:\n * the registry check, the mode build, and the runtime precompile. A terminal\n * gets a live line that the finished step overwrites, so the transcript stays\n * as short as the existing summary. Anything else (a pipe, CI, the embedded\n *
|
|
1
|
+
{"version":3,"file":"presenter.cjs","names":[],"sources":["../../../../../src/cli/commands/sync/presenter.ts"],"sourcesContent":["/**\n * Step-by-step progress for `po sync`.\n *\n * Sync spends almost all of its wall clock in three places a user cannot see:\n * the registry check, the mode build, and the runtime precompile. A terminal\n * gets a live line that the finished step overwrites, so the transcript stays\n * as short as the existing summary. Anything else (a pipe, CI, the embedded\n * po runner) gets one line per completed step and no escape sequences.\n */\n\nconst LABEL_WIDTH = 10;\nconst ANSI_ESCAPE = String.fromCharCode(0x1b);\nconst CLEAR_LINE = `${ANSI_ESCAPE}[2K\\r`;\nconst MILLISECONDS_PER_SECOND = 1000;\n\nexport interface SyncProgressOutput {\n write: NodeJS.WritableStream['write'];\n isTTY?: boolean;\n}\n\n/** Closes the step a `start` call opened, recording how long it took. */\nexport type SyncStepDone = (summary: string) => void;\n\nexport function formatProgressLine(label: string, message: string): string {\n return `${`${label}:`.padEnd(LABEL_WIDTH)}${message}`;\n}\n\nfunction formatElapsed(milliseconds: number): string {\n return `${(milliseconds / MILLISECONDS_PER_SECOND).toFixed(1)}s`;\n}\n\n/** Reports sync phases as they run rather than only after everything is done. */\nexport class SyncProgress {\n private readonly output: SyncProgressOutput;\n private readonly now: () => number;\n private live = false;\n\n constructor(output: SyncProgressOutput, now: () => number = Date.now) {\n this.output = output;\n this.now = now;\n }\n\n /** Opens a timed step and returns the call that closes it. */\n start(label: string, message: string): SyncStepDone {\n const startedAt = this.now();\n this.drawLive(formatProgressLine(label, `${message}...`));\n return (summary) => {\n this.clearLive();\n this.output.write(`${formatProgressLine(label, `${summary} (${formatElapsed(this.now() - startedAt)})`)}\\n`);\n };\n }\n\n /** Writes a standalone line, such as one package moving to a new version. */\n line(label: string, message: string): void {\n this.clearLive();\n this.output.write(`${formatProgressLine(label, message)}\\n`);\n }\n\n private drawLive(text: string): void {\n if (!this.output.isTTY) return;\n this.output.write(`${CLEAR_LINE}${text}`);\n this.live = true;\n }\n\n private clearLive(): void {\n if (!this.live) return;\n this.output.write(CLEAR_LINE);\n this.live = false;\n }\n}\n"],"mappings":";;;;;;;;;;AAUA,MAAM,cAAc;AAEpB,MAAM,aAAa,GADC,OAAO,aAAa,EACR,EAAE;AAClC,MAAM,0BAA0B;AAUhC,SAAgB,mBAAmB,OAAe,SAAyB;CACzE,OAAO,GAAG,GAAG,MAAM,GAAG,OAAO,WAAW,IAAI;AAC9C;AAEA,SAAS,cAAc,cAA8B;CACnD,OAAO,IAAI,eAAe,wBAAA,CAAyB,QAAQ,CAAC,EAAE;AAChE;;AAGA,IAAa,eAAb,MAA0B;CACxB;CACA;CACA,OAAe;CAEf,YAAY,QAA4B,MAAoB,KAAK,KAAK;EACpE,KAAK,SAAS;EACd,KAAK,MAAM;CACb;;CAGA,MAAM,OAAe,SAA+B;EAClD,MAAM,YAAY,KAAK,IAAI;EAC3B,KAAK,SAAS,mBAAmB,OAAO,GAAG,QAAQ,IAAI,CAAC;EACxD,QAAQ,YAAY;GAClB,KAAK,UAAU;GACf,KAAK,OAAO,MAAM,GAAG,mBAAmB,OAAO,GAAG,QAAQ,IAAI,cAAc,KAAK,IAAI,IAAI,SAAS,EAAE,EAAE,EAAE,GAAG;EAC7G;CACF;;CAGA,KAAK,OAAe,SAAuB;EACzC,KAAK,UAAU;EACf,KAAK,OAAO,MAAM,GAAG,mBAAmB,OAAO,OAAO,EAAE,GAAG;CAC7D;CAEA,SAAiB,MAAoB;EACnC,IAAI,CAAC,KAAK,OAAO,OAAO;EACxB,KAAK,OAAO,MAAM,GAAG,aAAa,MAAM;EACxC,KAAK,OAAO;CACd;CAEA,YAA0B;EACxB,IAAI,CAAC,KAAK,MAAM;EAChB,KAAK,OAAO,MAAM,UAAU;EAC5B,KAAK,OAAO;CACd;AACF"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* the registry check, the mode build, and the runtime precompile. A terminal
|
|
7
7
|
* gets a live line that the finished step overwrites, so the transcript stays
|
|
8
8
|
* as short as the existing summary. Anything else (a pipe, CI, the embedded
|
|
9
|
-
*
|
|
9
|
+
* po runner) gets one line per completed step and no escape sequences.
|
|
10
10
|
*/
|
|
11
11
|
export interface SyncProgressOutput {
|
|
12
12
|
write: NodeJS.WritableStream['write'];
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* the registry check, the mode build, and the runtime precompile. A terminal
|
|
7
7
|
* gets a live line that the finished step overwrites, so the transcript stays
|
|
8
8
|
* as short as the existing summary. Anything else (a pipe, CI, the embedded
|
|
9
|
-
*
|
|
9
|
+
* po runner) gets one line per completed step and no escape sequences.
|
|
10
10
|
*/
|
|
11
11
|
const LABEL_WIDTH = 10;
|
|
12
12
|
const CLEAR_LINE = `${String.fromCharCode(27)}[2K\r`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presenter.mjs","names":[],"sources":["../../../../../src/cli/commands/sync/presenter.ts"],"sourcesContent":["/**\n * Step-by-step progress for `po sync`.\n *\n * Sync spends almost all of its wall clock in three places a user cannot see:\n * the registry check, the mode build, and the runtime precompile. A terminal\n * gets a live line that the finished step overwrites, so the transcript stays\n * as short as the existing summary. Anything else (a pipe, CI, the embedded\n *
|
|
1
|
+
{"version":3,"file":"presenter.mjs","names":[],"sources":["../../../../../src/cli/commands/sync/presenter.ts"],"sourcesContent":["/**\n * Step-by-step progress for `po sync`.\n *\n * Sync spends almost all of its wall clock in three places a user cannot see:\n * the registry check, the mode build, and the runtime precompile. A terminal\n * gets a live line that the finished step overwrites, so the transcript stays\n * as short as the existing summary. Anything else (a pipe, CI, the embedded\n * po runner) gets one line per completed step and no escape sequences.\n */\n\nconst LABEL_WIDTH = 10;\nconst ANSI_ESCAPE = String.fromCharCode(0x1b);\nconst CLEAR_LINE = `${ANSI_ESCAPE}[2K\\r`;\nconst MILLISECONDS_PER_SECOND = 1000;\n\nexport interface SyncProgressOutput {\n write: NodeJS.WritableStream['write'];\n isTTY?: boolean;\n}\n\n/** Closes the step a `start` call opened, recording how long it took. */\nexport type SyncStepDone = (summary: string) => void;\n\nexport function formatProgressLine(label: string, message: string): string {\n return `${`${label}:`.padEnd(LABEL_WIDTH)}${message}`;\n}\n\nfunction formatElapsed(milliseconds: number): string {\n return `${(milliseconds / MILLISECONDS_PER_SECOND).toFixed(1)}s`;\n}\n\n/** Reports sync phases as they run rather than only after everything is done. */\nexport class SyncProgress {\n private readonly output: SyncProgressOutput;\n private readonly now: () => number;\n private live = false;\n\n constructor(output: SyncProgressOutput, now: () => number = Date.now) {\n this.output = output;\n this.now = now;\n }\n\n /** Opens a timed step and returns the call that closes it. */\n start(label: string, message: string): SyncStepDone {\n const startedAt = this.now();\n this.drawLive(formatProgressLine(label, `${message}...`));\n return (summary) => {\n this.clearLive();\n this.output.write(`${formatProgressLine(label, `${summary} (${formatElapsed(this.now() - startedAt)})`)}\\n`);\n };\n }\n\n /** Writes a standalone line, such as one package moving to a new version. */\n line(label: string, message: string): void {\n this.clearLive();\n this.output.write(`${formatProgressLine(label, message)}\\n`);\n }\n\n private drawLive(text: string): void {\n if (!this.output.isTTY) return;\n this.output.write(`${CLEAR_LINE}${text}`);\n this.live = true;\n }\n\n private clearLive(): void {\n if (!this.live) return;\n this.output.write(CLEAR_LINE);\n this.live = false;\n }\n}\n"],"mappings":";;;;;;;;;;AAUA,MAAM,cAAc;AAEpB,MAAM,aAAa,GADC,OAAO,aAAa,EACR,EAAE;AAClC,MAAM,0BAA0B;AAUhC,SAAgB,mBAAmB,OAAe,SAAyB;CACzE,OAAO,GAAG,GAAG,MAAM,GAAG,OAAO,WAAW,IAAI;AAC9C;AAEA,SAAS,cAAc,cAA8B;CACnD,OAAO,IAAI,eAAe,wBAAA,CAAyB,QAAQ,CAAC,EAAE;AAChE;;AAGA,IAAa,eAAb,MAA0B;CACxB;CACA;CACA,OAAe;CAEf,YAAY,QAA4B,MAAoB,KAAK,KAAK;EACpE,KAAK,SAAS;EACd,KAAK,MAAM;CACb;;CAGA,MAAM,OAAe,SAA+B;EAClD,MAAM,YAAY,KAAK,IAAI;EAC3B,KAAK,SAAS,mBAAmB,OAAO,GAAG,QAAQ,IAAI,CAAC;EACxD,QAAQ,YAAY;GAClB,KAAK,UAAU;GACf,KAAK,OAAO,MAAM,GAAG,mBAAmB,OAAO,GAAG,QAAQ,IAAI,cAAc,KAAK,IAAI,IAAI,SAAS,EAAE,EAAE,EAAE,GAAG;EAC7G;CACF;;CAGA,KAAK,OAAe,SAAuB;EACzC,KAAK,UAAU;EACf,KAAK,OAAO,MAAM,GAAG,mBAAmB,OAAO,OAAO,EAAE,GAAG;CAC7D;CAEA,SAAiB,MAAoB;EACnC,IAAI,CAAC,KAAK,OAAO,OAAO;EACxB,KAAK,OAAO,MAAM,GAAG,aAAa,MAAM;EACxC,KAAK,OAAO;CACd;CAEA,YAA0B;EACxB,IAAI,CAAC,KAAK,MAAM;EAChB,KAAK,OAAO,MAAM,UAAU;EAC5B,KAAK,OAAO;CACd;AACF"}
|
|
@@ -35,7 +35,8 @@ function binEntry(manifest) {
|
|
|
35
35
|
function resolvePoWebBin(dependencies) {
|
|
36
36
|
let manifestPath;
|
|
37
37
|
try {
|
|
38
|
-
|
|
38
|
+
const local = process.env.PO_TEST === "1" ? process.env.PO_WEB_PACKAGE_ROOT : void 0;
|
|
39
|
+
manifestPath = local ? node_path.default.join(local, "package.json") : dependencies.resolve(PO_WEB_MANIFEST);
|
|
39
40
|
} catch {
|
|
40
41
|
return;
|
|
41
42
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["require","createRequire","spawn","path"],"sources":["../../../../../src/cli/commands/web/index.ts"],"sourcesContent":["import { type ChildProcess, spawn } from 'node:child_process';\nimport { createRequire } from 'node:module';\nimport path from 'node:path';\n\nconst PO_WEB_PACKAGE = '@agimon-ai/po-web';\nconst PO_WEB_MANIFEST = `${PO_WEB_PACKAGE}/package.json`;\nconst PO_WEB_BIN = 'po-web';\nconst FORWARDED_SIGNALS = ['SIGINT', 'SIGTERM'] as const;\nconst SIGNAL_EXIT_BASE = 128;\nconst SIGNAL_NUMBERS: Record<string, number> = { SIGINT: 2, SIGTERM: 15 };\n\nexport interface PoWebOutput {\n write(chunk: string): void;\n}\n\nexport interface PoWebDependencies {\n /** Resolves a module specifier to an absolute path, throwing when it is not installed. */\n resolve: (specifier: string) => string;\n /** Reads a resolved package manifest. */\n readManifest: (manifestPath: string) => unknown;\n spawn: (command: string, args: string[]) => ChildProcess;\n signals: Pick<NodeJS.Process, 'on' | 'off'>;\n error: PoWebOutput;\n}\n\nfunction defaultDependencies(): PoWebDependencies {\n const require = createRequire(import.meta.url);\n return {\n resolve: (specifier) => require.resolve(specifier),\n readManifest: (manifestPath) => require(manifestPath) as unknown,\n spawn: (command, args) => spawn(command, args, { stdio: 'inherit' }),\n signals: process,\n error: process.stderr,\n };\n}\n\nfunction binEntry(manifest: unknown): string | undefined {\n if (typeof manifest !== 'object' || manifest === null) return undefined;\n const bin = (manifest as { bin?: unknown }).bin;\n if (typeof bin === 'string') return bin;\n if (typeof bin !== 'object' || bin === null) return undefined;\n const entry = (bin as Record<string, unknown>)[PO_WEB_BIN];\n return typeof entry === 'string' ? entry : undefined;\n}\n\n/** Absolute path of the installed po-web bin, or undefined when po-web is not installed. */\nexport function resolvePoWebBin(dependencies: Pick<PoWebDependencies, 'resolve' | 'readManifest'>): string | undefined {\n let manifestPath: string;\n try {\n manifestPath = dependencies.resolve(PO_WEB_MANIFEST);\n } catch {\n return undefined;\n }\n const entry = binEntry(dependencies.readManifest(manifestPath));\n return entry ? path.resolve(path.dirname(manifestPath), entry) : undefined;\n}\n\nfunction installGuidance(): string {\n return `po could not find ${PO_WEB_PACKAGE}, which serves the Po web console.\nInstall it next to po, for example:\n npm install -g ${PO_WEB_PACKAGE}\n`;\n}\n\n/**\n * Bare `po`: runs the po-web console with the caller's arguments.\n *\n * po-web depends on po, so po locates it at runtime instead of declaring it.\n * The child inherits stdio, receives SIGINT and SIGTERM, and its exit code\n * becomes po's.\n */\nexport async function runPoWeb(\n args: string[],\n dependencies: PoWebDependencies = defaultDependencies(),\n): Promise<number> {\n const bin = resolvePoWebBin(dependencies);\n if (!bin) {\n dependencies.error.write(installGuidance());\n return 1;\n }\n const child = dependencies.spawn(process.execPath, [bin, ...args]);\n const forwarders = FORWARDED_SIGNALS.map((signal) => {\n const forward = (): void => {\n child.kill(signal);\n };\n dependencies.signals.on(signal, forward);\n return [signal, forward] as const;\n });\n try {\n return await new Promise<number>((resolve, reject) => {\n child.once('error', reject);\n child.once('exit', (code, signal) => {\n if (code !== null) resolve(code);\n else resolve(SIGNAL_EXIT_BASE + (signal ? (SIGNAL_NUMBERS[signal] ?? 0) : 0));\n });\n });\n } finally {\n for (const [signal, forward] of forwarders) dependencies.signals.off(signal, forward);\n }\n}\n"],"mappings":";;;;;;AAIA,MAAM,iBAAiB;AACvB,MAAM,kBAAkB,GAAG,eAAe;AAC1C,MAAM,aAAa;AACnB,MAAM,oBAAoB,CAAC,UAAU,SAAS;AAC9C,MAAM,mBAAmB;AACzB,MAAM,iBAAyC;CAAE,QAAQ;CAAG,SAAS;AAAG;AAgBxE,SAAS,sBAAyC;CAChD,MAAMA,aAAAA,GAAUC,YAAAA,cAAAA,CAAAA,QAAAA,KAAAA,CAAAA,CAAAA,cAAAA,UAAAA,CAAAA,CAAAA,IAA6B;CAC7C,OAAO;EACL,UAAU,cAAcD,UAAQ,QAAQ,SAAS;EACjD,eAAe,iBAAiBA,UAAQ,YAAY;EACpD,QAAQ,SAAS,UAAA,GAASE,mBAAAA,MAAAA,CAAM,SAAS,MAAM,EAAE,OAAO,UAAU,CAAC;EACnE,SAAS;EACT,OAAO,QAAQ;CACjB;AACF;AAEA,SAAS,SAAS,UAAuC;CACvD,IAAI,OAAO,aAAa,YAAY,aAAa,MAAM,OAAO,KAAA;CAC9D,MAAM,MAAO,SAA+B;CAC5C,IAAI,OAAO,QAAQ,UAAU,OAAO;CACpC,IAAI,OAAO,QAAQ,YAAY,QAAQ,MAAM,OAAO,KAAA;CACpD,MAAM,QAAS,IAAgC;CAC/C,OAAO,OAAO,UAAU,WAAW,QAAQ,KAAA;AAC7C;;AAGA,SAAgB,gBAAgB,cAAuF;CACrH,IAAI;CACJ,IAAI;EACF,eAAe,aAAa,QAAQ,eAAe;
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["require","createRequire","spawn","path"],"sources":["../../../../../src/cli/commands/web/index.ts"],"sourcesContent":["import { type ChildProcess, spawn } from 'node:child_process';\nimport { createRequire } from 'node:module';\nimport path from 'node:path';\n\nconst PO_WEB_PACKAGE = '@agimon-ai/po-web';\nconst PO_WEB_MANIFEST = `${PO_WEB_PACKAGE}/package.json`;\nconst PO_WEB_BIN = 'po-web';\nconst FORWARDED_SIGNALS = ['SIGINT', 'SIGTERM'] as const;\nconst SIGNAL_EXIT_BASE = 128;\nconst SIGNAL_NUMBERS: Record<string, number> = { SIGINT: 2, SIGTERM: 15 };\n\nexport interface PoWebOutput {\n write(chunk: string): void;\n}\n\nexport interface PoWebDependencies {\n /** Resolves a module specifier to an absolute path, throwing when it is not installed. */\n resolve: (specifier: string) => string;\n /** Reads a resolved package manifest. */\n readManifest: (manifestPath: string) => unknown;\n spawn: (command: string, args: string[]) => ChildProcess;\n signals: Pick<NodeJS.Process, 'on' | 'off'>;\n error: PoWebOutput;\n}\n\nfunction defaultDependencies(): PoWebDependencies {\n const require = createRequire(import.meta.url);\n return {\n resolve: (specifier) => require.resolve(specifier),\n readManifest: (manifestPath) => require(manifestPath) as unknown,\n spawn: (command, args) => spawn(command, args, { stdio: 'inherit' }),\n signals: process,\n error: process.stderr,\n };\n}\n\nfunction binEntry(manifest: unknown): string | undefined {\n if (typeof manifest !== 'object' || manifest === null) return undefined;\n const bin = (manifest as { bin?: unknown }).bin;\n if (typeof bin === 'string') return bin;\n if (typeof bin !== 'object' || bin === null) return undefined;\n const entry = (bin as Record<string, unknown>)[PO_WEB_BIN];\n return typeof entry === 'string' ? entry : undefined;\n}\n\n/** Absolute path of the installed po-web bin, or undefined when po-web is not installed. */\nexport function resolvePoWebBin(dependencies: Pick<PoWebDependencies, 'resolve' | 'readManifest'>): string | undefined {\n let manifestPath: string;\n try {\n const local = process.env.PO_TEST === '1' ? process.env.PO_WEB_PACKAGE_ROOT : undefined;\n manifestPath = local ? path.join(local, 'package.json') : dependencies.resolve(PO_WEB_MANIFEST);\n } catch {\n return undefined;\n }\n const entry = binEntry(dependencies.readManifest(manifestPath));\n return entry ? path.resolve(path.dirname(manifestPath), entry) : undefined;\n}\n\nfunction installGuidance(): string {\n return `po could not find ${PO_WEB_PACKAGE}, which serves the Po web console.\nInstall it next to po, for example:\n npm install -g ${PO_WEB_PACKAGE}\n`;\n}\n\n/**\n * Bare `po`: runs the po-web console with the caller's arguments.\n *\n * po-web depends on po, so po locates it at runtime instead of declaring it.\n * The child inherits stdio, receives SIGINT and SIGTERM, and its exit code\n * becomes po's.\n */\nexport async function runPoWeb(\n args: string[],\n dependencies: PoWebDependencies = defaultDependencies(),\n): Promise<number> {\n const bin = resolvePoWebBin(dependencies);\n if (!bin) {\n dependencies.error.write(installGuidance());\n return 1;\n }\n const child = dependencies.spawn(process.execPath, [bin, ...args]);\n const forwarders = FORWARDED_SIGNALS.map((signal) => {\n const forward = (): void => {\n child.kill(signal);\n };\n dependencies.signals.on(signal, forward);\n return [signal, forward] as const;\n });\n try {\n return await new Promise<number>((resolve, reject) => {\n child.once('error', reject);\n child.once('exit', (code, signal) => {\n if (code !== null) resolve(code);\n else resolve(SIGNAL_EXIT_BASE + (signal ? (SIGNAL_NUMBERS[signal] ?? 0) : 0));\n });\n });\n } finally {\n for (const [signal, forward] of forwarders) dependencies.signals.off(signal, forward);\n }\n}\n"],"mappings":";;;;;;AAIA,MAAM,iBAAiB;AACvB,MAAM,kBAAkB,GAAG,eAAe;AAC1C,MAAM,aAAa;AACnB,MAAM,oBAAoB,CAAC,UAAU,SAAS;AAC9C,MAAM,mBAAmB;AACzB,MAAM,iBAAyC;CAAE,QAAQ;CAAG,SAAS;AAAG;AAgBxE,SAAS,sBAAyC;CAChD,MAAMA,aAAAA,GAAUC,YAAAA,cAAAA,CAAAA,QAAAA,KAAAA,CAAAA,CAAAA,cAAAA,UAAAA,CAAAA,CAAAA,IAA6B;CAC7C,OAAO;EACL,UAAU,cAAcD,UAAQ,QAAQ,SAAS;EACjD,eAAe,iBAAiBA,UAAQ,YAAY;EACpD,QAAQ,SAAS,UAAA,GAASE,mBAAAA,MAAAA,CAAM,SAAS,MAAM,EAAE,OAAO,UAAU,CAAC;EACnE,SAAS;EACT,OAAO,QAAQ;CACjB;AACF;AAEA,SAAS,SAAS,UAAuC;CACvD,IAAI,OAAO,aAAa,YAAY,aAAa,MAAM,OAAO,KAAA;CAC9D,MAAM,MAAO,SAA+B;CAC5C,IAAI,OAAO,QAAQ,UAAU,OAAO;CACpC,IAAI,OAAO,QAAQ,YAAY,QAAQ,MAAM,OAAO,KAAA;CACpD,MAAM,QAAS,IAAgC;CAC/C,OAAO,OAAO,UAAU,WAAW,QAAQ,KAAA;AAC7C;;AAGA,SAAgB,gBAAgB,cAAuF;CACrH,IAAI;CACJ,IAAI;EACF,MAAM,QAAQ,QAAQ,IAAI,YAAY,MAAM,QAAQ,IAAI,sBAAsB,KAAA;EAC9E,eAAe,QAAQC,UAAAA,QAAK,KAAK,OAAO,cAAc,IAAI,aAAa,QAAQ,eAAe;CAChG,QAAQ;EACN;CACF;CACA,MAAM,QAAQ,SAAS,aAAa,aAAa,YAAY,CAAC;CAC9D,OAAO,QAAQA,UAAAA,QAAK,QAAQA,UAAAA,QAAK,QAAQ,YAAY,GAAG,KAAK,IAAI,KAAA;AACnE;AAEA,SAAS,kBAA0B;CACjC,OAAO,qBAAqB,eAAe;;mBAE1B,eAAe;;AAElC;;;;;;;;AASA,eAAsB,SACpB,MACA,eAAkC,oBAAoB,GACrC;CACjB,MAAM,MAAM,gBAAgB,YAAY;CACxC,IAAI,CAAC,KAAK;EACR,aAAa,MAAM,MAAM,gBAAgB,CAAC;EAC1C,OAAO;CACT;CACA,MAAM,QAAQ,aAAa,MAAM,QAAQ,UAAU,CAAC,KAAK,GAAG,IAAI,CAAC;CACjE,MAAM,aAAa,kBAAkB,KAAK,WAAW;EACnD,MAAM,gBAAsB;GAC1B,MAAM,KAAK,MAAM;EACnB;EACA,aAAa,QAAQ,GAAG,QAAQ,OAAO;EACvC,OAAO,CAAC,QAAQ,OAAO;CACzB,CAAC;CACD,IAAI;EACF,OAAO,MAAM,IAAI,SAAiB,SAAS,WAAW;GACpD,MAAM,KAAK,SAAS,MAAM;GAC1B,MAAM,KAAK,SAAS,MAAM,WAAW;IACnC,IAAI,SAAS,MAAM,QAAQ,IAAI;SAC1B,QAAQ,oBAAoB,SAAU,eAAe,WAAW,IAAK,EAAE;GAC9E,CAAC;EACH,CAAC;CACH,UAAU;EACR,KAAK,MAAM,CAAC,QAAQ,YAAY,YAAY,aAAa,QAAQ,IAAI,QAAQ,OAAO;CACtF;AACF"}
|
|
@@ -33,7 +33,8 @@ function binEntry(manifest) {
|
|
|
33
33
|
function resolvePoWebBin(dependencies) {
|
|
34
34
|
let manifestPath;
|
|
35
35
|
try {
|
|
36
|
-
|
|
36
|
+
const local = process.env.PO_TEST === "1" ? process.env.PO_WEB_PACKAGE_ROOT : void 0;
|
|
37
|
+
manifestPath = local ? path.join(local, "package.json") : dependencies.resolve(PO_WEB_MANIFEST);
|
|
37
38
|
} catch {
|
|
38
39
|
return;
|
|
39
40
|
}
|