@anureo/refactor 0.3.7 → 0.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anureo/refactor",
3
- "version": "0.3.7",
3
+ "version": "0.3.9",
4
4
  "description": "Graph-assisted code refactoring with parallel agents in separate Git worktrees",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -9,40 +9,40 @@
9
9
  "directory": "apps/refactor"
10
10
  },
11
11
  "publishConfig": {
12
- "access": "public"
13
- },
14
- "type": "module",
15
- "exports": {
16
- ".": "./src/index.ts"
17
- },
18
- "bin": {
19
- "anureo-refactor": "./bin/anureo-refactor.ts"
20
- },
21
- "scripts": {
22
- "build": "tsc --noEmit",
23
- "typecheck": "tsc --noEmit --pretty false",
24
- "test": "bun test tests"
25
- },
26
- "dependencies": {
27
- "@anureo/adapter-acp": "0.3.7",
28
- "@anureo/adapter-ahp": "0.3.7",
29
- "@anureo/adapter-claude": "0.3.7",
30
- "@anureo/adapter-codex": "0.3.7",
31
- "@anureo/adapter-hermes": "0.3.7",
32
- "@anureo/adapter-pi": "0.3.7",
33
- "@anureo/sdk": "0.3.7",
34
- "@anureo/workflow": "0.3.7",
35
- "zod": "4.6.7"
36
- },
37
- "optionalDependencies": {
38
- "@youichi/repograph": "0.1.1"
39
- },
40
- "devDependencies": {
41
- "@anureo/conformance": "0.3.7",
42
- "@anureo/protocol": "0.3.7"
43
- },
44
- "engines": {
45
- "node": ">=22",
46
- "bun": ">=1.4.2"
47
- }
12
+ "access": "public"
13
+ },
14
+ "type": "module",
15
+ "exports": {
16
+ ".": "./src/index.ts"
17
+ },
18
+ "bin": {
19
+ "anureo-refactor": "./bin/anureo-refactor.ts"
20
+ },
21
+ "scripts": {
22
+ "build": "tsc --noEmit",
23
+ "typecheck": "tsc --noEmit --pretty false",
24
+ "test": "bun test tests"
25
+ },
26
+ "dependencies": {
27
+ "@anureo/adapter-acp": "0.3.9",
28
+ "@anureo/adapter-ahp": "0.3.9",
29
+ "@anureo/adapter-claude": "0.3.9",
30
+ "@anureo/adapter-codex": "0.3.9",
31
+ "@anureo/adapter-hermes": "0.3.9",
32
+ "@anureo/adapter-pi": "0.3.9",
33
+ "@anureo/sdk": "0.3.9",
34
+ "@anureo/workflow": "0.3.9",
35
+ "zod": "4.6.7"
36
+ },
37
+ "optionalDependencies": {
38
+ "@youichi/repograph": "0.1.1"
39
+ },
40
+ "devDependencies": {
41
+ "@anureo/conformance": "0.3.9",
42
+ "@anureo/protocol": "0.3.9"
43
+ },
44
+ "engines": {
45
+ "node": ">=22",
46
+ "bun": ">=1.4.2"
47
+ }
48
48
  }
package/src/checks.ts CHANGED
@@ -59,12 +59,12 @@ export async function defaultChecks(cwd: string): Promise<CheckCommand[]> {
59
59
  * runAgentWork awaits this before merging and records rejection as a failed step.
60
60
  * Commands may modify files or start other processes.
61
61
  * Resolves void after all checks; the first failed command is recorded before rejection and stops
62
- * later commands. Each process has a five-minute timeout and an eight-MiB
62
+ * later commands. Each process has a fifteen-minute timeout and an eight-MiB
63
63
  * limit on each output stream. Reports concatenate stdout then stderr, followed by the error
64
64
  * message on failure, and retain only the final 4,000 characters. An empty command list resolves
65
65
  * without changing results; existing entries are retained. */
66
66
  export async function runChecks(cwd: string, commands: readonly CheckCommand[], results: CheckResult[]): Promise<void> {
67
- const limits = { cwd, env: checkoutEnvironment(), maxBuffer: 8 << 20, timeout: 300_000, killSignal: 'SIGKILL' as const, windowsHide: true }
67
+ const limits = { cwd, env: checkoutEnvironment(), maxBuffer: 8 << 20, timeout: 900_000, killSignal: 'SIGKILL' as const, windowsHide: true }
68
68
  for (const command of commands) {
69
69
  const display = typeof command === 'string' ? command : [command.executable, ...(command.args ?? [])]
70
70
  .map(arg => /^[\w./:-]+$/.test(arg) ? arg : JSON.stringify(arg)).join(' ')
package/src/errors.ts CHANGED
@@ -1,15 +1,6 @@
1
1
  // Normalizes caught errors for reports and diagnostics.
2
2
  import type { Failure } from './results'
3
3
 
4
- declare module './results' {
5
- interface Failure {
6
- /** Whether the source error permits a retry. May be absent in older reports. */
7
- retryable?: boolean
8
- /** Field paths and rule codes from structured-output validation. */
9
- issues?: Array<{ path: string | Array<string | number>; code: string }>
10
- }
11
- }
12
-
13
4
  /** Convert a caught value for display, including values with throwing accessors or conversions. */
14
5
  export function message(cause: unknown): string {
15
6
  try {
package/src/results.ts CHANGED
@@ -15,6 +15,10 @@ export interface Failure {
15
15
  outcomeUnknown: boolean
16
16
  /** A resource-release error was reported, independently of execution outcome. */
17
17
  cleanupFailed: boolean
18
+ /** Whether the source error permits a retry. May be absent in older reports. */
19
+ retryable?: boolean
20
+ /** Field paths and rule codes from structured-output validation. */
21
+ issues?: Array<{ path: string | Array<string | number>; code: string }>
18
22
  }
19
23
  /** Outcome of a design or module step, including host observations from integration and validation.
20
24
  * The inherited summary, changes and deferred fields are the agent's account of the work. */
@@ -32,9 +32,14 @@ const sourceOnlyExclusions = new Set(['.repograph', 'node_modules', 'dist', 'bui
32
32
  /** Repository metadata and conventional standalone prose. Explicit includes can select these files. */
33
33
  const supportingFile = /^(?:\.(?:gitignore|gitattributes|gitmodules|editorconfig)|package(?:-lock)?\.json|(?:bun|yarn|Cargo|uv|poetry)\.lockb?|pnpm-lock\.ya?ml|(?:README|LICENSE|LICENCE|COPYING|NOTICE|CHANGELOG|CONTRIBUTING|AGENTS)(?:\.(?:md|txt|rst|adoc))?)$/i
34
34
 
35
- /** Match hard exclusions against any path component, regardless of case or glob settings. */
35
+ /** Match hard exclusions against the leading path component, regardless of case or glob settings.
36
+ * Conventional output, dependency and prose directories are excluded at the repository root; the
37
+ * same names stay eligible as nested implementation module names (for example a Rust `build`
38
+ * module directory inside a crate). */
36
39
  function isExcluded(file: string): boolean {
37
- return !isSnapshotPath(file) || file.split('/').some(part => sourceOnlyExclusions.has(part.toLowerCase()))
40
+ if (!isSnapshotPath(file)) return false
41
+ const [root = ''] = file.split('/')
42
+ return sourceOnlyExclusions.has(root.toLowerCase())
38
43
  }
39
44
 
40
45
  /** Default to UTF-8 unless a UTF-16 byte-order mark is present. Decode strictly so invalid
package/src/worktree.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  // Materializes Git-visible source and transfers edits between independent worktrees.
2
2
  import { constants } from 'node:fs'
3
- import { copyFile, cp, link, lstat, mkdir, mkdtemp, readdir, readlink, realpath, rename, rm, rmdir, symlink, writeFile } from 'node:fs/promises'
3
+ import { copyFile, cp, link, lstat, mkdir, mkdtemp, readdir, readlink, realpath, rename, rm, rmdir, stat, symlink, writeFile } from 'node:fs/promises'
4
4
  import { tmpdir } from 'node:os'
5
5
  import { basename, dirname, isAbsolute, join, relative, sep } from 'node:path'
6
6
  import { inspectGitPath, isSnapshotPath } from './git-path'
@@ -141,28 +141,40 @@ export async function prepareCheckDependencies(baseline: WorktreeBaseline, workt
141
141
  }
142
142
  }
143
143
 
144
+ /** Copy an installed dependency tree into the checkout. Real entries copy recursively and every
145
+ * link is recreated with a rebased target and a type matching its destination. */
144
146
  async function copyDependencies(from: string, to: string, sourceRoot: string, targetRoot: string): Promise<void> {
145
- await cp(from, to, { recursive: true, verbatimSymlinks: true, mode: constants.COPYFILE_FICLONE })
146
- await rebaseDependencyLinks(to, sourceRoot, targetRoot)
147
+ await mkdir(to, { recursive: true })
148
+ for (const entry of await readdir(from, { withFileTypes: true })) {
149
+ const source = join(from, entry.name)
150
+ const destination = join(to, entry.name)
151
+ if (entry.isSymbolicLink()) await copyDependencyLink(source, destination, sourceRoot, targetRoot)
152
+ else if (entry.isDirectory()) await copyDependencies(source, destination, sourceRoot, targetRoot)
153
+ else await copyFile(source, destination, constants.COPYFILE_FICLONE)
154
+ }
147
155
  }
148
156
 
149
- async function rebaseDependencyLinks(directory: string, source: string, target: string): Promise<void> {
150
- for (const entry of await readdir(directory, { withFileTypes: true })) {
151
- const path = join(directory, entry.name)
152
- if (entry.isDirectory()) await rebaseDependencyLinks(path, source, target)
153
- else if (entry.isSymbolicLink()) {
154
- const link = await readlink(path)
155
- if (!isAbsolute(link)) continue
156
- const absolute = await realpath(path).catch((cause: NodeJS.ErrnoException) => {
157
- if (cause.code !== 'ENOENT' && cause.code !== 'ELOOP') throw cause
158
- return link
159
- })
160
- const rebased = rebaseDependencyLink(absolute, source, target)
161
- if (rebased === absolute) continue
162
- await rm(path)
163
- await symlink(rebased, path)
164
- }
157
+ /** Rebase one dependency link into the target checkout and recreate it with an absolute target
158
+ * and an explicit type: 'dir' stays readable as a directory and traversable by module resolution
159
+ * even when the target is copied later in the same walk, and Git worktree removal deletes it
160
+ * without following. The runtime's typeless creation stores a 'file' link when the target is
161
+ * absent, which never becomes traversable after the target arrives. Verbatim copying breaks
162
+ * Windows directory links whose stored target ascends through '..' segments, which is how bun's
163
+ * isolated .bun layout links shared packages: the copy loses its directory type and resolution
164
+ * fails. A broken source link keeps its stored target so resolution stays observable. */
165
+ async function copyDependencyLink(source: string, destination: string, sourceRoot: string, targetRoot: string): Promise<void> {
166
+ const stored = await readlink(source)
167
+ const resolved = await realpath(source).catch((cause: NodeJS.ErrnoException) => {
168
+ if (cause.code !== 'ENOENT' && cause.code !== 'ELOOP') throw cause
169
+ return undefined
170
+ })
171
+ if (resolved === undefined) {
172
+ await symlink(stored, destination)
173
+ return
165
174
  }
175
+ const rebased = rebaseDependencyLink(resolved, sourceRoot, targetRoot)
176
+ if ((await stat(resolved)).isDirectory()) await symlink(rebased, destination, 'dir')
177
+ else await symlink(rebased, destination, 'file')
166
178
  }
167
179
 
168
180
  function rebaseDependencyLink(link: string, source: string, target: string): string {
File without changes
@@ -376,8 +376,9 @@ test('the plan checkpoint is published before either module starts', async () =>
376
376
  expect(saved.plan).toBeNull()
377
377
  return plan
378
378
  }
379
+ // Modules run concurrently and each completion republishes the whole report, so a later-starting
380
+ // module may already see its sibling's results; only the plan checkpoint is guaranteed on start.
379
381
  expect(saved.plan).toEqual(plan)
380
- expect(saved.modules).toEqual([])
381
382
  return unchanged
382
383
  })
383
384
  const report = await refactorCode({ ...context, checks: [],