Skip to content

Commit 1cabe30

Browse files
chore: upgrade to React 19 and Ink 8, drop the ink patch script (#76)
* chore: upgrade to React 19 and Ink 6 Prerequisite for the upcoming `codify prompt` chat UI, which is built on @assistant-ui/react-ink (requires react ^19 and ink >=6). - react 18 -> 19.2, ink 5 -> 6.8, ink-gradient 3 -> 4, @types/react 19, react-devtools-core 6. Ink 6.8 is the newest line that still supports Node 20 (ink 7+ requires Node 22). React is pinned to ~19.2 to match the react-reconciler (0.33) that ink 6 ships with. - typescript 5.3 -> 5.9 and skipLibCheck: ink 6's type-fest 5 typings need TS >= 5.4, and TS 5.9 flags .d.ts files inside @codifycli/schemas. - Rewrite the App.js/ink.js parts of scripts/patch-ink.ts. Ink 6's App is a function component, so the stdin suspend/resume closures are registered on a `codifyStdinControl` prop instead of found by walking the fiber tree. pauseRendering now also cancels pending throttled writes, and resumeRendering forces the next frame to be written. - Wait for render state commits in DefaultReporter. React 19 no longer commits updates from outside React synchronously, so display calls that were followed by process.exit() (e.g. `codify plan`) exited before the final frame rendered. DefaultComponent now emits RENDER_STATE_COMMITTED from a layout effect and the reporter awaits it (250ms fallback). - Give <Static> width 100%: the newer yoga no longer stretches absolutely positioned boxes, which shrank the plan header box to its content. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016QnBk1T9WChsm317yyQKmh * chore: move to Ink 8 and drop the ink patch script - ink 6.8 -> 8.0, react / @types/react ~19.2 -> ~19.3 (ink 8 ships react-reconciler 0.34, which requires react ^19.3). engines.node is now >=22 because ink 8 requires Node 22. Release binaries are unaffected (oclif pack bundles Node); CI already runs on Node 22. - Delete scripts/patch-ink.ts and its postinstall, pkg.ts and build-npm.ts steps. Ink 8 natively provides suspendTerminal() (flush + erase frame, release raw mode and the stdin 'readable' listener, forced redraw on resume) and fixes the stale <Static> node bug the reconciler patch backported. - DefaultReporter hands the terminal to PTY sessions via suspendTerminal(), captured from useApp() in DefaultComponent. Verified in a PTY on Node 22 and Node 24 (which previously needed the kState workaround). Ink now restores raw mode itself on resume, which also fixes keypresses being line-buffered after a stdin handoff. - wrap='middle' -> 'wrap' in PromptPressKeyToContinue: 'middle' was never a valid value (ink 5 silently skipped wrapping), and ink 8 rejects it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016QnBk1T9WChsm317yyQKmh --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 9dd6df5 commit 1cabe30

14 files changed

Lines changed: 455 additions & 488 deletions

‎package-lock.json‎

Lines changed: 323 additions & 170 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
"detect-indent": "^7.0.1",
2222
"diff": "^8.0.3",
2323
"express": "^5.1.0",
24-
"ink": "^5.2.1",
24+
"ink": "^8.0.0",
2525
"ink-big-text": "^2.0.0",
26-
"ink-gradient": "^3.0.0",
26+
"ink-gradient": "^4.0.1",
2727
"ink-select-input": "^6.0.0",
2828
"jju": "^1.4.0",
2929
"jose": "^6.1.0",
@@ -38,7 +38,7 @@
3838
"node-pty": "1.2.0-beta.15",
3939
"open": "^10.1.2",
4040
"parse-json": "^8.1.0",
41-
"react": "^18.3.1",
41+
"react": "~19.3.0",
4242
"uuid": "^10.0.0",
4343
"ws": "^8.18.3"
4444
},
@@ -56,7 +56,7 @@
5656
"@types/json5": "^2.2.0",
5757
"@types/mocha": "^10.0.10",
5858
"@types/node": "^20",
59-
"@types/react": "^18.3.1",
59+
"@types/react": "~19.3.0",
6060
"@types/semver": "^7.8.0",
6161
"@types/strip-ansi": "^5.2.1",
6262
"@types/uuid": "^10.0.0",
@@ -69,11 +69,11 @@
6969
"ink-testing-library": "^4.0.0",
7070
"memfs": "^4.14.0",
7171
"oclif": "^6.0.10",
72-
"react-devtools-core": "4.28.5",
72+
"react-devtools-core": "^6.1.5",
7373
"shx": "^0.3.3",
7474
"strip-ansi": "^7.1.0",
7575
"tsx": "^4.7.3",
76-
"typescript": "5.3.3",
76+
"typescript": "~5.9.3",
7777
"vitest": "^4.0.18"
7878
},
7979
"overrides": {
@@ -82,7 +82,7 @@
8282
}
8383
},
8484
"engines": {
85-
"node": ">=20.0.0"
85+
"node": ">=22.0.0"
8686
},
8787
"files": [
8888
"/bin",
@@ -128,7 +128,7 @@
128128
},
129129
"repository": "codifycli/codify",
130130
"scripts": {
131-
"postinstall": "[ -f node_modules/oclif/lib/tarballs/bin.js ] && tsx scripts/patch-oclif.ts || true; [ -f dist/patch-ink.mjs ] && node dist/patch-ink.mjs || true",
131+
"postinstall": "[ -f node_modules/oclif/lib/tarballs/bin.js ] && tsx scripts/patch-oclif.ts || true",
132132
"build": "shx rm -rf dist && tsc -b",
133133
"build:release": "npm run pkg && ./scripts/notarize.sh",
134134
"lint": "tsc",

‎scripts/build-npm.ts‎

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,15 @@
11
// npm-publish prep. Runs from `prepublishOnly` (after `npm run build`).
22
//
3-
// Two npm-specific concerns the plain `tsc` build doesn't handle:
4-
//
5-
// 1. dist/patch-ink.mjs — the postinstall hook runs `node dist/patch-ink.mjs`
6-
// to patch node_modules/ink at the user's install time (needed for the raw-PTY
7-
// handoff, e.g. `gh auth login` — see scripts/patch-ink.ts). `tsc -b` only
8-
// compiles src/**/*, so this file is otherwise absent from the npm tarball and
9-
// the postinstall guard silently skips it. Compile it here (same command as
10-
// scripts/pkg.ts uses for the binary build).
11-
//
12-
// 2. README.md — npm should show a "migrated and re-purposed" blurb that the
13-
// git-tracked README must NOT carry. README.npm.md holds ONLY the blurb; we
14-
// back up the real README and prepend the blurb to it (so the body is never
15-
// duplicated). `npm run restore-npm` (via postpublish, and defensively on
16-
// failure) restores it from the backup.
3+
// The plain `tsc` build doesn't handle the README: npm should show a "migrated and
4+
// re-purposed" blurb that the git-tracked README must NOT carry. README.npm.md holds
5+
// ONLY the blurb; we back up the real README and prepend the blurb to it (so the body
6+
// is never duplicated). `npm run restore-npm` (via postpublish, and defensively on
7+
// failure) restores it from the backup.
178
//
189
// The backup file (README.md.orig) is the single source of truth for restoration,
1910
// so a failed publish never leaves README.md dirty.
2011

2112
import chalk from 'chalk'
22-
import { execSync } from 'node:child_process'
2313
import { existsSync } from 'node:fs'
2414
import fs from 'node:fs/promises'
2515

@@ -30,15 +20,7 @@ const README_BLURB = 'README.npm.md'
3020
// allowlist, and this backup is just build scratch that shouldn't ship.
3121
const README_BACKUP = '.npm-readme-backup.md'
3222

33-
// ── 1. Compile patch-ink.ts → dist/patch-ink.mjs ─────────────────────────────
34-
console.log(chalk.magenta('Compiling patch-ink.ts to dist/patch-ink.mjs'))
35-
execSync(
36-
'tsc --module nodenext --moduleResolution nodenext --target es2022 --outDir dist scripts/patch-ink.ts',
37-
{ shell: 'zsh' },
38-
)
39-
await fs.rename('dist/patch-ink.js', 'dist/patch-ink.mjs')
40-
41-
// ── 2. Prepend the npm blurb to README.md ────────────────────────────────────
23+
// ── Prepend the npm blurb to README.md ────────────────────────────────────
4224
// README.npm.md holds ONLY the blurb; we prepend it to the real README so the
4325
// body never has to be duplicated/kept in sync. `npm run restore-npm` puts the
4426
// original README.md back from the backup.

‎scripts/patch-ink.ts‎

Lines changed: 0 additions & 244 deletions
This file was deleted.

‎scripts/pkg.ts‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,6 @@ await Promise.all([
2626
fs.cp('README.md', './.build/README.md'),
2727
]);
2828

29-
console.log(chalk.magenta('Compiling patch-ink.ts to .build/dist/patch-ink.mjs'))
30-
execSync(
31-
'tsc --module nodenext --moduleResolution nodenext --target es2022 --outDir .build/dist scripts/patch-ink.ts',
32-
{ shell: 'zsh' }
33-
);
34-
await fs.rename('./.build/dist/patch-ink.js', './.build/dist/patch-ink.mjs');
35-
3629
console.log(chalk.magenta('Esbuild src'))
3730
execSync('tsx esbuild.ts', { shell: 'zsh' })
3831

0 commit comments

Comments
 (0)