@oisincoveney/pipeline 3.8.0 → 3.9.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.
@@ -9,8 +9,6 @@ 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 -->";
14
12
  const SINGLE_OPENCODE_PLUGIN_ARRAY_RE = /\n {2}"plugin": \[\n {4}("[^"]+")\n {2}\]/;
15
13
  const OPENCODE_PROJECT_CONFIG_PATH = ".opencode/opencode.json";
16
14
  const CLAUDE_PROJECT_CONFIG_PATH = ".claude/settings.json";
@@ -94,4 +92,4 @@ function commandIdForHost(host, entrypointId) {
94
92
  return entrypointId;
95
93
  }
96
94
  //#endregion
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 };
95
+ 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 };
@@ -3,7 +3,6 @@ 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";
7
6
  import { existsSync, readFileSync, statSync } from "node:fs";
8
7
  import { dirname, join, relative } from "node:path";
9
8
  import { mkdir, readdir, rm, writeFile } from "node:fs/promises";
@@ -156,18 +155,15 @@ function commandInstallPlanItem(definition, action) {
156
155
  };
157
156
  }
158
157
  const PROJECT_ONLY_PATHS = new Set(["AGENTS.md"]);
159
- const GLOBAL_ONLY_PATHS = new Set(INSTRUCTION_PATHS);
160
158
  function scopedDefinitions(definitions, scope) {
161
159
  if (scope === "global") return definitions.filter((definition) => !PROJECT_ONLY_PATHS.has(definition.path));
162
- return definitions.filter((definition) => !GLOBAL_ONLY_PATHS.has(definition.path));
160
+ return definitions;
163
161
  }
164
162
  function installCommandsContext(options) {
165
163
  const cwd = options.cwd ?? process.cwd();
166
164
  const host = options.host ?? "all";
167
165
  const scope = options.scope ?? "global";
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);
166
+ const definitions = scopedDefinitions(definitionsFor(host, loadPipelineConfig(cwd, { allowMissingLintFileReferences: true }), cwd), scope);
171
167
  return {
172
168
  cwd,
173
169
  definitions,
@@ -0,0 +1,127 @@
1
+ import "./install-commands/shared.js";
2
+ import { execa } from "execa";
3
+ import { dirname, join } from "node:path";
4
+ import { homedir, tmpdir } from "node:os";
5
+ import { fileURLToPath } from "node:url";
6
+ import { mkdir, mkdtemp, readFile, readdir, rm, writeFile } from "node:fs/promises";
7
+ //#region src/install-rules.ts
8
+ const DEFAULT_RULES_INSTALL_SOURCE = "oisin-ee/rules";
9
+ const RULESYNC_TARGETS = [
10
+ "claudecode",
11
+ "codexcli",
12
+ "geminicli",
13
+ "opencode"
14
+ ];
15
+ function packageRoot() {
16
+ return join(dirname(fileURLToPath(import.meta.url)), "..");
17
+ }
18
+ const PACKAGE_ROOT = packageRoot();
19
+ async function cloneRulesRepository(targetDir) {
20
+ await execa("gh", [
21
+ "repo",
22
+ "clone",
23
+ DEFAULT_RULES_INSTALL_SOURCE,
24
+ targetDir,
25
+ "--",
26
+ "--depth=1"
27
+ ], { stdio: "inherit" });
28
+ }
29
+ async function withRulesSource(sourceOverride, useSource) {
30
+ if (sourceOverride !== void 0) return useSource(sourceOverride);
31
+ const parent = await mkdtemp(join(tmpdir(), "moka-rules-"));
32
+ const source = join(parent, "rules");
33
+ try {
34
+ await cloneRulesRepository(source);
35
+ return await useSource(source);
36
+ } finally {
37
+ await rm(parent, {
38
+ force: true,
39
+ recursive: true
40
+ });
41
+ }
42
+ }
43
+ async function defaultRulesyncRunner(args, opts) {
44
+ try {
45
+ await execa("rulesync", args, {
46
+ cwd: opts.cwd,
47
+ env: opts.env,
48
+ localDir: PACKAGE_ROOT,
49
+ preferLocal: true,
50
+ stdio: "inherit"
51
+ });
52
+ } catch (error) {
53
+ const cause = error instanceof Error ? `: ${error.message}` : "";
54
+ throw new Error(`Failed to generate global rules from ${DEFAULT_RULES_INSTALL_SOURCE}${cause}. If this is a private repository, authenticate GitHub access with \`gh auth login\` and rerun \`moka refresh-harnesses --scope global\`.`);
55
+ }
56
+ }
57
+ async function buildRootRule(source) {
58
+ const rulesDir = join(source, "rules");
59
+ let entries = [];
60
+ try {
61
+ entries = (await readdir(rulesDir, { withFileTypes: true })).filter((d) => d.isFile() && d.name.endsWith(".md")).map((d) => d.name).sort((a, b) => a.localeCompare(b));
62
+ } catch {}
63
+ const rootContent = `---
64
+ root: true
65
+ targets:
66
+ - "*"
67
+ ---
68
+
69
+ ${(await Promise.all(entries.map(async (name) => {
70
+ return (await readFile(join(rulesDir, name), "utf8")).trimEnd();
71
+ }))).join("\n\n")}\n`;
72
+ const rulesyncRulesDir = join(source, ".rulesync", "rules");
73
+ await mkdir(rulesyncRulesDir, { recursive: true });
74
+ await writeFile(join(rulesyncRulesDir, "_root.md"), rootContent);
75
+ }
76
+ function installRules(options = {}) {
77
+ if ((options.scope ?? "global") !== "global") return Promise.resolve({
78
+ items: [],
79
+ source: DEFAULT_RULES_INSTALL_SOURCE
80
+ });
81
+ const runner = options.rulesyncRunner ?? defaultRulesyncRunner;
82
+ return withRulesSource(options.sourceOverride, async (source) => {
83
+ await buildRootRule(source);
84
+ const home = process.env.HOME_DIR ?? homedir();
85
+ const args = [
86
+ "generate",
87
+ "-t",
88
+ RULESYNC_TARGETS.join(","),
89
+ "-f",
90
+ "rules",
91
+ "--delete"
92
+ ];
93
+ if (options.dryRun) args.push("--dry-run");
94
+ if (options.check) args.push("--check");
95
+ await runner(args, {
96
+ cwd: source,
97
+ env: {
98
+ ...process.env,
99
+ HOME_DIR: home
100
+ }
101
+ });
102
+ const action = options.dryRun ?? options.check ? "skip" : "generate";
103
+ return {
104
+ items: [
105
+ {
106
+ action,
107
+ path: join(home, ".claude/CLAUDE.md")
108
+ },
109
+ {
110
+ action,
111
+ path: join(home, ".codex/AGENTS.md")
112
+ },
113
+ {
114
+ action,
115
+ path: join(home, ".gemini/GEMINI.md")
116
+ },
117
+ {
118
+ action,
119
+ path: join(home, ".config/opencode/AGENTS.md")
120
+ }
121
+ ],
122
+ source: DEFAULT_RULES_INSTALL_SOURCE
123
+ };
124
+ });
125
+ }
126
+ //#endregion
127
+ export { installRules };
@@ -5,13 +5,13 @@ import { z } from "zod";
5
5
  //#region src/moka-submit.d.ts
6
6
  declare const mokaSubmitDirectHooksSchema: z.ZodRecord<z.ZodEnum<{
7
7
  "workflow.start": "workflow.start";
8
- "node.finish": "node.finish";
9
- "node.start": "node.start";
10
8
  "workflow.success": "workflow.success";
11
9
  "workflow.failure": "workflow.failure";
12
10
  "workflow.complete": "workflow.complete";
11
+ "node.start": "node.start";
13
12
  "node.success": "node.success";
14
13
  "node.error": "node.error";
14
+ "node.finish": "node.finish";
15
15
  "gate.failure": "gate.failure";
16
16
  }> & z.core.$partial, z.ZodDiscriminatedUnion<[z.ZodObject<{
17
17
  failure: z.ZodDefault<z.ZodEnum<{
@@ -94,13 +94,13 @@ declare const mokaSubmitOptionsSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
94
94
  }, z.core.$strict>>;
95
95
  hooks: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
96
96
  "workflow.start": "workflow.start";
97
- "node.finish": "node.finish";
98
- "node.start": "node.start";
99
97
  "workflow.success": "workflow.success";
100
98
  "workflow.failure": "workflow.failure";
101
99
  "workflow.complete": "workflow.complete";
100
+ "node.start": "node.start";
102
101
  "node.success": "node.success";
103
102
  "node.error": "node.error";
103
+ "node.finish": "node.finish";
104
104
  "gate.failure": "gate.failure";
105
105
  }> & z.core.$partial, z.ZodDiscriminatedUnion<[z.ZodObject<{
106
106
  failure: z.ZodDefault<z.ZodEnum<{
@@ -207,13 +207,13 @@ declare const mokaSubmitOptionsSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
207
207
  }, z.core.$strict>>;
208
208
  hooks: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
209
209
  "workflow.start": "workflow.start";
210
- "node.finish": "node.finish";
211
- "node.start": "node.start";
212
210
  "workflow.success": "workflow.success";
213
211
  "workflow.failure": "workflow.failure";
214
212
  "workflow.complete": "workflow.complete";
213
+ "node.start": "node.start";
215
214
  "node.success": "node.success";
216
215
  "node.error": "node.error";
216
+ "node.finish": "node.finish";
217
217
  "gate.failure": "gate.failure";
218
218
  }> & z.core.$partial, z.ZodDiscriminatedUnion<[z.ZodObject<{
219
219
  failure: z.ZodDefault<z.ZodEnum<{
@@ -1,6 +1,7 @@
1
1
  import "./install-commands/shared.js";
2
2
  import { installCommands } from "./install-commands.js";
3
3
  import { installHooks } from "./install-hooks.js";
4
+ import { installRules } from "./install-rules.js";
4
5
  import { existsSync } from "node:fs";
5
6
  import { execa } from "execa";
6
7
  import { join } from "node:path";
@@ -76,6 +77,10 @@ async function initPipelineProject(options = {}) {
76
77
  const scope = options.scope ?? "global";
77
78
  const skillInstaller = options.skillInstaller ?? ((target) => installDefaultSkills(target, skillScopeFor(scope)));
78
79
  const hookInstaller = options.hookInstaller ?? installDefaultHooks;
80
+ const rulesInstaller = options.rulesInstaller ?? ((target, s) => installRules({
81
+ cwd: target,
82
+ scope: s
83
+ }));
79
84
  await skillInstaller(cwd);
80
85
  const result = await installCommands({
81
86
  cwd,
@@ -84,8 +89,13 @@ async function initPipelineProject(options = {}) {
84
89
  scope
85
90
  });
86
91
  const hooks = await hookInstaller(cwd, scope);
92
+ const rulesResult = await rulesInstaller(cwd, scope);
87
93
  return {
88
- files: [...result.items.map((item) => item.path), ...hookInstallerFiles(hooks)],
94
+ files: [
95
+ ...result.items.map((item) => item.path),
96
+ ...hookInstallerFiles(hooks),
97
+ ...rulesResult.items.map((item) => item.path)
98
+ ],
89
99
  scope
90
100
  };
91
101
  }
@@ -94,6 +104,7 @@ async function refreshAgentHarnesses(options = {}) {
94
104
  const init = await initPipelineProject({
95
105
  cwd: context.cwd,
96
106
  hookInstaller: options.hookInstaller,
107
+ rulesInstaller: options.rulesInstaller,
97
108
  scope: options.scope,
98
109
  skillInstaller: options.skillInstaller
99
110
  });
@@ -118,7 +129,7 @@ async function refreshAgentHarnessesCommitResult(context) {
118
129
  function formatPipelineInitResult(result) {
119
130
  return [
120
131
  "Initialized package-owned pipeline support:",
121
- result.scope === "global" ? "installed the per-machine harness globally (user/global skills + ~/.claude, ~/.config/opencode, ~/.codex); inherited by every repo with no per-repo copy" : "installed default skills and host config repo-local",
132
+ result.scope === "global" ? "installed the per-machine harness globally (user/global skills + ~/.claude, ~/.config/opencode, ~/.codex); global instruction files generated via rulesync from oisin-ee/rules; inherited by every repo with no per-repo copy" : "installed default skills and host config repo-local",
122
133
  ...result.files.map((path) => `generated ${path}`),
123
134
  "no repo-local pipeline config files were created"
124
135
  ].join("\n");
@@ -11,8 +11,8 @@ declare const runnerEventRecordSchema: z.ZodUnion<readonly [z.ZodObject<{
11
11
  runId: z.ZodString;
12
12
  sequence: z.ZodNumber;
13
13
  type: z.ZodEnum<{
14
- "workflow.planned": "workflow.planned";
15
14
  "workflow.start": "workflow.start";
15
+ "workflow.planned": "workflow.planned";
16
16
  }>;
17
17
  workflowPlan: z.ZodObject<{
18
18
  edges: z.ZodOptional<z.ZodArray<z.ZodObject<{
@@ -58,10 +58,10 @@ declare const runnerEventRecordSchema: z.ZodUnion<readonly [z.ZodObject<{
58
58
  }>;
59
59
  }, z.core.$strip>;
60
60
  type: z.ZodEnum<{
61
+ "node.start": "node.start";
62
+ "node.finish": "node.finish";
61
63
  "agent.finish": "agent.finish";
62
64
  "agent.start": "agent.start";
63
- "node.finish": "node.finish";
64
- "node.start": "node.start";
65
65
  }>;
66
66
  }, z.core.$strip>, z.ZodObject<{
67
67
  at: z.ZodOptional<z.ZodString>;
@@ -189,8 +189,8 @@ declare const runnerEventBatchSchema: z.ZodObject<{
189
189
  runId: z.ZodString;
190
190
  sequence: z.ZodNumber;
191
191
  type: z.ZodEnum<{
192
- "workflow.planned": "workflow.planned";
193
192
  "workflow.start": "workflow.start";
193
+ "workflow.planned": "workflow.planned";
194
194
  }>;
195
195
  workflowPlan: z.ZodObject<{
196
196
  edges: z.ZodOptional<z.ZodArray<z.ZodObject<{
@@ -236,10 +236,10 @@ declare const runnerEventBatchSchema: z.ZodObject<{
236
236
  }>;
237
237
  }, z.core.$strip>;
238
238
  type: z.ZodEnum<{
239
+ "node.start": "node.start";
240
+ "node.finish": "node.finish";
239
241
  "agent.finish": "agent.finish";
240
242
  "agent.start": "agent.start";
241
- "node.finish": "node.finish";
242
- "node.start": "node.start";
243
243
  }>;
244
244
  }, z.core.$strip>, z.ZodObject<{
245
245
  at: z.ZodOptional<z.ZodString>;
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "dependencies": {
3
3
  "@dagrejs/graphlib": "^4.0.1",
4
+ "rulesync": "8.30.1",
4
5
  "@kubernetes/client-node": "^1.4.0",
5
6
  "@opencode-ai/sdk": "1.17.4",
6
7
  "ajv": "^8.20.0",
@@ -126,7 +127,7 @@
126
127
  "prepack": "bun run build:cli"
127
128
  },
128
129
  "type": "module",
129
- "version": "3.8.0",
130
+ "version": "3.9.0",
130
131
  "description": "Config-driven multi-agent pipeline runner for repository work",
131
132
  "main": "./dist/index.js",
132
133
  "types": "./dist/index.d.ts",
@@ -1,68 +0,0 @@
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`.
@@ -1,62 +0,0 @@
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 };