chief-helm 0.1.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.
Files changed (90) hide show
  1. package/Readme.md +220 -0
  2. package/dist/commands/config.d.ts +26 -0
  3. package/dist/commands/config.d.ts.map +1 -0
  4. package/dist/commands/config.js +111 -0
  5. package/dist/commands/config.js.map +1 -0
  6. package/dist/commands/inputs.d.ts +21 -0
  7. package/dist/commands/inputs.d.ts.map +1 -0
  8. package/dist/commands/inputs.js +158 -0
  9. package/dist/commands/inputs.js.map +1 -0
  10. package/dist/commands/push.d.ts +21 -0
  11. package/dist/commands/push.d.ts.map +1 -0
  12. package/dist/commands/push.js +51 -0
  13. package/dist/commands/push.js.map +1 -0
  14. package/dist/commands/secrets.d.ts +21 -0
  15. package/dist/commands/secrets.d.ts.map +1 -0
  16. package/dist/commands/secrets.js +110 -0
  17. package/dist/commands/secrets.js.map +1 -0
  18. package/dist/commands/setup.d.ts +24 -0
  19. package/dist/commands/setup.d.ts.map +1 -0
  20. package/dist/commands/setup.js +421 -0
  21. package/dist/commands/setup.js.map +1 -0
  22. package/dist/commands/status.d.ts +20 -0
  23. package/dist/commands/status.d.ts.map +1 -0
  24. package/dist/commands/status.js +184 -0
  25. package/dist/commands/status.js.map +1 -0
  26. package/dist/commands/sync.d.ts +19 -0
  27. package/dist/commands/sync.d.ts.map +1 -0
  28. package/dist/commands/sync.js +47 -0
  29. package/dist/commands/sync.js.map +1 -0
  30. package/dist/core/config.d.ts +74 -0
  31. package/dist/core/config.d.ts.map +1 -0
  32. package/dist/core/config.js +182 -0
  33. package/dist/core/config.js.map +1 -0
  34. package/dist/core/git.d.ts +73 -0
  35. package/dist/core/git.d.ts.map +1 -0
  36. package/dist/core/git.js +188 -0
  37. package/dist/core/git.js.map +1 -0
  38. package/dist/core/inputs.d.ts +40 -0
  39. package/dist/core/inputs.d.ts.map +1 -0
  40. package/dist/core/inputs.js +360 -0
  41. package/dist/core/inputs.js.map +1 -0
  42. package/dist/core/repo.d.ts +71 -0
  43. package/dist/core/repo.d.ts.map +1 -0
  44. package/dist/core/repo.js +152 -0
  45. package/dist/core/repo.js.map +1 -0
  46. package/dist/core/secrets.d.ts +79 -0
  47. package/dist/core/secrets.d.ts.map +1 -0
  48. package/dist/core/secrets.js +168 -0
  49. package/dist/core/secrets.js.map +1 -0
  50. package/dist/core/state.d.ts +46 -0
  51. package/dist/core/state.d.ts.map +1 -0
  52. package/dist/core/state.js +119 -0
  53. package/dist/core/state.js.map +1 -0
  54. package/dist/index.d.ts +19 -0
  55. package/dist/index.d.ts.map +1 -0
  56. package/dist/index.js +163 -0
  57. package/dist/index.js.map +1 -0
  58. package/dist/types/index.d.ts +210 -0
  59. package/dist/types/index.d.ts.map +1 -0
  60. package/dist/types/index.js +10 -0
  61. package/dist/types/index.js.map +1 -0
  62. package/dist/ui/components/Header.d.ts +32 -0
  63. package/dist/ui/components/Header.d.ts.map +1 -0
  64. package/dist/ui/components/Header.js +15 -0
  65. package/dist/ui/components/Header.js.map +1 -0
  66. package/dist/ui/components/Panel.d.ts +30 -0
  67. package/dist/ui/components/Panel.d.ts.map +1 -0
  68. package/dist/ui/components/Panel.js +15 -0
  69. package/dist/ui/components/Panel.js.map +1 -0
  70. package/dist/ui/components/StatusRow.d.ts +39 -0
  71. package/dist/ui/components/StatusRow.d.ts.map +1 -0
  72. package/dist/ui/components/StatusRow.js +27 -0
  73. package/dist/ui/components/StatusRow.js.map +1 -0
  74. package/dist/ui/theme.d.ts +60 -0
  75. package/dist/ui/theme.d.ts.map +1 -0
  76. package/dist/ui/theme.js +60 -0
  77. package/dist/ui/theme.js.map +1 -0
  78. package/dist/utils/errors.d.ts +50 -0
  79. package/dist/utils/errors.d.ts.map +1 -0
  80. package/dist/utils/errors.js +63 -0
  81. package/dist/utils/errors.js.map +1 -0
  82. package/dist/utils/format.d.ts +66 -0
  83. package/dist/utils/format.d.ts.map +1 -0
  84. package/dist/utils/format.js +107 -0
  85. package/dist/utils/format.js.map +1 -0
  86. package/dist/utils/logger.d.ts +35 -0
  87. package/dist/utils/logger.d.ts.map +1 -0
  88. package/dist/utils/logger.js +71 -0
  89. package/dist/utils/logger.js.map +1 -0
  90. package/package.json +53 -0
@@ -0,0 +1,184 @@
1
+ /**
2
+ * @file helm status — system health overview panel.
3
+ *
4
+ * Renders a static bordered status panel in the CHIEF visual design
5
+ * showing: repo path and git cleanliness, all configured inputs with
6
+ * connection state, last run timestamps per flow, and engine availability.
7
+ *
8
+ * This command is read-only — it makes no writes and issues no git
9
+ * operations. Input "connection state" is derived from the `configured`
10
+ * flag in inputs.yaml (set by helm setup and helm inputs test) rather
11
+ * than making live API calls on every status invocation.
12
+ */
13
+ import chalk from "chalk";
14
+ import { execa } from "execa";
15
+ import { requireSetup, getLocalConfig } from "../core/repo.js";
16
+ import { readInputsConfig, readFlowsConfig, readEngineConfig } from "../core/config.js";
17
+ import { getRepoStatus } from "../core/git.js";
18
+ import { readLastRunState } from "../core/state.js";
19
+ import { theme, symbol } from "../ui/theme.js";
20
+ import { boxTop, boxDivider, boxBottom, boxRow, formatHeaderDate, formatLastRun, padEnd, } from "../utils/format.js";
21
+ // ─── Engine Check ─────────────────────────────────────────────────────────────
22
+ /**
23
+ * Returns true if the engine CLI command is available in PATH.
24
+ * Uses the command from engine.yaml, defaulting to "claude".
25
+ *
26
+ * @param command - The CLI command to check (e.g. "claude").
27
+ */
28
+ async function isEngineAvailable(command) {
29
+ try {
30
+ await execa(command, ["--version"], { reject: true });
31
+ return true;
32
+ }
33
+ catch {
34
+ return false;
35
+ }
36
+ }
37
+ // ─── Row Builders ─────────────────────────────────────────────────────────────
38
+ /**
39
+ * Builds the header row content string for the top section.
40
+ * Format: CHIEF · STATUS · [username] · [date]
41
+ */
42
+ function buildHeaderContent(username) {
43
+ const dateStr = formatHeaderDate(new Date());
44
+ const sep = chalk.hex(theme.border)(" · ");
45
+ return [
46
+ chalk.hex(theme.text).bold("CHIEF"),
47
+ sep,
48
+ chalk.hex(theme.accent).bold("STATUS"),
49
+ sep,
50
+ chalk.hex(theme.muted)(username),
51
+ sep,
52
+ chalk.hex(theme.muted)(dateStr),
53
+ ].join("");
54
+ }
55
+ /**
56
+ * Builds the repo section row content.
57
+ * Shows the repo path and clean/dirty state.
58
+ */
59
+ function buildRepoContent(repoRoot, status) {
60
+ const label = padEnd(chalk.hex(theme.text)("REPO"), 12);
61
+ const pathStr = chalk.hex(theme.muted)(repoRoot);
62
+ const statusStr = status.clean
63
+ ? chalk.hex(theme.success)(`${symbol.success} clean`)
64
+ : chalk.hex(theme.warning)(`${symbol.warning} dirty (${status.fileCount} file${status.fileCount !== 1 ? "s" : ""})`);
65
+ return `${label}${pathStr} ${statusStr}`;
66
+ }
67
+ /**
68
+ * Builds one input row for the INPUTS section.
69
+ * Connected: ✓ green. Disabled: ○ gray. Configured-but-untested: ⚠ yellow.
70
+ */
71
+ function buildInputRow(input) {
72
+ const labelStr = padEnd(input.label, 22);
73
+ if (!input.enabled) {
74
+ return (chalk.hex(theme.skip)(symbol.disabled) +
75
+ " " +
76
+ chalk.hex(theme.skip)(labelStr) +
77
+ chalk.hex(theme.skip)("disabled"));
78
+ }
79
+ if (input.configured) {
80
+ return (chalk.hex(theme.success)(symbol.success) +
81
+ " " +
82
+ chalk.hex(theme.text)(labelStr) +
83
+ chalk.hex(theme.success)("connected"));
84
+ }
85
+ return (chalk.hex(theme.warning)(symbol.warning) +
86
+ " " +
87
+ chalk.hex(theme.text)(labelStr) +
88
+ chalk.hex(theme.warning)("not configured"));
89
+ }
90
+ /**
91
+ * Builds one last-run row for the LAST RUNS section.
92
+ */
93
+ function buildLastRunRow(flowId, flowLabel, record) {
94
+ const labelStr = padEnd(flowLabel, 22);
95
+ const timeStr = formatLastRun(record?.timestamp);
96
+ const statusStr = record
97
+ ? record.status === "success"
98
+ ? chalk.hex(theme.success)(`${symbol.success} success`)
99
+ : chalk.hex(theme.error)(`${symbol.error} failed`)
100
+ : chalk.hex(theme.muted)("—");
101
+ return (chalk.hex(theme.text)(labelStr) +
102
+ chalk.hex(theme.muted)(padEnd(timeStr, 18)) +
103
+ " " +
104
+ statusStr);
105
+ }
106
+ /**
107
+ * Builds the engine status row.
108
+ */
109
+ function buildEngineRow(engineLabel, available) {
110
+ const label = padEnd(chalk.hex(theme.text)("ENGINE"), 12);
111
+ const nameStr = chalk.hex(theme.muted)(padEnd(engineLabel, 20));
112
+ const statusStr = available
113
+ ? chalk.hex(theme.success)(`${symbol.success} available`)
114
+ : chalk.hex(theme.error)(`${symbol.error} not found`);
115
+ return `${label}${nameStr}${statusStr}`;
116
+ }
117
+ // ─── Panel Renderer ───────────────────────────────────────────────────────────
118
+ /**
119
+ * Assembles and prints the full CHIEF status panel to stdout.
120
+ * All data is fetched before this function is called so rendering
121
+ * is synchronous and non-interactive.
122
+ */
123
+ function renderStatusPanel(data) {
124
+ const lines = [
125
+ boxTop(),
126
+ boxRow(buildHeaderContent(data.username)),
127
+ boxDivider(),
128
+ boxRow(buildRepoContent(data.repoRoot, data.repoStatus)),
129
+ boxDivider(),
130
+ boxRow(chalk.hex(theme.text).bold("INPUTS")),
131
+ ...data.inputs.map((inp) => boxRow(buildInputRow(inp))),
132
+ boxDivider(),
133
+ boxRow(chalk.hex(theme.text).bold("LAST RUNS")),
134
+ ...data.flows.map((flow) => boxRow(buildLastRunRow(flow.id, flow.label, data.lastRunState[flow.id]))),
135
+ boxDivider(),
136
+ boxRow(buildEngineRow(data.engineLabel, data.engineAvailable)),
137
+ boxBottom(),
138
+ ];
139
+ console.log("\n" + lines.join("\n") + "\n");
140
+ }
141
+ // ─── Command Registration ─────────────────────────────────────────────────────
142
+ /**
143
+ * Registers the `helm status` command on the given Commander program.
144
+ *
145
+ * @param program - The root Commander Command instance.
146
+ */
147
+ export function registerStatusCommand(program) {
148
+ program
149
+ .command("status")
150
+ .description("Show system health overview")
151
+ .action(async () => {
152
+ requireSetup();
153
+ const config = getLocalConfig();
154
+ const repoRoot = config.instance_repo_path;
155
+ const username = config.active_user;
156
+ const [repoStatus, inputs, flows, lastRunState, engineConfig] = await Promise.all([
157
+ getRepoStatus(repoRoot),
158
+ Promise.resolve(readInputsConfig(repoRoot)),
159
+ Promise.resolve(readFlowsConfig(repoRoot)),
160
+ Promise.resolve(readLastRunState(repoRoot, username)),
161
+ Promise.resolve(readEngineConfig(repoRoot)),
162
+ ]);
163
+ const engineLabel = engineConfig.engine === "claude-code"
164
+ ? "Claude Code CLI"
165
+ : "Anthropic API";
166
+ const engineAvailable = await isEngineAvailable(engineConfig.command);
167
+ const lastRunMap = {};
168
+ for (const flow of flows) {
169
+ const record = lastRunState[flow.id];
170
+ lastRunMap[flow.id] = record;
171
+ }
172
+ renderStatusPanel({
173
+ username,
174
+ repoRoot,
175
+ repoStatus,
176
+ inputs,
177
+ flows,
178
+ lastRunState: lastRunMap,
179
+ engineLabel,
180
+ engineAvailable,
181
+ });
182
+ });
183
+ }
184
+ //# sourceMappingURL=status.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.js","sourceRoot":"","sources":["../../src/commands/status.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAE9B,OAAO,EAAE,YAAY,EAAE,cAAc,EAAY,MAAM,iBAAiB,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACxF,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EACL,MAAM,EACN,UAAU,EACV,SAAS,EACT,MAAM,EAEN,gBAAgB,EAChB,aAAa,EACb,MAAM,GACP,MAAM,oBAAoB,CAAC;AAE5B,iFAAiF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EtB,MAAM,eAAe,GAAG,MAAM,iBAAiB,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAEtE,MAAM,UAAU,GAGZ,EAAE,CAAC;QACP,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACrC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC;QAC/B,CAAC;QAED,iBAAiB,CAAC;YAChB,QAAQ;YACR,QAAQ;YACR,UAAU;YACV,MAAM;YACN,KAAK;YACL,YAAY,EAAE,UAAU;YACxB,WAAW;YACX,eAAe;SAChB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @file helm sync — pull latest changes from the instance repo remote.
3
+ *
4
+ * Performs `git pull` on the personal instance repo, updates the
5
+ * last_sync timestamp in local config, and displays the current
6
+ * repo status (clean or dirty with file count).
7
+ *
8
+ * This command is the mandatory first step before any flow run.
9
+ * Running it manually confirms the local copy is up to date with
10
+ * any changes made in other environments or by Railway automation.
11
+ */
12
+ import type { Command } from "commander";
13
+ /**
14
+ * Registers the `helm sync` command on the given Commander program.
15
+ *
16
+ * @param program - The root Commander Command instance.
17
+ */
18
+ export declare function registerSyncCommand(program: Command): void;
19
+ //# sourceMappingURL=sync.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../src/commands/sync.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAQzC;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA8C1D"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * @file helm sync — pull latest changes from the instance repo remote.
3
+ *
4
+ * Performs `git pull` on the personal instance repo, updates the
5
+ * last_sync timestamp in local config, and displays the current
6
+ * repo status (clean or dirty with file count).
7
+ *
8
+ * This command is the mandatory first step before any flow run.
9
+ * Running it manually confirms the local copy is up to date with
10
+ * any changes made in other environments or by Railway automation.
11
+ */
12
+ import chalk from "chalk";
13
+ import { requireSetup, getLocalConfig, updateLocalConfig } from "../core/repo.js";
14
+ import { pullLatest, getRepoStatus } from "../core/git.js";
15
+ import { theme, symbol } from "../ui/theme.js";
16
+ import { formatHeaderDate } from "../utils/format.js";
17
+ // ─── Command Registration ─────────────────────────────────────────────────────
18
+ /**
19
+ * Registers the `helm sync` command on the given Commander program.
20
+ *
21
+ * @param program - The root Commander Command instance.
22
+ */
23
+ export function registerSyncCommand(program) {
24
+ program
25
+ .command("sync")
26
+ .description("Pull latest from origin and show repo status")
27
+ .action(async () => {
28
+ requireSetup();
29
+ const { instance_repo_path: repoRoot, active_user: username } = getLocalConfig();
30
+ process.stdout.write(chalk.hex(theme.muted)(" Pulling from origin… "));
31
+ await pullLatest(repoRoot);
32
+ const now = new Date();
33
+ updateLocalConfig({ last_sync: now.toISOString() });
34
+ const status = await getRepoStatus(repoRoot);
35
+ process.stdout.write("\n");
36
+ const statusStr = status.clean
37
+ ? chalk.hex(theme.success)(`${symbol.success} clean`)
38
+ : chalk.hex(theme.warning)(`${symbol.warning} dirty — ${status.fileCount} file${status.fileCount !== 1 ? "s" : ""} modified`);
39
+ console.log(` ${chalk.hex(theme.success)(symbol.success)} Synced ${chalk.hex(theme.muted)(formatHeaderDate(now))}`);
40
+ console.log(` ${chalk.hex(theme.muted)(symbol.bullet)} Repo status: ${statusStr}`);
41
+ if (!status.clean) {
42
+ console.log(chalk.hex(theme.muted)(`\n Uncommitted changes are present.\n Run: helm push to commit and push them.`));
43
+ }
44
+ console.log();
45
+ });
46
+ }
47
+ //# sourceMappingURL=sync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync.js","sourceRoot":"","sources":["../../src/commands/sync.ts"],"names":[],"mappings":"AAAA;;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AK,CAAC,OAAO,CAAC,CACtB,GAAG,MAAM,CAAC,OAAO,YAAY,MAAM,CAAC,SAAS,QAAQ,MAAM,CAAC,SAAS,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,WAAW,CAClG,CAAC;QAEN,OAAO,CAAC,GAAG,CACT,KAAK,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,aAAa,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,EAAE,CAC1G,CAAC;QACF,OAAO,CAAC,GAAG,CACT,KAAK,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,kBAAkB,SAAS,EAAE,CACxE,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YAClB,OAAO,CAAC,GAAG,CACT,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CACpB,kFAAkF,CACnF,CACF,CAAC;QACJ,CAAC;QAED,OAAO,CAAC,GAAG,EAAE,CAAC;IAChB,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * @file Instance repo YAML config file I/O.
3
+ *
4
+ * Provides typed read and write functions for every config file that
5
+ * HELM manages in the personal instance repo under /config/. All
6
+ * functions fail fast with a descriptive HelmError when a file is
7
+ * missing, unreadable, or does not contain the expected top-level type.
8
+ *
9
+ * Write functions serialise with consistent YAML formatting so diffs
10
+ * remain readable when the user views their git history.
11
+ */
12
+ import type { Input, Agent, Flow, Trigger, SystemConfig, EngineConfig } from "../types/index.js";
13
+ /**
14
+ * Reads and returns all Input entries from config/inputs.yaml.
15
+ *
16
+ * @param repoRoot - Absolute path to the instance repo root.
17
+ */
18
+ export declare function readInputsConfig(repoRoot: string): Input[];
19
+ /**
20
+ * Writes the given Input array to config/inputs.yaml, replacing
21
+ * the current file contents.
22
+ *
23
+ * @param repoRoot - Absolute path to the instance repo root.
24
+ * @param inputs - Full array of Input entries to persist.
25
+ */
26
+ export declare function writeInputsConfig(repoRoot: string, inputs: Input[]): void;
27
+ /**
28
+ * Reads and returns all Agent entries from config/agents.yaml.
29
+ *
30
+ * @param repoRoot - Absolute path to the instance repo root.
31
+ */
32
+ export declare function readAgentsConfig(repoRoot: string): Agent[];
33
+ /**
34
+ * Writes the given Agent array to config/agents.yaml.
35
+ *
36
+ * @param repoRoot - Absolute path to the instance repo root.
37
+ * @param agents - Full array of Agent entries to persist.
38
+ */
39
+ export declare function writeAgentsConfig(repoRoot: string, agents: Agent[]): void;
40
+ /**
41
+ * Reads and returns all Flow entries from config/flows.yaml.
42
+ *
43
+ * @param repoRoot - Absolute path to the instance repo root.
44
+ */
45
+ export declare function readFlowsConfig(repoRoot: string): Flow[];
46
+ /**
47
+ * Writes the given Flow array to config/flows.yaml.
48
+ *
49
+ * @param repoRoot - Absolute path to the instance repo root.
50
+ * @param flows - Full array of Flow entries to persist.
51
+ */
52
+ export declare function writeFlowsConfig(repoRoot: string, flows: Flow[]): void;
53
+ /**
54
+ * Reads and returns all Trigger entries from config/triggers.yaml.
55
+ *
56
+ * @param repoRoot - Absolute path to the instance repo root.
57
+ */
58
+ export declare function readTriggersConfig(repoRoot: string): Trigger[];
59
+ /**
60
+ * Reads engine.yaml if it exists and returns its contents, or returns
61
+ * a safe default EngineConfig when the file is absent (the file is
62
+ * optional — HELM falls back to the Claude Code CLI defaults).
63
+ *
64
+ * @param repoRoot - Absolute path to the instance repo root.
65
+ */
66
+ export declare function readEngineConfig(repoRoot: string): EngineConfig;
67
+ /**
68
+ * Reads config/system.yaml if it exists and returns its contents.
69
+ * Returns null if the file is absent so callers can skip it gracefully.
70
+ *
71
+ * @param repoRoot - Absolute path to the instance repo root.
72
+ */
73
+ export declare function readSystemConfig(repoRoot: string): SystemConfig | null;
74
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/core/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,KAAK,EACV,KAAK,EACL,KAAK,EACL,IAAI,EACJ,OAAO,EACP,YAAY,EACZ,YAAY,EACb,MAAM,mBAAmB,CAAC;AA8D3B;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,KAAK,EAAE,CAY1D;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAGzE;AAID;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,KAAK,EAAE,CAY1D;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAGzE;AAID;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,CAYxD;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,CAGtE;AAID;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,EAAE,CAY9D;AAID;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,YAAY,CAe/D;AAID;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI,CAOtE"}
@@ -0,0 +1,182 @@
1
+ /**
2
+ * @file Instance repo YAML config file I/O.
3
+ *
4
+ * Provides typed read and write functions for every config file that
5
+ * HELM manages in the personal instance repo under /config/. All
6
+ * functions fail fast with a descriptive HelmError when a file is
7
+ * missing, unreadable, or does not contain the expected top-level type.
8
+ *
9
+ * Write functions serialise with consistent YAML formatting so diffs
10
+ * remain readable when the user views their git history.
11
+ */
12
+ import fs from "fs";
13
+ import path from "path";
14
+ import yaml from "js-yaml";
15
+ import { HelmError } from "../utils/errors.js";
16
+ // ─── Internal Helpers ─────────────────────────────────────────────────────────
17
+ /**
18
+ * Reads a YAML file at the given absolute path and returns the parsed
19
+ * value. Throws HelmError on missing file or parse failure.
20
+ *
21
+ * @param filePath - Absolute path to the YAML file.
22
+ * @param label - Human-readable name used in error messages (e.g. "inputs.yaml").
23
+ */
24
+ function readYaml(filePath, label) {
25
+ if (!fs.existsSync(filePath)) {
26
+ throw new HelmError(`Config file not found: ${label}`, `Ensure your instance repo is fully initialised. Missing: ${filePath}`);
27
+ }
28
+ const raw = fs.readFileSync(filePath, "utf-8");
29
+ try {
30
+ return yaml.load(raw);
31
+ }
32
+ catch (err) {
33
+ const detail = err instanceof Error ? err.message : String(err);
34
+ throw new HelmError(`Failed to parse ${label}: ${detail}`, `Fix the YAML syntax in ${filePath}, then retry.`);
35
+ }
36
+ }
37
+ /**
38
+ * Serialises data to YAML and writes it atomically to the given path.
39
+ * Throws HelmError if the write fails.
40
+ *
41
+ * @param filePath - Absolute path to write.
42
+ * @param data - Value to serialise.
43
+ * @param label - Human-readable name for error messages.
44
+ */
45
+ function writeYaml(filePath, data, label) {
46
+ const content = yaml.dump(data, {
47
+ indent: 2,
48
+ lineWidth: -1,
49
+ noRefs: true,
50
+ sortKeys: false,
51
+ });
52
+ try {
53
+ fs.writeFileSync(filePath, content, "utf-8");
54
+ }
55
+ catch (err) {
56
+ const detail = err instanceof Error ? err.message : String(err);
57
+ throw new HelmError(`Failed to write ${label}: ${detail}`, `Check file permissions for ${filePath}.`);
58
+ }
59
+ }
60
+ // ─── inputs.yaml ─────────────────────────────────────────────────────────────
61
+ /**
62
+ * Reads and returns all Input entries from config/inputs.yaml.
63
+ *
64
+ * @param repoRoot - Absolute path to the instance repo root.
65
+ */
66
+ export function readInputsConfig(repoRoot) {
67
+ const filePath = path.join(repoRoot, "config", "inputs.yaml");
68
+ const parsed = readYaml(filePath, "inputs.yaml");
69
+ if (!Array.isArray(parsed)) {
70
+ throw new HelmError("inputs.yaml must contain a top-level array.", `Open ${filePath} and ensure the root value is a YAML sequence.`);
71
+ }
72
+ return parsed;
73
+ }
74
+ /**
75
+ * Writes the given Input array to config/inputs.yaml, replacing
76
+ * the current file contents.
77
+ *
78
+ * @param repoRoot - Absolute path to the instance repo root.
79
+ * @param inputs - Full array of Input entries to persist.
80
+ */
81
+ export function writeInputsConfig(repoRoot, inputs) {
82
+ const filePath = path.join(repoRoot, "config", "inputs.yaml");
83
+ writeYaml(filePath, inputs, "inputs.yaml");
84
+ }
85
+ // ─── agents.yaml ─────────────────────────────────────────────────────────────
86
+ /**
87
+ * Reads and returns all Agent entries from config/agents.yaml.
88
+ *
89
+ * @param repoRoot - Absolute path to the instance repo root.
90
+ */
91
+ export function readAgentsConfig(repoRoot) {
92
+ const filePath = path.join(repoRoot, "config", "agents.yaml");
93
+ const parsed = readYaml(filePath, "agents.yaml");
94
+ if (!Array.isArray(parsed)) {
95
+ throw new HelmError("agents.yaml must contain a top-level array.", `Open ${filePath} and ensure the root value is a YAML sequence.`);
96
+ }
97
+ return parsed;
98
+ }
99
+ /**
100
+ * Writes the given Agent array to config/agents.yaml.
101
+ *
102
+ * @param repoRoot - Absolute path to the instance repo root.
103
+ * @param agents - Full array of Agent entries to persist.
104
+ */
105
+ export function writeAgentsConfig(repoRoot, agents) {
106
+ const filePath = path.join(repoRoot, "config", "agents.yaml");
107
+ writeYaml(filePath, agents, "agents.yaml");
108
+ }
109
+ // ─── flows.yaml ──────────────────────────────────────────────────────────────
110
+ /**
111
+ * Reads and returns all Flow entries from config/flows.yaml.
112
+ *
113
+ * @param repoRoot - Absolute path to the instance repo root.
114
+ */
115
+ export function readFlowsConfig(repoRoot) {
116
+ const filePath = path.join(repoRoot, "config", "flows.yaml");
117
+ const parsed = readYaml(filePath, "flows.yaml");
118
+ if (!Array.isArray(parsed)) {
119
+ throw new HelmError("flows.yaml must contain a top-level array.", `Open ${filePath} and ensure the root value is a YAML sequence.`);
120
+ }
121
+ return parsed;
122
+ }
123
+ /**
124
+ * Writes the given Flow array to config/flows.yaml.
125
+ *
126
+ * @param repoRoot - Absolute path to the instance repo root.
127
+ * @param flows - Full array of Flow entries to persist.
128
+ */
129
+ export function writeFlowsConfig(repoRoot, flows) {
130
+ const filePath = path.join(repoRoot, "config", "flows.yaml");
131
+ writeYaml(filePath, flows, "flows.yaml");
132
+ }
133
+ // ─── triggers.yaml ───────────────────────────────────────────────────────────
134
+ /**
135
+ * Reads and returns all Trigger entries from config/triggers.yaml.
136
+ *
137
+ * @param repoRoot - Absolute path to the instance repo root.
138
+ */
139
+ export function readTriggersConfig(repoRoot) {
140
+ const filePath = path.join(repoRoot, "config", "triggers.yaml");
141
+ const parsed = readYaml(filePath, "triggers.yaml");
142
+ if (!Array.isArray(parsed)) {
143
+ throw new HelmError("triggers.yaml must contain a top-level array.", `Open ${filePath} and ensure the root value is a YAML sequence.`);
144
+ }
145
+ return parsed;
146
+ }
147
+ // ─── engine.yaml ─────────────────────────────────────────────────────────────
148
+ /**
149
+ * Reads engine.yaml if it exists and returns its contents, or returns
150
+ * a safe default EngineConfig when the file is absent (the file is
151
+ * optional — HELM falls back to the Claude Code CLI defaults).
152
+ *
153
+ * @param repoRoot - Absolute path to the instance repo root.
154
+ */
155
+ export function readEngineConfig(repoRoot) {
156
+ const filePath = path.join(repoRoot, "config", "engine.yaml");
157
+ const DEFAULT_ENGINE_CONFIG = {
158
+ engine: "claude-code",
159
+ command: "claude",
160
+ timeout_seconds: 120,
161
+ };
162
+ if (!fs.existsSync(filePath)) {
163
+ return DEFAULT_ENGINE_CONFIG;
164
+ }
165
+ const parsed = readYaml(filePath, "engine.yaml");
166
+ return { ...DEFAULT_ENGINE_CONFIG, ...parsed };
167
+ }
168
+ // ─── system.yaml ─────────────────────────────────────────────────────────────
169
+ /**
170
+ * Reads config/system.yaml if it exists and returns its contents.
171
+ * Returns null if the file is absent so callers can skip it gracefully.
172
+ *
173
+ * @param repoRoot - Absolute path to the instance repo root.
174
+ */
175
+ export function readSystemConfig(repoRoot) {
176
+ const filePath = path.join(repoRoot, "config", "system.yaml");
177
+ if (!fs.existsSync(filePath))
178
+ return null;
179
+ const parsed = readYaml(filePath, "system.yaml");
180
+ return parsed;
181
+ }
182
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/core/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,IAAI,MAAM,SAAS,CAAC;AAS3B,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,iFAAiF;AAEjF;;;;;;GAMG;AACH,SAAS,QAAQ,CAAC,QAAgB,EAAE,KAAa;IAC/C,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,SAAS,CACjB,0BAA0B,KAAK,EAAE,EACjC,4DAA4D,QAAQ,EAAE,CACvE,CAAC;IACJ,CAAC;IAED,MAAM,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAE/C,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,MAAM,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAChE,MAAM,IAAI,SAAS,CACjB,mBAAmB,KAAK,KAAK,MAAM,EAAE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AKG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAgB;IAC/C,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC;IAE9D,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC;QAAE,OAAO,IAAI,CAAC;IAE1C,MAAM,MAAM,GAAG,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;IACjD,OAAO,MAAsB,CAAC;AAChC,CAAC"}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * @file Git operations for HELM.
3
+ *
4
+ * All git interactions are routed through this module. Every function
5
+ * operates on the personal instance repo at the path provided by the
6
+ * caller (obtained from repoPath() in core/repo.ts).
7
+ *
8
+ * Git discipline enforced by this module:
9
+ * - pullLatest() must be called before any flow run.
10
+ * - commitAndPush() must be called after any successful flow run.
11
+ * - Merge conflicts abort all operations with explicit manual steps.
12
+ * - git add is always called with an explicit file list — never -A.
13
+ *
14
+ * Push failures after a completed run are non-fatal: they surface as a
15
+ * warning with the manual push command so the user can recover without
16
+ * re-running the flow.
17
+ */
18
+ import type { RepoStatus } from "../types/index.js";
19
+ /**
20
+ * Pulls the latest changes from the remote origin for the current branch.
21
+ *
22
+ * Fails fast if:
23
+ * - The pull results in a merge conflict.
24
+ * - The git command itself fails (no remote, auth error, etc.).
25
+ *
26
+ * This must be called before any flow run begins to ensure the agent
27
+ * instructions and config are up to date.
28
+ *
29
+ * @param repoRoot - Absolute path to the instance repo.
30
+ * @throws {HelmError} On merge conflict or pull failure.
31
+ */
32
+ export declare function pullLatest(repoRoot: string): Promise<void>;
33
+ /**
34
+ * Returns the current working tree status of the repo.
35
+ *
36
+ * @param repoRoot - Absolute path to the instance repo.
37
+ * @throws {HelmError} If git status cannot be read.
38
+ */
39
+ export declare function getRepoStatus(repoRoot: string): Promise<RepoStatus>;
40
+ /**
41
+ * Stages an explicit list of files, commits with the given message,
42
+ * and pushes to origin.
43
+ *
44
+ * If the push fails the commit is preserved locally and the function
45
+ * prints a recoverable warning rather than throwing. This matches the
46
+ * PRD behaviour: a completed run's outputs are never discarded due to
47
+ * a push failure.
48
+ *
49
+ * @param repoRoot - Absolute path to the instance repo.
50
+ * @param files - Explicit list of repo-relative paths to stage.
51
+ * @param message - Commit message (caller applies [tag] prefix convention).
52
+ * @returns True if the push succeeded; false if it failed (warning printed).
53
+ * @throws {HelmError} If the commit itself fails.
54
+ */
55
+ export declare function commitAndPush(repoRoot: string, files: string[], message: string): Promise<boolean>;
56
+ /**
57
+ * Stages all tracked modified files and pushes with a given commit message.
58
+ * Unlike commitAndPush(), this uses `git add -u` (tracked files only) rather
59
+ * than an explicit file list. Intended for helm push where the user is
60
+ * explicitly choosing to push whatever is dirty.
61
+ *
62
+ * @param repoRoot - Absolute path to the instance repo.
63
+ * @param message - Commit message.
64
+ * @returns True if push succeeded.
65
+ * @throws {HelmError} If there is nothing to commit or commit fails.
66
+ */
67
+ export declare function addAllAndPush(repoRoot: string, message: string): Promise<boolean>;
68
+ /**
69
+ * Returns true if the `git` executable is available in PATH.
70
+ * Used by the startup check in index.ts.
71
+ */
72
+ export declare function isGitAvailable(): Promise<boolean>;
73
+ //# sourceMappingURL=git.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../src/core/git.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAyBpD;;;;;;;;;;;;GAYG;AACH,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAkChE;AAED;;;;;GAKG;AACH,wBAAsB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAoBzE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,aAAa,CACjC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EAAE,EACf,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,OAAO,CAAC,CA0BlB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,aAAa,CACjC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,OAAO,CAAC,CAwClB;AAED;;;GAGG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC,CAOvD"}