@vreko/cli 3.0.1
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/LICENSE +201 -0
- package/README.md +45 -0
- package/dist/CeremonyView-LQS7FTMK.js +134 -0
- package/dist/CeremonyView-LQS7FTMK.js.map +1 -0
- package/dist/InitApp-7K5DTYSW.js +1479 -0
- package/dist/InitApp-7K5DTYSW.js.map +1 -0
- package/dist/SkippedTestDetector-PJSKSOZR.js +7 -0
- package/dist/SkippedTestDetector-PJSKSOZR.js.map +1 -0
- package/dist/TuiApp-FX23XQBK.js +8 -0
- package/dist/TuiApp-FX23XQBK.js.map +1 -0
- package/dist/analysis-ABEO6RTN.js +8 -0
- package/dist/analysis-ABEO6RTN.js.map +1 -0
- package/dist/auth-XNBEBNPY.js +7669 -0
- package/dist/auth-XNBEBNPY.js.map +1 -0
- package/dist/ceremony-M7CXVBVA.js +45 -0
- package/dist/ceremony-M7CXVBVA.js.map +1 -0
- package/dist/chunk-A3QSZJPD.js +3147 -0
- package/dist/chunk-A3QSZJPD.js.map +1 -0
- package/dist/chunk-ASGZ5B6C.js +3969 -0
- package/dist/chunk-ASGZ5B6C.js.map +1 -0
- package/dist/chunk-DMXC2JTC.js +58 -0
- package/dist/chunk-DMXC2JTC.js.map +1 -0
- package/dist/chunk-EEBSK2IH.js +161 -0
- package/dist/chunk-EEBSK2IH.js.map +1 -0
- package/dist/chunk-EWOJGXRX.js +22 -0
- package/dist/chunk-EWOJGXRX.js.map +1 -0
- package/dist/chunk-F7GEJLP7.js +2389 -0
- package/dist/chunk-F7GEJLP7.js.map +1 -0
- package/dist/chunk-GOYL3F4T.js +605 -0
- package/dist/chunk-GOYL3F4T.js.map +1 -0
- package/dist/chunk-GRMRYWYS.js +17 -0
- package/dist/chunk-GRMRYWYS.js.map +1 -0
- package/dist/chunk-GSUGROXB.js +1951 -0
- package/dist/chunk-GSUGROXB.js.map +1 -0
- package/dist/chunk-H7773ONB.js +50 -0
- package/dist/chunk-H7773ONB.js.map +1 -0
- package/dist/chunk-HFQHU5LC.js +445 -0
- package/dist/chunk-HFQHU5LC.js.map +1 -0
- package/dist/chunk-IVHUBLJD.js +318 -0
- package/dist/chunk-IVHUBLJD.js.map +1 -0
- package/dist/chunk-KJWKY4L4.js +14 -0
- package/dist/chunk-KJWKY4L4.js.map +1 -0
- package/dist/chunk-MJVY2XUN.js +1793 -0
- package/dist/chunk-MJVY2XUN.js.map +1 -0
- package/dist/chunk-QWZVCJII.js +1797 -0
- package/dist/chunk-QWZVCJII.js.map +1 -0
- package/dist/chunk-VTSNRV3V.js +3237 -0
- package/dist/chunk-VTSNRV3V.js.map +1 -0
- package/dist/chunk-W5B4GTXR.js +1466 -0
- package/dist/chunk-W5B4GTXR.js.map +1 -0
- package/dist/chunk-WZEZLVOW.js +4995 -0
- package/dist/chunk-WZEZLVOW.js.map +1 -0
- package/dist/chunk-YPTTIXKC.js +199 -0
- package/dist/chunk-YPTTIXKC.js.map +1 -0
- package/dist/chunk-Z55UGM6X.js +6360 -0
- package/dist/chunk-Z55UGM6X.js.map +1 -0
- package/dist/chunk-ZIIRQODJ.js +110 -0
- package/dist/chunk-ZIIRQODJ.js.map +1 -0
- package/dist/chunk-ZSUQ4FMB.js +77 -0
- package/dist/chunk-ZSUQ4FMB.js.map +1 -0
- package/dist/client-JMTSZS3V.js +10 -0
- package/dist/client-JMTSZS3V.js.map +1 -0
- package/dist/deprecated-snap.js +19 -0
- package/dist/deprecated-snap.js.map +1 -0
- package/dist/dist-2KWBZFLA.js +14 -0
- package/dist/dist-2KWBZFLA.js.map +1 -0
- package/dist/dist-5ZYKNNU3.js +7 -0
- package/dist/dist-5ZYKNNU3.js.map +1 -0
- package/dist/dist-CP3RFHPI.js +11 -0
- package/dist/dist-CP3RFHPI.js.map +1 -0
- package/dist/gecko-53ITAGG6.js +56 -0
- package/dist/gecko-53ITAGG6.js.map +1 -0
- package/dist/guards-QAFC64NO.js +7 -0
- package/dist/guards-QAFC64NO.js.map +1 -0
- package/dist/index.js +57785 -0
- package/dist/index.js.map +1 -0
- package/dist/init-command-246JIVXM.js +7 -0
- package/dist/init-command-246JIVXM.js.map +1 -0
- package/dist/init-core-KAI7LCXZ.js +12 -0
- package/dist/init-core-KAI7LCXZ.js.map +1 -0
- package/dist/init-scan-RZNYDTUV.js +1919 -0
- package/dist/init-scan-RZNYDTUV.js.map +1 -0
- package/dist/local-service-adapter-6KNN6WQL.js +8 -0
- package/dist/local-service-adapter-6KNN6WQL.js.map +1 -0
- package/dist/secure-credentials-JXWAQLS2.js +306 -0
- package/dist/secure-credentials-JXWAQLS2.js.map +1 -0
- package/dist/tui-TPJPUS2R.js +111 -0
- package/dist/tui-TPJPUS2R.js.map +1 -0
- package/dist/vreko-dir-O3RLG7PI.js +8 -0
- package/dist/vreko-dir-O3RLG7PI.js.map +1 -0
- package/package.json +132 -0
- package/scripts/check-banned-words.ts +152 -0
- package/scripts/hooks/posttooluse-file-notify.sh +108 -0
- package/scripts/hooks/pretooluse-fragile-guard.sh +82 -0
- package/scripts/post-install-notice.js +24 -0
- package/scripts/postinstall.mjs +84 -0
- package/scripts/preuninstall.mjs +34 -0
- package/scripts/verify-jsx-transform.mjs +55 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
|
|
4
|
+
process.env.VREKO_CLI='true';process.env.NODE_NO_WARNINGS='1';
|
|
5
|
+
var BRAND_COLORS = {
|
|
6
|
+
/** Primary brand green - main color for headers, highlights */
|
|
7
|
+
primary: "#4ADE80",
|
|
8
|
+
/** Darker green for secondary elements */
|
|
9
|
+
primaryDark: "#22C55E",
|
|
10
|
+
/** Light green for subtle highlights */
|
|
11
|
+
primaryLight: "#6EE7A7",
|
|
12
|
+
/** Semantic colors */
|
|
13
|
+
success: "#34D399",
|
|
14
|
+
warning: "#FF6B35",
|
|
15
|
+
error: "#EF4444",
|
|
16
|
+
info: "#3B82F6",
|
|
17
|
+
/** Neutral colors */
|
|
18
|
+
muted: "#71717A",
|
|
19
|
+
text: "#FAFAFA"
|
|
20
|
+
};
|
|
21
|
+
var theme = {
|
|
22
|
+
/** Primary brand color - use for headers, highlights, commands */
|
|
23
|
+
brand: chalk.hex(BRAND_COLORS.primary),
|
|
24
|
+
/** Primary brand color bold - use for section headers */
|
|
25
|
+
brandBold: chalk.hex(BRAND_COLORS.primary).bold,
|
|
26
|
+
/** Darker brand color - use for secondary emphasis */
|
|
27
|
+
brandDark: chalk.hex(BRAND_COLORS.primaryDark),
|
|
28
|
+
/** Success messages */
|
|
29
|
+
success: chalk.hex(BRAND_COLORS.success),
|
|
30
|
+
/** Warning messages */
|
|
31
|
+
warning: chalk.hex(BRAND_COLORS.warning),
|
|
32
|
+
/** Error messages */
|
|
33
|
+
error: chalk.hex(BRAND_COLORS.error),
|
|
34
|
+
/** Informational (semantic blue - use sparingly) */
|
|
35
|
+
info: chalk.hex(BRAND_COLORS.info),
|
|
36
|
+
/** Muted/secondary text */
|
|
37
|
+
muted: chalk.gray,
|
|
38
|
+
/** Dimmed text */
|
|
39
|
+
dim: chalk.dim,
|
|
40
|
+
/** Bold text */
|
|
41
|
+
bold: chalk.bold,
|
|
42
|
+
/** White text */
|
|
43
|
+
white: chalk.white,
|
|
44
|
+
/** Table headers - use brand color */
|
|
45
|
+
tableHeader: chalk.hex(BRAND_COLORS.primary)
|
|
46
|
+
};
|
|
47
|
+
({
|
|
48
|
+
success: chalk.green("\u2713"),
|
|
49
|
+
error: chalk.red("\u2717"),
|
|
50
|
+
warning: chalk.yellow("\u26A0"),
|
|
51
|
+
info: theme.brand("\u2139"),
|
|
52
|
+
step: theme.brand("\u203A"),
|
|
53
|
+
bullet: theme.brand("\u2022")
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
export { BRAND_COLORS };
|
|
57
|
+
//# sourceMappingURL=chunk-DMXC2JTC.js.map
|
|
58
|
+
//# sourceMappingURL=chunk-DMXC2JTC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/ui/theme.ts"],"names":["BRAND_COLORS","primary","primaryDark","primaryLight","success","warning","error","info","muted","text","theme","brand","chalk","hex","brandBold","bold","brandDark","gray","dim","white","tableHeader","green","red","yellow","step","bullet"],"mappings":";;;;AAuBO,IAAMA,YAAAA,GAAe;;EAE3BC,OAAAA,EAAS,SAAA;;EAETC,WAAAA,EAAa,SAAA;;EAEbC,YAAAA,EAAc,SAAA;;EAGdC,OAAAA,EAAS,SAAA;EACTC,OAAAA,EAAS,SAAA;EACTC,KAAAA,EAAO,SAAA;EACPC,IAAAA,EAAM,SAAA;;EAGNC,KAAAA,EAAO,SAAA;EACPC,IAAAA,EAAM;AACP;AAmBO,IAAMC,KAAAA,GAAQ;;EAEpBC,KAAAA,EAAOC,KAAAA,CAAMC,GAAAA,CAAIb,YAAAA,CAAaC,OAAO,CAAA;;AAErCa,EAAAA,SAAAA,EAAWF,KAAAA,CAAMC,GAAAA,CAAIb,YAAAA,CAAaC,OAAO,CAAA,CAAEc,IAAAA;;EAE3CC,SAAAA,EAAWJ,KAAAA,CAAMC,GAAAA,CAAIb,YAAAA,CAAaE,WAAW,CAAA;;EAG7CE,OAAAA,EAASQ,KAAAA,CAAMC,GAAAA,CAAIb,YAAAA,CAAaI,OAAO,CAAA;;EAEvCC,OAAAA,EAASO,KAAAA,CAAMC,GAAAA,CAAIb,YAAAA,CAAaK,OAAO,CAAA;;EAEvCC,KAAAA,EAAOM,KAAAA,CAAMC,GAAAA,CAAIb,YAAAA,CAAaM,KAAK,CAAA;;EAEnCC,IAAAA,EAAMK,KAAAA,CAAMC,GAAAA,CAAIb,YAAAA,CAAaO,IAAI,CAAA;;AAGjCC,EAAAA,KAAAA,EAAOI,KAAAA,CAAMK,IAAAA;;AAEbC,EAAAA,GAAAA,EAAKN,KAAAA,CAAMM,GAAAA;;AAEXH,EAAAA,IAAAA,EAAMH,KAAAA,CAAMG,IAAAA;;AAEZI,EAAAA,KAAAA,EAAOP,KAAAA,CAAMO,KAAAA;;EAGbC,WAAAA,EAAaR,KAAAA,CAAMC,GAAAA,CAAIb,YAAAA,CAAaC,OAAO;AAC5C,CAAA;CA0C4B;EAC3BG,OAAAA,EAASQ,KAAAA,CAAMS,MAAM,QAAA,CAAA;EACrBf,KAAAA,EAAOM,KAAAA,CAAMU,IAAI,QAAA,CAAA;EACjBjB,OAAAA,EAASO,KAAAA,CAAMW,OAAO,QAAA,CAAA;EACtBhB,IAAAA,EAAMG,KAAAA,CAAMC,MAAM,QAAA,CAAA;EAClBa,IAAAA,EAAMd,KAAAA,CAAMC,MAAM,QAAA,CAAA;EAClBc,MAAAA,EAAQf,KAAAA,CAAMC,MAAM,QAAA;AACrB","file":"chunk-DMXC2JTC.js","sourcesContent":["/**\n * CLI Theme & Branding Constants\n *\n * Single source of truth for CLI colors, ensuring brand consistency\n * across all terminal output.\n *\n * BRAND COLORS (from brand/colors.json):\n * - Primary: Green (#4ADE80) - Main brand color\n * - Green Dark: #22C55E - Hover states\n * - Green Light: #6EE7A7 - Highlights\n *\n * IMPORTANT: Blue/cyan are NOT Vreko brand colors.\n * The 🦎 emoji is blue due to Unicode limitations, not brand choice.\n *\n * @module ui/theme\n */\n\nimport chalk from \"chalk\";\n\n// =============================================================================\n// BRAND COLORS (Hex values from brand/colors.json)\n// =============================================================================\n\nexport const BRAND_COLORS = {\n\t/** Primary brand green - main color for headers, highlights */\n\tprimary: \"#4ADE80\",\n\t/** Darker green for secondary elements */\n\tprimaryDark: \"#22C55E\",\n\t/** Light green for subtle highlights */\n\tprimaryLight: \"#6EE7A7\",\n\n\t/** Semantic colors */\n\tsuccess: \"#34D399\",\n\twarning: \"#FF6B35\",\n\terror: \"#EF4444\",\n\tinfo: \"#3B82F6\", // Blue is ONLY for semantic info, not branding\n\n\t/** Neutral colors */\n\tmuted: \"#71717A\",\n\ttext: \"#FAFAFA\",\n} as const;\n\n// =============================================================================\n// CHALK THEME - Use these instead of chalk.cyan/blue\n// =============================================================================\n\n/**\n * Brand-consistent chalk colors for CLI output.\n *\n * Use `theme.brand` instead of `chalk.cyan` or `chalk.blue`\n * Use `theme.brandBold` instead of `chalk.cyan.bold` or `chalk.blue.bold`\n *\n * @example\n * // ❌ WRONG - off-brand\n * print(...));\n *\n * // ✅ CORRECT - brand-consistent\n * print(...));\n */\nexport const theme = {\n\t/** Primary brand color - use for headers, highlights, commands */\n\tbrand: chalk.hex(BRAND_COLORS.primary),\n\t/** Primary brand color bold - use for section headers */\n\tbrandBold: chalk.hex(BRAND_COLORS.primary).bold,\n\t/** Darker brand color - use for secondary emphasis */\n\tbrandDark: chalk.hex(BRAND_COLORS.primaryDark),\n\n\t/** Success messages */\n\tsuccess: chalk.hex(BRAND_COLORS.success),\n\t/** Warning messages */\n\twarning: chalk.hex(BRAND_COLORS.warning),\n\t/** Error messages */\n\terror: chalk.hex(BRAND_COLORS.error),\n\t/** Informational (semantic blue - use sparingly) */\n\tinfo: chalk.hex(BRAND_COLORS.info),\n\n\t/** Muted/secondary text */\n\tmuted: chalk.gray,\n\t/** Dimmed text */\n\tdim: chalk.dim,\n\t/** Bold text */\n\tbold: chalk.bold,\n\t/** White text */\n\twhite: chalk.white,\n\n\t/** Table headers - use brand color */\n\ttableHeader: chalk.hex(BRAND_COLORS.primary),\n} as const;\n\n// =============================================================================\n// SEMANTIC HELPERS\n// =============================================================================\n\n/**\n * Format a command for display\n * @example formatCommand(\"vr init\") // \"$ vr init\" in brand green\n */\nexport function formatCommand(command: string): string {\n\treturn theme.brand(`$ ${command}`);\n}\n\n/**\n * Format a section header\n * @example formatSectionHeader(\"Workspace Status\")\n */\nexport function formatSectionHeader(title: string): string {\n\treturn theme.brandBold(title);\n}\n\n/**\n * Format a label-value pair\n * @example formatLabelValue(\"Email\", \"user@example.com\")\n */\nexport function formatLabelValue(label: string, value: string): string {\n\treturn `${theme.brand(`${label}:`)} ${value}`;\n}\n\n/**\n * Format a step indicator\n * @example formatStep(\"1\", \"Connect your account\")\n */\nexport function formatStep(number: string, description: string): string {\n\treturn `${theme.muted(`${number}.`)} ${theme.brand(description)}`;\n}\n\n// =============================================================================\n// STATUS ICONS\n// =============================================================================\n\nexport const STATUS_ICONS = {\n\tsuccess: chalk.green(\"✓\"),\n\terror: chalk.red(\"✗\"),\n\twarning: chalk.yellow(\"⚠\"),\n\tinfo: theme.brand(\"ℹ\"),\n\tstep: theme.brand(\"›\"),\n\tbullet: theme.brand(\"•\"),\n} as const;\n\n// =============================================================================\n// TYPE EXPORTS\n// =============================================================================\n\nexport type ThemeColor = keyof typeof theme;\nexport type BrandColor = keyof typeof BRAND_COLORS;\n"]}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { VrekoLocalClient, isServiceHealthy } from './chunk-GSUGROXB.js';
|
|
3
|
+
import { __name } from './chunk-EWOJGXRX.js';
|
|
4
|
+
|
|
5
|
+
process.env.VREKO_CLI='true';process.env.NODE_NO_WARNINGS='1';
|
|
6
|
+
|
|
7
|
+
// src/ui/degraded-state.ts
|
|
8
|
+
function renderDegradedState(opts) {
|
|
9
|
+
const reason = opts.reason ?? "unreachable";
|
|
10
|
+
const messages = {
|
|
11
|
+
unreachable: "Vreko daemon is not running or not reachable.",
|
|
12
|
+
timeout: "Vreko daemon did not respond in time.",
|
|
13
|
+
"version-mismatch": "Vreko daemon version does not match CLI version.",
|
|
14
|
+
"not-started": "Vreko daemon has not been started."
|
|
15
|
+
};
|
|
16
|
+
const fixes = {
|
|
17
|
+
unreachable: "vr daemon start",
|
|
18
|
+
timeout: "vr daemon restart",
|
|
19
|
+
"version-mismatch": "vr upgrade",
|
|
20
|
+
"not-started": "vr daemon start"
|
|
21
|
+
};
|
|
22
|
+
const lines = [
|
|
23
|
+
`[ERROR] ${messages[reason]}`,
|
|
24
|
+
` Command '${opts.command}' requires the daemon.`,
|
|
25
|
+
` Run: ${fixes[reason]}`,
|
|
26
|
+
" Commands that work offline: vr learn, vr check, vr session status",
|
|
27
|
+
" Diagnostics: vr doctor"
|
|
28
|
+
];
|
|
29
|
+
process.stderr.write(`${lines.join("\n")}
|
|
30
|
+
`);
|
|
31
|
+
}
|
|
32
|
+
__name(renderDegradedState, "renderDegradedState");
|
|
33
|
+
|
|
34
|
+
// src/services/service-client.ts
|
|
35
|
+
var version = "0.0.0";
|
|
36
|
+
{
|
|
37
|
+
version = "3.0.1";
|
|
38
|
+
}
|
|
39
|
+
var client = null;
|
|
40
|
+
var connectionPromise = null;
|
|
41
|
+
function getDaemonClient(options = {}) {
|
|
42
|
+
if (!client) {
|
|
43
|
+
client = new VrekoLocalClient({
|
|
44
|
+
socketPath: options.socketPath,
|
|
45
|
+
// DAEMON-06: No timeout forwarded. IpcConnection hardcodes its own 5s connect
|
|
46
|
+
// timeout (client.ts:140). Per-request RPC timeout defaults to 30s from
|
|
47
|
+
// VrekoLocalClient constructor - unverified against large-repo cold-start
|
|
48
|
+
// (workspace/analyze on next.js/shadcn). If hero-capture runs hit this ceiling,
|
|
49
|
+
// VrekoLocalClient.call() needs a per-request timeout override.
|
|
50
|
+
autoReconnect: options.autoReconnect ?? true
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
return client;
|
|
54
|
+
}
|
|
55
|
+
__name(getDaemonClient, "getDaemonClient");
|
|
56
|
+
async function connectToDaemon(options = {}) {
|
|
57
|
+
const daemonClient = getDaemonClient(options);
|
|
58
|
+
if (connectionPromise) {
|
|
59
|
+
await connectionPromise;
|
|
60
|
+
return daemonClient;
|
|
61
|
+
}
|
|
62
|
+
if (daemonClient.isConnected()) {
|
|
63
|
+
return daemonClient;
|
|
64
|
+
}
|
|
65
|
+
connectionPromise = (async () => {
|
|
66
|
+
await daemonClient.connect();
|
|
67
|
+
await daemonClient.initialize({
|
|
68
|
+
protocolVersion: "1.0.0",
|
|
69
|
+
clientInfo: {
|
|
70
|
+
name: "@vreko/cli",
|
|
71
|
+
version
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
})();
|
|
75
|
+
try {
|
|
76
|
+
await connectionPromise;
|
|
77
|
+
} finally {
|
|
78
|
+
connectionPromise = null;
|
|
79
|
+
}
|
|
80
|
+
return daemonClient;
|
|
81
|
+
}
|
|
82
|
+
__name(connectToDaemon, "connectToDaemon");
|
|
83
|
+
function isDaemonConnected() {
|
|
84
|
+
return client?.isConnected() ?? false;
|
|
85
|
+
}
|
|
86
|
+
__name(isDaemonConnected, "isDaemonConnected");
|
|
87
|
+
async function isDaemonAvailable() {
|
|
88
|
+
try {
|
|
89
|
+
await connectToDaemon();
|
|
90
|
+
return true;
|
|
91
|
+
} catch {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
__name(isDaemonAvailable, "isDaemonAvailable");
|
|
96
|
+
async function getDaemonStatus() {
|
|
97
|
+
if (!isDaemonConnected()) {
|
|
98
|
+
return {
|
|
99
|
+
connected: false
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
try {
|
|
103
|
+
const daemonClient = getDaemonClient();
|
|
104
|
+
const health = await daemonClient.health.check();
|
|
105
|
+
return {
|
|
106
|
+
connected: true,
|
|
107
|
+
version: health.version,
|
|
108
|
+
uptime: health.uptime
|
|
109
|
+
};
|
|
110
|
+
} catch {
|
|
111
|
+
return {
|
|
112
|
+
connected: false
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
__name(getDaemonStatus, "getDaemonStatus");
|
|
117
|
+
function disconnectFromDaemon() {
|
|
118
|
+
if (client) {
|
|
119
|
+
client.close();
|
|
120
|
+
client = null;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
__name(disconnectFromDaemon, "disconnectFromDaemon");
|
|
124
|
+
async function withDaemon(command, fn, opts) {
|
|
125
|
+
const healthy = await isServiceHealthy();
|
|
126
|
+
if (!healthy) {
|
|
127
|
+
renderDegradedState({
|
|
128
|
+
command,
|
|
129
|
+
reason: opts?.reason ?? "unreachable"
|
|
130
|
+
});
|
|
131
|
+
process.exit(1);
|
|
132
|
+
}
|
|
133
|
+
let client2 = null;
|
|
134
|
+
try {
|
|
135
|
+
client2 = await connectToDaemon();
|
|
136
|
+
await client2.health.check();
|
|
137
|
+
} catch {
|
|
138
|
+
renderDegradedState({
|
|
139
|
+
command,
|
|
140
|
+
reason: opts?.reason ?? "unreachable"
|
|
141
|
+
});
|
|
142
|
+
process.exit(1);
|
|
143
|
+
}
|
|
144
|
+
return fn(client2);
|
|
145
|
+
}
|
|
146
|
+
__name(withDaemon, "withDaemon");
|
|
147
|
+
async function withDaemonOptional(command, fn) {
|
|
148
|
+
let client2 = null;
|
|
149
|
+
try {
|
|
150
|
+
client2 = await connectToDaemon();
|
|
151
|
+
await client2.health.check();
|
|
152
|
+
} catch (_error) {
|
|
153
|
+
client2 = null;
|
|
154
|
+
}
|
|
155
|
+
return fn(client2);
|
|
156
|
+
}
|
|
157
|
+
__name(withDaemonOptional, "withDaemonOptional");
|
|
158
|
+
|
|
159
|
+
export { connectToDaemon, disconnectFromDaemon, getDaemonClient, getDaemonStatus, isDaemonAvailable, isDaemonConnected, withDaemon, withDaemonOptional };
|
|
160
|
+
//# sourceMappingURL=chunk-EEBSK2IH.js.map
|
|
161
|
+
//# sourceMappingURL=chunk-EEBSK2IH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/ui/degraded-state.ts","../src/services/service-client.ts"],"names":["renderDegradedState","opts","reason","messages","unreachable","timeout","fixes","lines","command","process","stderr","write","join","version","__CLI_VERSION__","client","connectionPromise","getDaemonClient","options","VrekoLocalClient","socketPath","autoReconnect","connectToDaemon","daemonClient","isConnected","connect","initialize","protocolVersion","clientInfo","name","isDaemonConnected","isDaemonAvailable","getDaemonStatus","connected","health","check","uptime","disconnectFromDaemon","close","withDaemon","fn","healthy","isServiceHealthy","exit","withDaemonOptional","_error"],"mappings":";;;;;;;AAuBO,SAASA,oBAAoBC,IAAAA,EAA0B;AAC7D,EAAA,M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CAAA,MAAQ;AACPnC,IAAAA,mBAAAA,CAAoB;AAAEQ,MAAAA,OAAAA;AAASN,MAAAA,MAAAA,EAAQD,MAAMC,MAAAA,IAAU;KAAc,CAAA;AACrEO,IAAAA,OAAAA,CAAQkC,KAAK,CAAA,CAAA;AACd,EAAA;AAEA,EAAA,OAAOH,GAAGzB,OAAAA,CAAAA;AACX;AAxBsBwB,MAAAA,CAAAA,UAAAA,EAAAA,YAAAA,CAAAA;AAyCtB,eAAsBK,kBAAAA,CACrBpC,SACAgC,EAAAA,EAAmD;AAEnD,EAAA,IAAIzB,OAAAA,GAAkC,IAAA;AAEtC,EAAA,IAAI;AACHA,IAAAA,OAAAA,GAAS,MAAMO,eAAAA,EAAAA;AACf,IAAA,MAAMP,OAAAA,CAAOmB,OAAOC,KAAAA,EAAK;AAC1B,EAAA,CAAA,CAAA,OAASU,MAAAA,EAAQ;AAEhB9B,IAAAA,OAAAA,GAAS,IAAA;AACV,EAAA;AAEA,EAAA,OAAOyB,GAAGzB,OAAAA,CAAAA;AACX;AAfsB6B,MAAAA,CAAAA,kBAAAA,EAAAA,oBAAAA,CAAAA","file":"chunk-EEBSK2IH.js","sourcesContent":["/**\n * Degraded State Rendering\n *\n * Single source of truth for daemon-unavailable UX.\n * All commands must use renderDegradedState() when the daemon is unavailable.\n * No command may inline its own daemon-unavailable messaging.\n *\n * @module ui/degraded-state\n */\n\nexport interface DegradedStateOptions {\n\tcommand: string;\n\treason?: \"unreachable\" | \"timeout\" | \"version-mismatch\" | \"not-started\";\n}\n\n/**\n * Render consistent daemon-unavailable error message.\n *\n * This is the ONLY place that renders daemon-unavailable messaging.\n * All future changes to daemon-unavailable UX happen here and propagate automatically.\n *\n * @param opts - Options for rendering the degraded state\n */\nexport function renderDegradedState(opts: DegradedStateOptions): void {\n\tconst reason = opts.reason ?? \"unreachable\";\n\n\tconst messages: Record<typeof reason, string> = {\n\t\tunreachable: \"Vreko daemon is not running or not reachable.\",\n\t\ttimeout: \"Vreko daemon did not respond in time.\",\n\t\t\"version-mismatch\": \"Vreko daemon version does not match CLI version.\",\n\t\t\"not-started\": \"Vreko daemon has not been started.\",\n\t};\n\n\tconst fixes: Record<typeof reason, string> = {\n\t\tunreachable: \"vr daemon start\",\n\t\ttimeout: \"vr daemon restart\",\n\t\t\"version-mismatch\": \"vr upgrade\",\n\t\t\"not-started\": \"vr daemon start\",\n\t};\n\n\t// Four-part degraded-state message per industry standard (Docker, GitHub CLI, WCAG):\n\t// 1. What is unavailable (text severity prefix, no color dependence)\n\t// 2. What is affected (the specific command that failed)\n\t// 3. What to do (primary recovery action)\n\t// 4. What still works (offline fallback)\n\tconst lines = [\n\t\t`[ERROR] ${messages[reason]}`,\n\t\t` Command '${opts.command}' requires the daemon.`,\n\t\t` Run: ${fixes[reason]}`,\n\t\t\" Commands that work offline: vr learn, vr check, vr session status\",\n\t\t\" Diagnostics: vr doctor\",\n\t];\n\n\tprocess.stderr.write(`${lines.join(\"\\n\")}\\n`);\n}\n","/**\n * Daemon Client Service\n *\n * Manages connection to the Vreko local service daemon (vrekod).\n * All intelligence operations are proxied through the daemon for IP protection.\n *\n * ## Architecture\n *\n * ```\n * CLI Commands\n * ↓\n * DaemonClientService (this file)\n * ↓\n * @vreko/local-service-client (IPC client)\n * ↓\n * vrekod daemon (Unix socket / named pipe)\n * ↓\n * @vreko/intelligence (runs in daemon process)\n * ```\n *\n * ## IP Protection\n *\n * - CLI has NO direct imports of @vreko/intelligence\n * - All intelligence code runs in the daemon process\n * - CLI only has types from @vreko/contracts and local-service-client\n *\n * ## Canonical Daemon Connection Patterns\n *\n * **For commands that require the daemon:**\n * - Use `withDaemon(command, fn)` - exits with code 1 on failure\n * - Always calls `renderDegradedState()` for consistent error messaging\n * - No inline daemon-unavailable messaging allowed\n *\n * **For commands with graceful degraded mode:**\n * - Use `withDaemonOptional(command, fn)` - does not exit on failure\n * - Callback receives `client | null` to handle degraded state\n * - Surfaces clear \"limited mode\" indicator to user\n *\n * **Do NOT use:**\n * - `requireDaemon()` - deprecated, replaced by withDaemon/withDaemonOptional\n * - Inline error handling for daemon unavailability\n *\n * @module services/service-client\n */\n\n// Version is inlined at build time by tsup's define option\n// This avoids runtime package.json resolution issues in bundled output\ndeclare const __CLI_VERSION__: string | undefined;\n\nimport { VrekoLocalClient } from \"@vreko/local-service-client\";\nimport { isServiceHealthy } from \"../service-adapter/local-service-adapter.js\";\nimport { type DegradedStateOptions, renderDegradedState } from \"../ui/degraded-state.js\";\n\n// Use build-time version if available, otherwise fall back to package.json\n// This supports both production builds (tsup defines __CLI_VERSION__) and dev (tsx)\nlet version = \"0.0.0\";\nif (typeof __CLI_VERSION__ !== \"undefined\") {\n\tversion = __CLI_VERSION__;\n} else {\n\ttry {\n\t\t// Dynamic import for dev mode - works with tsx\n\t\t// eslint-disable-next-line @typescript-eslint/no-require-imports\n\t\tconst pkg = require(\"../../package.json\") as { version: string };\n\t\tversion = pkg.version ?? \"0.0.0\";\n\t} catch {\n\t\t// Fallback if package.json can't be loaded\n\t\tversion = \"0.0.0-dev\";\n\t}\n}\n\n// =============================================================================\n// TYPES\n// =============================================================================\n\nexport interface DaemonStatus {\n\tconnected: boolean;\n\tversion?: string;\n\tuptime?: number;\n}\n\nexport interface DaemonClientOptions {\n\t/** Socket path for IPC (default: OS-specific) */\n\tsocketPath?: string;\n\t/** Auto-reconnect on disconnect */\n\tautoReconnect?: boolean;\n\t/**\n\t * Connection probe timeout hint (ms). Accepted but not forwarded to\n\t * VrekoLocalClient - per DAEMON-06, the 5s probe hint must not become\n\t * the per-request RPC timeout. Reserved for a future probe mechanism.\n\t */\n\ttimeout?: number;\n}\n\n// =============================================================================\n// SINGLETON CLIENT\n// =============================================================================\n\nlet client: VrekoLocalClient | null = null;\nlet connectionPromise: Promise<void> | null = null;\n\n/**\n * Get or create the daemon client\n *\n * @param options - Client options\n * @returns The daemon client instance\n */\nexport function getDaemonClient(options: DaemonClientOptions = {}): VrekoLocalClient {\n\tif (!client) {\n\t\tclient = new VrekoLocalClient({\n\t\t\tsocketPath: options.socketPath,\n\t\t\t// DAEMON-06: No timeout forwarded. IpcConnection hardcodes its own 5s connect\n\t\t\t// timeout (client.ts:140). Per-request RPC timeout defaults to 30s from\n\t\t\t// VrekoLocalClient constructor - unverified against large-repo cold-start\n\t\t\t// (workspace/analyze on next.js/shadcn). If hero-capture runs hit this ceiling,\n\t\t\t// VrekoLocalClient.call() needs a per-request timeout override.\n\t\t\tautoReconnect: options.autoReconnect ?? true,\n\t\t});\n\t}\n\treturn client;\n}\n\n/**\n * Connect to the daemon\n *\n * @param options - Connection options\n * @throws If connection fails\n */\nexport async function connectToDaemon(options: DaemonClientOptions = {}): Promise<VrekoLocalClient> {\n\tconst daemonClient = getDaemonClient(options);\n\n\t// Avoid duplicate connection attempts\n\tif (connectionPromise) {\n\t\tawait connectionPromise;\n\t\treturn daemonClient;\n\t}\n\n\tif (daemonClient.isConnected()) {\n\t\treturn daemonClient;\n\t}\n\n\tconnectionPromise = (async () => {\n\t\tawait daemonClient.connect();\n\n\t\t// Initialize protocol\n\t\tawait daemonClient.initialize({\n\t\t\tprotocolVersion: \"1.0.0\",\n\t\t\tclientInfo: {\n\t\t\t\tname: \"@vreko/cli\",\n\t\t\t\tversion,\n\t\t\t},\n\t\t});\n\t})();\n\n\ttry {\n\t\tawait connectionPromise;\n\t} finally {\n\t\tconnectionPromise = null;\n\t}\n\n\treturn daemonClient;\n}\n\n/**\n * Check if daemon is connected\n */\nexport function isDaemonConnected(): boolean {\n\treturn client?.isConnected() ?? false;\n}\n\n/**\n * Check if daemon is available (try to connect)\n *\n * @returns true if daemon is running and accessible\n */\nexport async function isDaemonAvailable(): Promise<boolean> {\n\ttry {\n\t\tawait connectToDaemon();\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/**\n * Get daemon status\n */\nexport async function getDaemonStatus(): Promise<DaemonStatus> {\n\tif (!isDaemonConnected()) {\n\t\treturn { connected: false };\n\t}\n\n\ttry {\n\t\tconst daemonClient = getDaemonClient();\n\t\tconst health = await daemonClient.health.check();\n\t\treturn {\n\t\t\tconnected: true,\n\t\t\tversion: health.version,\n\t\t\tuptime: health.uptime,\n\t\t};\n\t} catch {\n\t\treturn { connected: false };\n\t}\n}\n\n/**\n * Disconnect from the daemon\n */\nexport function disconnectFromDaemon(): void {\n\tif (client) {\n\t\tclient.close();\n\t\tclient = null;\n\t}\n}\n\n/**\n * Canonical wrapper for commands that require daemon connectivity.\n *\n * Rules:\n * - withDaemon() always calls renderDegradedState() on failure - never logs inline\n * - withDaemon() always exits with code 1 on failure - no silent degradation\n * - withDaemon() accepts the command name string for telemetry attribution\n *\n * @param command - Command name for telemetry attribution\n * @param fn - Function to execute with daemon client\n * @param opts - Optional degradation reason\n * @returns Result from fn, or never exits on failure\n */\nexport async function withDaemon<T>(\n\tcommand: string,\n\tfn: (client: VrekoLocalClient) => Promise<T>,\n\topts?: { reason?: DegradedStateOptions[\"reason\"] },\n): Promise<T | never> {\n\t// DAEMON-03: pre-flight socket probe - catches zombie daemon (PID alive, socket dead).\n\t// isServiceHealthy() is async; the missing-await form would be silently truthy (Pitfall 4).\n\tconst healthy = await isServiceHealthy();\n\tif (!healthy) {\n\t\trenderDegradedState({ command, reason: opts?.reason ?? \"unreachable\" });\n\t\tprocess.exit(1);\n\t}\n\n\tlet client: VrekoLocalClient | null = null;\n\n\ttry {\n\t\tclient = await connectToDaemon();\n\t\tawait client.health.check();\n\t} catch {\n\t\trenderDegradedState({ command, reason: opts?.reason ?? \"unreachable\" });\n\t\tprocess.exit(1);\n\t}\n\n\treturn fn(client);\n}\n\n/**\n * Canonical wrapper for commands with graceful offline mode.\n *\n * Some commands can show partial data without the daemon. These use a different\n * wrapper that does not exit on failure but surfaces a clear \"limited mode\" indicator.\n *\n * Rules:\n * - withDaemonOptional() does not exit on failure\n * - withDaemonOptional() surfaces a clear \"limited mode\" indicator\n * - withDaemonOptional() accepts client | null in the callback function\n *\n * @param command - Command name for telemetry attribution\n * @param fn - Function to execute with daemon client (may receive null)\n * @returns Result from fn\n */\nexport async function withDaemonOptional<T>(\n\tcommand: string,\n\tfn: (client: VrekoLocalClient | null) => Promise<T>,\n): Promise<T> {\n\tlet client: VrekoLocalClient | null = null;\n\n\ttry {\n\t\tclient = await connectToDaemon();\n\t\tawait client.health.check();\n\t} catch (_error) {\n\t\tvoid _error;\n\t\tclient = null;\n\t}\n\n\treturn fn(client);\n}\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
process.env.VREKO_CLI='true';process.env.NODE_NO_WARNINGS='1';
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
7
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
8
|
+
}) : x)(function(x) {
|
|
9
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
10
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
11
|
+
});
|
|
12
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
13
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
14
|
+
};
|
|
15
|
+
var __export = (target, all) => {
|
|
16
|
+
for (var name in all)
|
|
17
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { __commonJS, __export, __name, __require };
|
|
21
|
+
//# sourceMappingURL=chunk-EWOJGXRX.js.map
|
|
22
|
+
//# sourceMappingURL=chunk-EWOJGXRX.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-EWOJGXRX.js"}
|