@oisincoveney/pipeline 3.6.0 → 3.7.0

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.
@@ -0,0 +1,68 @@
1
+ # Caveman Mode (default ON)
2
+
3
+ Operate in caveman mode by default on every response: terse, smart-caveman phrasing — drop filler, keep ALL technical substance, code, commands, paths, and accuracy. This is active every response and does not drift off over a long session. Defer to the `caveman` skill for the exact compression rules and intensity levels. Turn off only when the user says "stop caveman" or "normal mode".
4
+
5
+ # Global Behavior
6
+
7
+ - Answer fully and stop. Never end with "Want me to do X?" or "Should I implement this?" — if the user wants more, they'll ask.
8
+ - Research before acting — know how components and libraries work before making changes.
9
+ - When uncertain, ask — don't guess.
10
+ - The answer to "Why is X an improvement?" should never be "I'm not sure."
11
+
12
+ ## Before writing code
13
+
14
+ - Search for existing implementations before creating new code.
15
+ - Check for existing utilities before adding helpers.
16
+ - Don't add dependencies without checking if functionality already exists in current deps.
17
+ - Reuse patterns from similar files in the codebase.
18
+
19
+ ## Problem-solving
20
+
21
+ - Is this a real problem? Reject over-engineering.
22
+ - Is there a simpler way? Always seek the simplest solution.
23
+ - Will it break anything? Backward compatibility matters.
24
+
25
+ # Anti-Patterns
26
+
27
+ ## Code quality
28
+
29
+ - NEVER manually edit auto-generated files — regenerate them instead.
30
+ - NEVER suppress type errors (`as any`, `@ts-ignore`, `@ts-expect-error`).
31
+ - NEVER use bandaids or hacks — proper fixes only.
32
+ - NEVER create new Zod schemas when generated ones exist.
33
+ - NEVER use `var` declarations.
34
+ - NEVER add `.unwrap()` calls in Rust code.
35
+
36
+ ## Error handling
37
+
38
+ - Silent error handling is NEVER permitted.
39
+ - Every fallback and default value MUST have specific business-logic reasoning.
40
+ - Unexpected errors MUST be logged, not swallowed.
41
+ - Errors affecting user flow MUST surface to the user — never hide failures.
42
+
43
+ ## Testing
44
+
45
+ - NEVER commit code without tests for new functionality.
46
+ - NEVER skip tests or mark them skipped to make CI pass.
47
+ - NEVER disable or delete existing tests — fix the code, not the tests.
48
+ - Test both success and error cases.
49
+
50
+ # Verification
51
+
52
+ - Run tests, lint, and typecheck after every change.
53
+ - Self-assessment is unreliable — use external signals (build output, test results) as ground truth.
54
+ - Don't claim something works without running it.
55
+ - If a test suite exists, run it. Don't skip it because "the change is small."
56
+
57
+ # Coding Style
58
+
59
+ - 120 char line width.
60
+ - Trailing commas everywhere.
61
+
62
+ ## Git
63
+
64
+ - NEVER commit/push directly to main.
65
+ - NEVER amend commits or rewrite history after pushing.
66
+ - NEVER use `--force` without explicit approval.
67
+ - Always create new commits — never amend, squash, or rebase unless explicitly asked.
68
+ - Conventional commit format: `feat|fix|chore|docs|test|refactor(scope): description`.
@@ -481,8 +481,8 @@ declare const configSchema: z.ZodObject<{
481
481
  schedules: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
482
482
  description: z.ZodOptional<z.ZodString>;
483
483
  baseline: z.ZodEnum<{
484
- execute: "execute";
485
484
  quick: "quick";
485
+ execute: "execute";
486
486
  }>;
487
487
  max_parallel_nodes: z.ZodOptional<z.ZodNumber>;
488
488
  node_catalog: z.ZodOptional<z.ZodString>;
@@ -0,0 +1,62 @@
1
+ import { resolvePackageAssetPath } from "../package-assets.js";
2
+ import { GENERATED_MARKER, INSTRUCTIONS_END, INSTRUCTIONS_START, OWNER_MARKER_PREFIX } from "./shared.js";
3
+ import { readFileSync } from "node:fs";
4
+ //#region src/install-commands/instructions.ts
5
+ /**
6
+ * The canonical global agent instruction body, package-owned so every machine,
7
+ * k8s job, and host renders the same behavior. Shipped in `defaults/` (see
8
+ * package.json `files`).
9
+ */
10
+ const INSTRUCTION_BODY = readFileSync(resolvePackageAssetPath("defaults/instructions/global.md"), "utf8").trimEnd();
11
+ /**
12
+ * The global instruction memory file each host reads, and the repo-relative
13
+ * path that `resolveHarnessTarget` rebases onto its per-machine config dir.
14
+ * Distinct from the bare `AGENTS.md` project guidance file, so these coexist
15
+ * with (and never trip) the PROJECT_ONLY AGENTS.md handling.
16
+ */
17
+ const INSTRUCTION_TARGETS = [
18
+ {
19
+ host: "claude-code",
20
+ path: ".claude/CLAUDE.md"
21
+ },
22
+ {
23
+ host: "codex",
24
+ path: ".codex/AGENTS.md"
25
+ },
26
+ {
27
+ host: "gemini",
28
+ path: ".gemini/GEMINI.md"
29
+ }
30
+ ];
31
+ /** Repo-relative paths of every generated instruction file (global scope). */
32
+ const INSTRUCTION_PATHS = INSTRUCTION_TARGETS.map((target) => target.path);
33
+ function instructionContent(host) {
34
+ return `${[
35
+ INSTRUCTIONS_START,
36
+ GENERATED_MARKER,
37
+ `${OWNER_MARKER_PREFIX}host=${host} -->`,
38
+ "",
39
+ INSTRUCTION_BODY,
40
+ "",
41
+ INSTRUCTIONS_END
42
+ ].join("\n")}\n`;
43
+ }
44
+ /**
45
+ * Per-host global instruction definitions. Each is upserted as a marker block
46
+ * so any user-authored content outside the markers in the target file is
47
+ * preserved. Emitted in global scope only (see GLOBAL_ONLY_PATHS).
48
+ */
49
+ function globalInstructionDefinitions() {
50
+ return INSTRUCTION_TARGETS.map(({ host, path }) => ({
51
+ block: {
52
+ end: INSTRUCTIONS_END,
53
+ start: INSTRUCTIONS_START
54
+ },
55
+ content: instructionContent(host),
56
+ host,
57
+ invocation: "(global instructions)",
58
+ path
59
+ }));
60
+ }
61
+ //#endregion
62
+ export { INSTRUCTION_PATHS, globalInstructionDefinitions };
@@ -9,6 +9,8 @@ const OWNER_TS_MARKER_PREFIX = "// @oisincoveney/pipeline:";
9
9
  const OWNER_YAML_MARKER_PREFIX = "# @oisincoveney/pipeline:";
10
10
  const AGENTS_MD_START = "<!-- @oisincoveney/pipeline:agents:start -->";
11
11
  const AGENTS_MD_END = "<!-- @oisincoveney/pipeline:agents:end -->";
12
+ const INSTRUCTIONS_START = "<!-- @oisincoveney/pipeline:instructions:start -->";
13
+ const INSTRUCTIONS_END = "<!-- @oisincoveney/pipeline:instructions:end -->";
12
14
  const SINGLE_OPENCODE_PLUGIN_ARRAY_RE = /\n {2}"plugin": \[\n {4}("[^"]+")\n {2}\]/;
13
15
  const OPENCODE_PROJECT_CONFIG_PATH = ".opencode/opencode.json";
14
16
  const CLAUDE_PROJECT_CONFIG_PATH = ".claude/settings.json";
@@ -34,6 +36,9 @@ function codexGlobalConfigDir() {
34
36
  function opencodeGlobalConfigDir() {
35
37
  return process.env.OPENCODE_CONFIG_DIR ?? join(process.env.XDG_CONFIG_HOME ?? join(homedir(), ".config"), "opencode");
36
38
  }
39
+ function geminiGlobalConfigDir() {
40
+ return process.env.GEMINI_CONFIG_DIR ?? join(homedir(), ".gemini");
41
+ }
37
42
  function stripPrefix(value, prefix) {
38
43
  if (value === prefix) return "";
39
44
  return value.startsWith(`${prefix}/`) ? value.slice(prefix.length + 1) : value;
@@ -55,6 +60,7 @@ function resolveHarnessTarget(scope, cwd, relPath) {
55
60
  const normalized = relPath.replaceAll("\\", "/");
56
61
  if (normalized === ".claude" || normalized.startsWith(".claude/")) return join(claudeGlobalConfigDir(), stripPrefix(normalized, ".claude"));
57
62
  if (normalized === ".codex" || normalized.startsWith(".codex/")) return join(codexGlobalConfigDir(), stripPrefix(normalized, ".codex"));
63
+ if (normalized === ".gemini" || normalized.startsWith(".gemini/")) return join(geminiGlobalConfigDir(), stripPrefix(normalized, ".gemini"));
58
64
  return join(opencodeGlobalConfigDir(), stripPrefix(normalized, ".opencode"));
59
65
  }
60
66
  function profileEntries(config) {
@@ -88,4 +94,4 @@ function commandIdForHost(host, entrypointId) {
88
94
  return entrypointId;
89
95
  }
90
96
  //#endregion
91
- export { AGENTS_MD_END, AGENTS_MD_START, CLAUDE_PROJECT_CONFIG_PATH, COMMAND_HOSTS, DEFAULT_HARNESS_SCOPE, ENTRYPOINT_PATH_PATTERNS, GENERATED_MARKER, GENERATED_TS_MARKER, GENERATED_YAML_MARKER, OPENCODE_PROJECT_CONFIG_PATH, OWNER_MARKER_PREFIX, OWNER_TS_MARKER_PREFIX, OWNER_YAML_MARKER_PREFIX, SINGLE_OPENCODE_PLUGIN_ARRAY_RE, commandIdForHost, compactLines, entrypointDescription, entrypointEntries, instructionsPointer, invocationForHost, profileEntries, resolveHarnessTarget };
97
+ export { AGENTS_MD_END, AGENTS_MD_START, CLAUDE_PROJECT_CONFIG_PATH, COMMAND_HOSTS, DEFAULT_HARNESS_SCOPE, ENTRYPOINT_PATH_PATTERNS, GENERATED_MARKER, GENERATED_TS_MARKER, GENERATED_YAML_MARKER, INSTRUCTIONS_END, INSTRUCTIONS_START, OPENCODE_PROJECT_CONFIG_PATH, OWNER_MARKER_PREFIX, OWNER_TS_MARKER_PREFIX, OWNER_YAML_MARKER_PREFIX, SINGLE_OPENCODE_PLUGIN_ARRAY_RE, commandIdForHost, compactLines, entrypointDescription, entrypointEntries, instructionsPointer, invocationForHost, profileEntries, resolveHarnessTarget };
@@ -3,6 +3,7 @@ import "./config.js";
3
3
  import { COMMAND_HOSTS, ENTRYPOINT_PATH_PATTERNS, invocationForHost, resolveHarnessTarget } from "./install-commands/shared.js";
4
4
  import { opencodeAdapter } from "./install-commands/opencode.js";
5
5
  import { claudeCodeAdapter } from "./install-commands/claude-code.js";
6
+ import { INSTRUCTION_PATHS, globalInstructionDefinitions } from "./install-commands/instructions.js";
6
7
  import { existsSync, readFileSync, statSync } from "node:fs";
7
8
  import { dirname, join, relative } from "node:path";
8
9
  import { mkdir, readdir, rm, writeFile } from "node:fs/promises";
@@ -75,7 +76,7 @@ function entrypointIdFromGeneratedPath(host, path) {
75
76
  }
76
77
  function resolveDefinitionContent(definition, target) {
77
78
  const adapter = ADAPTERS[definition.host];
78
- if (!(adapter.mergeDefinition && existsSync(target))) return {
79
+ if (!(adapter?.mergeDefinition && existsSync(target))) return {
79
80
  conflict: false,
80
81
  content: definition.content
81
82
  };
@@ -120,7 +121,7 @@ function upsertGeneratedBlock(current, content, block) {
120
121
  return `${current.trimEnd()}${separator}${content}`;
121
122
  }
122
123
  function adapterForcesDefinition(definition) {
123
- const fn = ADAPTERS[definition.host].isAlwaysForced;
124
+ const fn = ADAPTERS[definition.host]?.isAlwaysForced;
124
125
  return fn ? fn(definition) : false;
125
126
  }
126
127
  function installActionForDefinition(definition, target, resolved, force) {
@@ -155,15 +156,18 @@ function commandInstallPlanItem(definition, action) {
155
156
  };
156
157
  }
157
158
  const PROJECT_ONLY_PATHS = new Set(["AGENTS.md"]);
159
+ const GLOBAL_ONLY_PATHS = new Set(INSTRUCTION_PATHS);
158
160
  function scopedDefinitions(definitions, scope) {
159
- if (scope !== "global") return definitions;
160
- return definitions.filter((definition) => !PROJECT_ONLY_PATHS.has(definition.path));
161
+ if (scope === "global") return definitions.filter((definition) => !PROJECT_ONLY_PATHS.has(definition.path));
162
+ return definitions.filter((definition) => !GLOBAL_ONLY_PATHS.has(definition.path));
161
163
  }
162
164
  function installCommandsContext(options) {
163
165
  const cwd = options.cwd ?? process.cwd();
164
166
  const host = options.host ?? "all";
165
167
  const scope = options.scope ?? "global";
166
- const definitions = scopedDefinitions(definitionsFor(host, loadPipelineConfig(cwd, { allowMissingLintFileReferences: true }), cwd), scope);
168
+ const config = loadPipelineConfig(cwd, { allowMissingLintFileReferences: true });
169
+ const instructionDefinitions = globalInstructionDefinitions().filter((definition) => host === "all" || definition.host === host);
170
+ const definitions = scopedDefinitions([...definitionsFor(host, config, cwd), ...instructionDefinitions], scope);
167
171
  return {
168
172
  cwd,
169
173
  definitions,
@@ -160,8 +160,8 @@ declare const mokaSubmitOptionsSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
160
160
  }, z.core.$strict>>;
161
161
  serviceAccountName: z.ZodOptional<z.ZodString>;
162
162
  mode: z.ZodEnum<{
163
- quick: "quick";
164
163
  full: "full";
164
+ quick: "quick";
165
165
  }>;
166
166
  schedulePath: z.ZodOptional<z.ZodString>;
167
167
  scheduleYaml: z.ZodOptional<z.ZodString>;
@@ -232,11 +232,13 @@ function runSetupCommand(command, index, options) {
232
232
  const io = yield* RunnerCommandIoService;
233
233
  const commandIndex = index + 1;
234
234
  options.logger.info(setupCommandLog(command.command, commandIndex, "start"), "setup.command start");
235
- const exitCode = setupExitCode((yield* io.runSetupCommand(command.command, command.args, {
235
+ const result = yield* io.runSetupCommand(command.command, command.args, {
236
236
  cwd: options.worktreePath,
237
237
  env: options.env
238
- })).exitCode);
238
+ });
239
+ const exitCode = setupExitCode(result.exitCode);
239
240
  options.logger.info(setupCommandFinishLog(command, commandIndex, exitCode), "setup.command finish");
241
+ if (exitCode !== 0) options.logger.error(setupCommandOutputLog(command.command, commandIndex, result), "setup.command output");
240
242
  if (exitCode !== 0 && command.required) return yield* Effect.fail(/* @__PURE__ */ new Error(`runner setup command '${command.command}' failed with exit ${exitCode}`));
241
243
  });
242
244
  }
@@ -244,6 +246,21 @@ function setupExitCode(exitCode) {
244
246
  if (typeof exitCode === "number") return exitCode;
245
247
  return 1;
246
248
  }
249
+ const SETUP_OUTPUT_TAIL = 4e3;
250
+ function setupOutputTail(output) {
251
+ if (typeof output !== "string" || output.length === 0) return "";
252
+ return output.length > SETUP_OUTPUT_TAIL ? output.slice(-4e3) : output;
253
+ }
254
+ function setupCommandOutputLog(command, index, result) {
255
+ return {
256
+ command,
257
+ index,
258
+ phase: "setup.command",
259
+ status: "output",
260
+ stderr: setupOutputTail(result.stderr),
261
+ stdout: setupOutputTail(result.stdout)
262
+ };
263
+ }
247
264
  function setupCommandLog(command, index, status) {
248
265
  return {
249
266
  command,
@@ -43,8 +43,8 @@ declare const runnerDeliverySchema: z.ZodObject<{
43
43
  declare const mokaSubmissionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
44
44
  kind: z.ZodLiteral<"graph">;
45
45
  mode: z.ZodEnum<{
46
- quick: "quick";
47
46
  full: "full";
47
+ quick: "quick";
48
48
  }>;
49
49
  }, z.core.$strict>, z.ZodObject<{
50
50
  argv: z.ZodArray<z.ZodString>;
@@ -104,8 +104,8 @@ declare const runnerCommandPayloadSchema: z.ZodObject<{
104
104
  submission: z.ZodDefault<z.ZodDiscriminatedUnion<[z.ZodObject<{
105
105
  kind: z.ZodLiteral<"graph">;
106
106
  mode: z.ZodEnum<{
107
- quick: "quick";
108
107
  full: "full";
108
+ quick: "quick";
109
109
  }>;
110
110
  }, z.core.$strict>, z.ZodObject<{
111
111
  argv: z.ZodArray<z.ZodString>;
@@ -188,6 +188,7 @@ function mapWorkflowRunnerEvent(event, context, record) {
188
188
  }
189
189
  function mapNodeRunnerEvent(event, record) {
190
190
  switch (event.type) {
191
+ case "node.session": return [];
191
192
  case "node.start": return [{
192
193
  ...record,
193
194
  type: event.type,
package/package.json CHANGED
@@ -126,7 +126,7 @@
126
126
  "prepack": "bun run build:cli"
127
127
  },
128
128
  "type": "module",
129
- "version": "3.6.0",
129
+ "version": "3.7.0",
130
130
  "description": "Config-driven multi-agent pipeline runner for repository work",
131
131
  "main": "./dist/index.js",
132
132
  "types": "./dist/index.d.ts",