@punks/cli 2.1.6 → 2.1.9

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/AGENTS.md CHANGED
@@ -6,6 +6,8 @@ This app owns the `punks`/`dp` executable, repo detection flow, local scaffold a
6
6
 
7
7
  Keep consumer-repo product logic out of the CLI. The future backend owns registry, provenance, auth, telemetry, and artifact access; the CLI remains the local scanner, cache, prompt/skill/hook placer, and filesystem writer.
8
8
 
9
+ When pushing a new npm executable release, update `CHANGELOG.md` first with a non-empty section for the exact `apps/cli/package.json` version. `bun run release:publish` must publish `@punks/cli`, push the matching `v<version>` tag, and create the GitHub release from that changelog entry. Baseline-only releases stay on `baseline/stable/*` and do not require package changelog entries.
10
+
9
11
  For direct CLI UX, packaging, and release behavior guidance, inspect:
10
12
 
11
13
  - `opensrc path cevr/sentry-cli` (`https://github.com/cevr/sentry-cli`)
package/README.md CHANGED
@@ -42,7 +42,7 @@ Before refreshing generated skills, setup migrates legacy per-agent skill folder
42
42
 
43
43
  `punks update --yes` applies managed scaffold updates without prompting. It is the non-interactive alias for the apply behavior of `--write`.
44
44
 
45
- `punks report` opens a GitHub issue in `wearedevpunks/harness-intelligence` for reusable Harness docs, workflow, tooling, CLI, skill-pack, or wiki friction. It uses `gh auth token`, `GH_TOKEN`, or `GITHUB_TOKEN` for GitHub auth and applies report labels such as `harness-report`, `area:wiki`, `surface:cli`, `pack:dp-cli`, and `command:dp-report`.
45
+ `punks report` submits reusable Harness docs, workflow, tooling, CLI, skill-pack, or wiki friction to the Harness API. Public CLI submissions are validated, given deterministic metadata, and stored internally for backoffice triage. GitHub issue creation is reserved for authenticated backoffice operator flows.
46
46
 
47
47
  Interactive commands check the selected npm dist-tag before running. When a newer CLI is available, `punks` asks for confirmation, reinstalls through the detected global package manager, and exits so the command can be rerun on the upgraded binary. `punks upgrade` keeps the same installer path as an explicit manual command. Use `--tag next` for prerelease channels or `--force` to reinstall the selected tag even when the current version is fresh.
48
48
 
@@ -92,7 +92,7 @@ bun run release:publish
92
92
 
93
93
  `bun run baseline:publish` builds the current scaffold baseline, creates or updates the `baseline/stable/<date>-<sha>` GitHub release, and uploads the baseline manifest plus tarball. Use it when scaffold data changes but the npm executable does not need a new version.
94
94
 
95
- `bun run release:publish` builds the CLI, publishes a sanitized npm package from the built `dist/` output, updates the `latest` dist-tag, also updates `next` for latest releases, and pushes the matching `v<version>` git tag. Commit and push the version bump before running it; the script refuses dirty worktrees and existing tags that point at another commit. Set `NPM_TAG=beta` for beta prereleases without moving `latest`.
95
+ `bun run release:publish` builds the CLI, publishes a sanitized npm package from the built `dist/` output, updates the `latest` dist-tag, also updates `next` for latest releases, pushes the matching `v<version>` git tag, and creates or updates the GitHub release title and notes from the categorized `CHANGELOG.md` content. GitHub notes use compact category labels such as `changed:` and `fixed:` without changelog publish metadata. Commit the version bump and changelog entry before running it; the script refuses dirty worktrees, missing changelog entries, uncategorized release notes, and existing tags that point at another commit. Set `NPM_TAG=beta` for beta prereleases without moving `latest`.
96
96
 
97
97
  Before npm releases, authenticate against the public npm registry:
98
98
 
@@ -96,7 +96,9 @@ Strong success criteria let you loop independently. Weak criteria ("make it work
96
96
 
97
97
  ## Subagents
98
98
 
99
- In readonly scenarios ONLY spawn subagents aggressively for parallelization opportunities outside code writing. Examples: research, auditing, docs updating, investigating multiple hypotheses, exploring unrelated areas. Fan out whenever possible, synthesize findings before acting.
99
+ Before delegating, verify the active harness global/project settings actually enable subagent execution. Then verify `.agents/subagents/manifest.mjs` exists and the chosen specialist has matching owned paths, guidance files, and skills.
100
+
101
+ Use readonly subagents aggressively for research, auditing, docs updating, investigating multiple hypotheses, or exploring unrelated areas. Implementation subagents are allowed only when a skill or plan explicitly requires them, such as `implement-spec` sequential single-worker execution or parallel waves. If the runtime guard fails, repair setup or execute locally; do not claim inactive worker coverage.
100
102
 
101
103
  ## Notes — Cross-session Memory
102
104
 
@@ -15,6 +15,7 @@ export interface LintPlacementDefinition {
15
15
  export interface LintAssetDefinition {
16
16
  readonly id: LintAssetId;
17
17
  readonly description: string;
18
+ readonly oxlintPresets: ReadonlyArray<string>;
18
19
  readonly plugins: ReadonlyArray<string>;
19
20
  readonly jsPlugins: ReadonlyArray<LintJsPluginDefinition>;
20
21
  readonly settings: Record<string, unknown>;
@@ -24,7 +25,7 @@ export interface LintAssetDefinition {
24
25
  }
25
26
 
26
27
  const sharedReactPlacement = {
27
- recommendedConfigFile: ".oxlintrc.json",
28
+ recommendedConfigFile: "oxlint.config.ts",
28
29
  recommendedFiles: ["<detected-react-workspace>/**/*.{js,jsx,ts,tsx}"],
29
30
  recommendedWorkspaces: ["detected React workspaces"],
30
31
  placementNotes:
@@ -32,7 +33,7 @@ const sharedReactPlacement = {
32
33
  } as const satisfies LintPlacementDefinition;
33
34
 
34
35
  const webOnlyPlacement = {
35
- recommendedConfigFile: ".oxlintrc.json",
36
+ recommendedConfigFile: "oxlint.config.ts",
36
37
  recommendedFiles: ["<detected-nextjs-workspace>/**/*.{js,jsx,ts,tsx}"],
37
38
  recommendedWorkspaces: ["detected Next.js workspaces"],
38
39
  placementNotes:
@@ -40,7 +41,7 @@ const webOnlyPlacement = {
40
41
  } as const satisfies LintPlacementDefinition;
41
42
 
42
43
  const effectPlacement = {
43
- recommendedConfigFile: ".oxlintrc.json",
44
+ recommendedConfigFile: "oxlint.config.ts",
44
45
  recommendedFiles: ["<detected-effect-workspace>/**/*.{js,jsx,ts,tsx}"],
45
46
  recommendedWorkspaces: ["detected Effect workspaces"],
46
47
  placementNotes:
@@ -48,7 +49,7 @@ const effectPlacement = {
48
49
  } as const satisfies LintPlacementDefinition;
49
50
 
50
51
  const vitestPlacement = {
51
- recommendedConfigFile: ".oxlintrc.json",
52
+ recommendedConfigFile: "oxlint.config.ts",
52
53
  recommendedFiles: [
53
54
  "<detected-test-workspace>/**/*.{test,spec}.{js,jsx,ts,tsx}",
54
55
  "<detected-test-workspace>/src/test/**/*.{js,jsx,ts,tsx}",
@@ -61,38 +62,19 @@ const vitestPlacement = {
61
62
  export const lintCatalog = [
62
63
  {
63
64
  id: "react-core",
64
- description: "Core React rules for rendered app and shared UI code.",
65
- plugins: ["unicorn", "typescript", "oxc", "react"],
65
+ description: "Ultracite React preset for rendered app and shared UI code.",
66
+ oxlintPresets: ["react"],
67
+ plugins: [],
66
68
  jsPlugins: [],
67
69
  settings: {},
68
- rules: {
69
- "react/rules-of-hooks": "error",
70
- "react/exhaustive-deps": "error",
71
- "react/forward-ref-uses-ref": "error",
72
- "react/jsx-key": "error",
73
- "react/jsx-no-comment-textnodes": "error",
74
- "react/jsx-no-duplicate-props": "error",
75
- "react/jsx-no-target-blank": "error",
76
- "react/jsx-no-undef": "error",
77
- "react/jsx-no-useless-fragment": "error",
78
- "react/no-children-prop": "error",
79
- "react/no-danger-with-children": "error",
80
- "react/no-direct-mutation-state": "error",
81
- "react/no-find-dom-node": "error",
82
- "react/no-render-return-value": "error",
83
- "react/no-string-refs": "error",
84
- "react/no-this-in-sfc": "error",
85
- "react/no-unknown-property": "error",
86
- "react/no-unescaped-entities": "error",
87
- "react/no-unsafe": "error",
88
- "react/void-dom-elements-no-children": "error",
89
- },
70
+ rules: {},
90
71
  requiredDevDependencies: [],
91
72
  placement: sharedReactPlacement,
92
73
  },
93
74
  {
94
75
  id: "react-hooks",
95
76
  description: "React Hooks lint rules via the JS plugin bridge for Oxlint.",
77
+ oxlintPresets: [],
96
78
  plugins: [],
97
79
  jsPlugins: [
98
80
  {
@@ -102,6 +84,7 @@ export const lintCatalog = [
102
84
  ],
103
85
  settings: {},
104
86
  rules: {
87
+ "react-hooks-js/exhaustive-deps": "error",
105
88
  "react-hooks-js/component-hook-factories": "error",
106
89
  "react-hooks-js/config": "error",
107
90
  "react-hooks-js/error-boundaries": "error",
@@ -112,6 +95,7 @@ export const lintCatalog = [
112
95
  "react-hooks-js/preserve-manual-memoization": "error",
113
96
  "react-hooks-js/purity": "error",
114
97
  "react-hooks-js/refs": "error",
98
+ "react-hooks-js/rules-of-hooks": "error",
115
99
  "react-hooks-js/set-state-in-effect": "error",
116
100
  "react-hooks-js/set-state-in-render": "error",
117
101
  "react-hooks-js/static-components": "error",
@@ -124,6 +108,7 @@ export const lintCatalog = [
124
108
  {
125
109
  id: "react-you-might-not-need-an-effect",
126
110
  description: "Guidance rules that push React code away from unnecessary effects.",
111
+ oxlintPresets: [],
127
112
  plugins: [],
128
113
  jsPlugins: [
129
114
  {
@@ -136,7 +121,6 @@ export const lintCatalog = [
136
121
  "react-you-might-not-need-an-effect-js/no-adjust-state-on-prop-change": "error",
137
122
  "react-you-might-not-need-an-effect-js/no-chain-state-updates": "error",
138
123
  "react-you-might-not-need-an-effect-js/no-derived-state": "error",
139
- "react-you-might-not-need-an-effect-js/no-empty-effect": "error",
140
124
  "react-you-might-not-need-an-effect-js/no-event-handler": "error",
141
125
  "react-you-might-not-need-an-effect-js/no-initialize-state": "error",
142
126
  "react-you-might-not-need-an-effect-js/no-pass-data-to-parent": "error",
@@ -148,31 +132,12 @@ export const lintCatalog = [
148
132
  },
149
133
  {
150
134
  id: "next-core",
151
- description: "Next.js correctness rules for the main web application.",
152
- plugins: ["nextjs"],
135
+ description: "Ultracite Next.js preset for the main web application.",
136
+ oxlintPresets: ["next"],
137
+ plugins: [],
153
138
  jsPlugins: [],
154
139
  settings: {},
155
- rules: {
156
- "nextjs/inline-script-id": "error",
157
- "nextjs/next-script-for-ga": "error",
158
- "nextjs/no-assign-module-variable": "error",
159
- "nextjs/no-async-client-component": "error",
160
- "nextjs/no-before-interactive-script-outside-document": "error",
161
- "nextjs/no-css-tags": "error",
162
- "nextjs/no-document-import-in-page": "error",
163
- "nextjs/no-duplicate-head": "error",
164
- "nextjs/no-head-element": "error",
165
- "nextjs/no-head-import-in-document": "error",
166
- "nextjs/no-html-link-for-pages": "error",
167
- "nextjs/no-img-element": "error",
168
- "nextjs/no-page-custom-font": "error",
169
- "nextjs/no-script-component-in-head": "error",
170
- "nextjs/no-styled-jsx-in-document": "error",
171
- "nextjs/no-sync-scripts": "error",
172
- "nextjs/no-title-in-document-head": "error",
173
- "nextjs/no-typos": "error",
174
- "nextjs/no-unwanted-polyfillio": "error",
175
- },
140
+ rules: {},
176
141
  requiredDevDependencies: [],
177
142
  placement: {
178
143
  ...webOnlyPlacement,
@@ -182,25 +147,13 @@ export const lintCatalog = [
182
147
  },
183
148
  {
184
149
  id: "tanstack-query-core",
185
- description: "TanStack Query rules via the Oxlint JS plugin bridge.",
150
+ description: "Ultracite TanStack preset for query/router/start framework linting.",
151
+ oxlintPresets: ["tanstack"],
186
152
  plugins: [],
187
- jsPlugins: [
188
- {
189
- name: "tanstack-query-js",
190
- specifier: "@tanstack/eslint-plugin-query",
191
- },
192
- ],
153
+ jsPlugins: [],
193
154
  settings: {},
194
- rules: {
195
- "tanstack-query-js/exhaustive-deps": "error",
196
- "tanstack-query-js/infinite-query-property-order": "error",
197
- "tanstack-query-js/mutation-property-order": "error",
198
- "tanstack-query-js/no-rest-destructuring": "warn",
199
- "tanstack-query-js/no-unstable-deps": "error",
200
- "tanstack-query-js/no-void-query-fn": "error",
201
- "tanstack-query-js/stable-query-client": "error",
202
- },
203
- requiredDevDependencies: ["@tanstack/eslint-plugin-query"],
155
+ rules: {},
156
+ requiredDevDependencies: [],
204
157
  placement: {
205
158
  ...webOnlyPlacement,
206
159
  placementNotes:
@@ -210,6 +163,7 @@ export const lintCatalog = [
210
163
  {
211
164
  id: "effect-no-barrel-imports",
212
165
  description: "Effect architectural rule that blocks barrel-package imports.",
166
+ oxlintPresets: [],
213
167
  plugins: [],
214
168
  jsPlugins: [
215
169
  {
@@ -231,20 +185,12 @@ export const lintCatalog = [
231
185
  },
232
186
  {
233
187
  id: "vitest-core",
234
- description: "Vitest-focused test rules for repo-owned test globs.",
235
- plugins: ["vitest"],
188
+ description: "Ultracite Vitest preset for repo-owned test globs.",
189
+ oxlintPresets: ["vitest"],
190
+ plugins: [],
236
191
  jsPlugins: [],
237
- settings: {
238
- vitest: {
239
- typecheck: false,
240
- },
241
- },
242
- rules: {
243
- "vitest/consistent-each-for": "warn",
244
- "vitest/no-conditional-tests": "error",
245
- "vitest/no-import-node-test": "error",
246
- "vitest/warn-todo": "warn",
247
- },
192
+ settings: {},
193
+ rules: {},
248
194
  requiredDevDependencies: [],
249
195
  placement: vitestPlacement,
250
196
  },
@@ -205,7 +205,7 @@ export const packCatalog = [
205
205
  triggerPackages: ["react", "react-dom"],
206
206
  description: "React guidance pack.",
207
207
  skills: ["async-react-patterns", "vercel-composition-patterns", "vercel-react-best-practices"],
208
- lintAssets: ["react-core", "react-hooks", "react-you-might-not-need-an-effect"],
208
+ lintAssets: ["react-core", "react-you-might-not-need-an-effect"],
209
209
  hooks: [],
210
210
  promptSurfaces: ["shared-agents", "root-prompt-spec", "workspace-prompt-spec"],
211
211
  promptDetails: ["shared react structure baseline", "workspace react composition rules"],
@@ -214,8 +214,9 @@ export const packCatalog = [
214
214
  id: "research",
215
215
  category: "default",
216
216
  triggerPackages: [],
217
- description: "Default research pack: parallel research, review, and architecture inspection.",
218
- skills: ["parallel-research", "review-phase", "improve-codebase-architecture"],
217
+ description:
218
+ "Default research pack: parallel research, structured review, and architecture inspection.",
219
+ skills: ["parallel-research", "review-phase", "autoreview", "improve-codebase-architecture"],
219
220
  lintAssets: [],
220
221
  hooks: [],
221
222
  promptSurfaces: ["shared-agents", "root-prompt-spec", "workspace-prompt-spec"],
@@ -299,7 +300,7 @@ export const packCatalog = [
299
300
  "python-testing-patterns",
300
301
  ],
301
302
  lintAssets: [],
302
- hooks: [],
303
+ hooks: ["format-edited-file"],
303
304
  promptSurfaces: [],
304
305
  promptDetails: [],
305
306
  },
@@ -324,6 +324,14 @@ export const skillCatalog = [
324
324
  framework: null,
325
325
  requiresTools: [],
326
326
  },
327
+ {
328
+ id: "autoreview",
329
+ sourceDirectory: "skills/agnostic/quality/autoreview",
330
+ tier: "agnostic",
331
+ language: null,
332
+ framework: null,
333
+ requiresTools: [],
334
+ },
327
335
  {
328
336
  id: "simplify",
329
337
  sourceDirectory: "skills/agnostic/quality/simplify",
@@ -7,11 +7,25 @@ import path from "node:path";
7
7
  import { spawnSync } from "node:child_process";
8
8
  import { fileURLToPath } from "node:url";
9
9
 
10
- const formattableSuffixes = new Set([".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".json"]);
11
- const lintableSuffixes = new Set([".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"]);
10
+ const javascriptFormattableSuffixes = new Set([
11
+ ".ts",
12
+ ".tsx",
13
+ ".js",
14
+ ".jsx",
15
+ ".mjs",
16
+ ".cjs",
17
+ ".json",
18
+ ]);
19
+ const javascriptLintableSuffixes = new Set([".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"]);
20
+ const pythonFormattableSuffixes = new Set([".py"]);
21
+ const formattableSuffixes = new Set([
22
+ ...javascriptFormattableSuffixes,
23
+ ...pythonFormattableSuffixes,
24
+ ]);
12
25
  const ignoredParts = new Set([".git", "node_modules", ".next", "dist"]);
13
26
  const productRoots = new Set(["apps", "packages"]);
14
27
  const packageManagers = new Set(["bun", "pnpm", "npm", "yarn"]);
28
+ const backendWorkspaceSegments = new Set(["api", "backend", "server", "services"]);
15
29
 
16
30
  function readStdinJson() {
17
31
  try {
@@ -69,10 +83,14 @@ function isLintablePath(relativePath) {
69
83
  return (
70
84
  parts.length > 0 &&
71
85
  productRoots.has(parts[0]) &&
72
- lintableSuffixes.has(path.extname(relativePath))
86
+ javascriptLintableSuffixes.has(path.extname(relativePath))
73
87
  );
74
88
  }
75
89
 
90
+ function isPythonPath(relativePath) {
91
+ return pythonFormattableSuffixes.has(path.extname(relativePath));
92
+ }
93
+
76
94
  function runCommand(root, args, stdio = "ignore") {
77
95
  const result = spawnSync(args[0], args.slice(1), {
78
96
  cwd: root,
@@ -174,6 +192,60 @@ function toolCommand(root, tool, args) {
174
192
  return ["npx", tool, ...args];
175
193
  }
176
194
 
195
+ function nearestPythonProject(root, relativePath) {
196
+ const parts = relativePath.split("/");
197
+
198
+ for (let index = parts.length - 1; index > 0; index -= 1) {
199
+ const projectPath = parts.slice(0, index).join("/");
200
+ if (existsSync(path.join(root, projectPath, "pyproject.toml"))) {
201
+ return projectPath;
202
+ }
203
+ }
204
+
205
+ if (parts.length >= 2 && productRoots.has(parts[0]) && backendWorkspaceSegments.has(parts[1])) {
206
+ return `${parts[0]}/${parts[1]}`;
207
+ }
208
+
209
+ return ".";
210
+ }
211
+
212
+ function formatCommandForPath(root, relativePath) {
213
+ if (isPythonPath(relativePath)) {
214
+ return [
215
+ "uv",
216
+ "run",
217
+ "--project",
218
+ nearestPythonProject(root, relativePath),
219
+ "ruff",
220
+ "format",
221
+ relativePath,
222
+ ];
223
+ }
224
+
225
+ return toolCommand(root, "oxfmt", ["--write", relativePath]);
226
+ }
227
+
228
+ function lintCommandForPath(root, relativePath) {
229
+ if (isPythonPath(relativePath)) {
230
+ return [
231
+ "uv",
232
+ "run",
233
+ "--project",
234
+ nearestPythonProject(root, relativePath),
235
+ "ruff",
236
+ "check",
237
+ "--fix",
238
+ relativePath,
239
+ ];
240
+ }
241
+
242
+ if (!isLintablePath(relativePath)) {
243
+ return null;
244
+ }
245
+
246
+ return toolCommand(root, "oxlint", [relativePath]);
247
+ }
248
+
177
249
  function formatAndLintFiles(root, filePaths) {
178
250
  const normalizedFiles = [];
179
251
 
@@ -189,7 +261,7 @@ function formatAndLintFiles(root, filePaths) {
189
261
  const lintFailed = [];
190
262
 
191
263
  for (const relativePath of normalizedFiles) {
192
- const formattedOk = runCommand(root, toolCommand(root, "oxfmt", ["--write", relativePath])).ok;
264
+ const formattedOk = runCommand(root, formatCommandForPath(root, relativePath)).ok;
193
265
 
194
266
  if (!formattedOk) {
195
267
  formatFailed.push(relativePath);
@@ -198,10 +270,8 @@ function formatAndLintFiles(root, filePaths) {
198
270
 
199
271
  formatted.push(relativePath);
200
272
 
201
- if (
202
- isLintablePath(relativePath) &&
203
- !runCommand(root, toolCommand(root, "oxlint", ["-c", ".oxlintrc.json", relativePath])).ok
204
- ) {
273
+ const lintCommand = lintCommandForPath(root, relativePath);
274
+ if (lintCommand !== null && !runCommand(root, lintCommand).ok) {
205
275
  lintFailed.push(relativePath);
206
276
  }
207
277
  }
@@ -594,6 +664,8 @@ export const FormatAndLintPlugin = async ({ client, worktree }) => {
594
664
  };
595
665
 
596
666
  export const testHooks = {
667
+ formatCommandForPath,
668
+ lintCommandForPath,
597
669
  toolCommand,
598
670
  };
599
671
 
@@ -1,4 +1,4 @@
1
- import { mkdtempSync, writeFileSync } from "node:fs";
1
+ import { mkdirSync, mkdtempSync, writeFileSync } from "node:fs";
2
2
  import { tmpdir } from "node:os";
3
3
  import path from "node:path";
4
4
 
@@ -12,6 +12,11 @@ type HookModule = {
12
12
  tool: string,
13
13
  args: ReadonlyArray<string>,
14
14
  ) => ReadonlyArray<string>;
15
+ readonly formatCommandForPath?: (root: string, relativePath: string) => ReadonlyArray<string>;
16
+ readonly lintCommandForPath?: (
17
+ root: string,
18
+ relativePath: string,
19
+ ) => ReadonlyArray<string> | null;
15
20
  };
16
21
  };
17
22
 
@@ -24,6 +29,7 @@ const tempRepo = (files: Record<string, string>) => {
24
29
  const root = mkdtempSync(path.join(tmpdir(), "dp-hook-test-"));
25
30
 
26
31
  for (const [filePath, content] of Object.entries(files)) {
32
+ mkdirSync(path.dirname(path.join(root, filePath)), { recursive: true });
27
33
  writeFileSync(path.join(root, filePath), content);
28
34
  }
29
35
 
@@ -51,8 +57,36 @@ describe("scaffolded hooks", () => {
51
57
  "pnpm-lock.yaml": "",
52
58
  }),
53
59
  "oxlint",
54
- ["-c", ".oxlintrc.json", "src/index.ts"],
60
+ ["src/index.ts"],
55
61
  ),
56
- ).toEqual(["pnpm", "exec", "oxlint", "-c", ".oxlintrc.json", "src/index.ts"]);
62
+ ).toEqual(["pnpm", "exec", "oxlint", "src/index.ts"]);
63
+ });
64
+
65
+ it("routes Python backend files through Ruff in their project", async () => {
66
+ const { testHooks } = await loadHookModule("format-edited-file.mjs");
67
+ const root = tempRepo({
68
+ "apps/backend/pyproject.toml": '[project]\nname = "backend"\n',
69
+ "apps/backend/main.py": "print('hi')\n",
70
+ });
71
+
72
+ expect(testHooks.formatCommandForPath?.(root, "apps/backend/main.py")).toEqual([
73
+ "uv",
74
+ "run",
75
+ "--project",
76
+ "apps/backend",
77
+ "ruff",
78
+ "format",
79
+ "apps/backend/main.py",
80
+ ]);
81
+ expect(testHooks.lintCommandForPath?.(root, "apps/backend/main.py")).toEqual([
82
+ "uv",
83
+ "run",
84
+ "--project",
85
+ "apps/backend",
86
+ "ruff",
87
+ "check",
88
+ "--fix",
89
+ "apps/backend/main.py",
90
+ ]);
57
91
  });
58
92
  });
@@ -40,6 +40,7 @@ const opencodeDir = path.join(repoRoot, ".opencode");
40
40
  const opencodeAgentsDir = path.join(opencodeDir, "agents");
41
41
  const opencodePluginsDir = path.join(opencodeDir, "plugins");
42
42
  const opencodeAgentsMirrorPath = path.join(opencodeDir, "AGENTS.md");
43
+ const opencodeConfigPath = path.join(repoRoot, "opencode.json");
43
44
 
44
45
  const managedHeader = [
45
46
  "# Generated by scripts/sync-subagents.mjs.",
@@ -124,6 +125,38 @@ function buildCursorHooksConfig({ hasFormatHook }) {
124
125
  };
125
126
  }
126
127
 
128
+ function buildOpenCodeConfig(existingConfig, { hasFormatHook }) {
129
+ const config = { ...existingConfig };
130
+
131
+ if (hasFormatHook) {
132
+ config.formatter = {
133
+ ...(typeof config.formatter === "object" && config.formatter !== null
134
+ ? config.formatter
135
+ : {}),
136
+ "harness-format-edited-file": {
137
+ command: ["node", ".agents/hooks/format-edited-file.mjs", "files", "$FILE"],
138
+ extensions: [".js", ".jsx", ".ts", ".tsx", ".mjs", ".cjs", ".json", ".py"],
139
+ },
140
+ };
141
+ }
142
+
143
+ return {
144
+ $schema: "https://opencode.ai/config.json",
145
+ ...config,
146
+ };
147
+ }
148
+
149
+ async function readJsonFile(filePath) {
150
+ try {
151
+ return JSON.parse(await readFile(filePath, "utf8"));
152
+ } catch (error) {
153
+ if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") {
154
+ return {};
155
+ }
156
+ throw error;
157
+ }
158
+ }
159
+
127
160
  function getSkillNames(agent) {
128
161
  if (Array.isArray(agent.skills)) {
129
162
  return [...new Set(agent.skills)];
@@ -400,6 +433,13 @@ async function main() {
400
433
  "utf8",
401
434
  );
402
435
  await writeFile(cursorHooksJsonPath, encodeJson(buildCursorHooksConfig(availableHooks)), "utf8");
436
+ if (availableHooks.hasFormatHook || (await pathExists(opencodeConfigPath))) {
437
+ await writeFile(
438
+ opencodeConfigPath,
439
+ encodeJson(buildOpenCodeConfig(await readJsonFile(opencodeConfigPath), availableHooks)),
440
+ "utf8",
441
+ );
442
+ }
403
443
  await writeManagedFiles(claudeAgentsDir, "md", claudeFiles);
404
444
  await writeManagedFiles(codexAgentsDir, "toml", codexFiles);
405
445
  await writeManagedFiles(cursorAgentsDir, "md", cursorFiles);