genaicode 2.7.0 → 2.8.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,56 @@
1
+ Bundled license information:
2
+
3
+ react/cjs/react.production.js:
4
+ /**
5
+ * @license React
6
+ * react.production.js
7
+ *
8
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
9
+ *
10
+ * This source code is licensed under the MIT license found in the
11
+ * LICENSE file in the root directory of this source tree.
12
+ */
13
+
14
+ scheduler/cjs/scheduler.production.js:
15
+ /**
16
+ * @license React
17
+ * scheduler.production.js
18
+ *
19
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
20
+ *
21
+ * This source code is licensed under the MIT license found in the
22
+ * LICENSE file in the root directory of this source tree.
23
+ */
24
+
25
+ react-dom/cjs/react-dom.production.js:
26
+ /**
27
+ * @license React
28
+ * react-dom.production.js
29
+ *
30
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
31
+ *
32
+ * This source code is licensed under the MIT license found in the
33
+ * LICENSE file in the root directory of this source tree.
34
+ */
35
+
36
+ react-dom/cjs/react-dom-client.production.js:
37
+ /**
38
+ * @license React
39
+ * react-dom-client.production.js
40
+ *
41
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
42
+ *
43
+ * This source code is licensed under the MIT license found in the
44
+ * LICENSE file in the root directory of this source tree.
45
+ */
46
+
47
+ react/cjs/react-jsx-runtime.production.js:
48
+ /**
49
+ * @license React
50
+ * react-jsx-runtime.production.js
51
+ *
52
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
53
+ *
54
+ * This source code is licensed under the MIT license found in the
55
+ * LICENSE file in the root directory of this source tree.
56
+ */
package/docs/agents.md CHANGED
@@ -74,6 +74,46 @@ failure of its own. A zero exit alone is not treated as success.
74
74
 
75
75
  Vendor events that have no mapping are dropped.
76
76
 
77
+ ## Follow-up turns
78
+
79
+ `result.sessionId` names the agent's own session. Pass it as `resume` to continue that
80
+ session with a new prompt; the agent keeps the earlier turns as context:
81
+
82
+ ```ts
83
+ const agent = claude();
84
+ const first = await agent.run({ prompt: 'Add a --dry-run flag', cwd }).result;
85
+ const next = await agent.run({ prompt: 'Now cover it with a test', cwd, resume: first.sessionId }).result;
86
+ ```
87
+
88
+ `claude`, `codex`, `cursor`, `opencode` and `copilot` support it (`capabilities.resume`).
89
+ Other drivers fail the task before spawning anything rather than starting a fresh session.
90
+
91
+ ## Chat sessions
92
+
93
+ `createAgentSession` keeps a conversation with one agent for chat front ends; the
94
+ `genaicode chat` and `genaicode ui` commands are built on it:
95
+
96
+ ```ts
97
+ import { claude, createAgentSession } from 'genaicode/agents';
98
+
99
+ const session = createAgentSession({ agent: claude(), cwd: '/work/repo' });
100
+ session.subscribe((state) => render(state)); // a new immutable snapshot on every change
101
+ session.send('Add a --dry-run flag');
102
+ await session.idle();
103
+ session.send('Now cover it with a test'); // resumes the same agent session
104
+ ```
105
+
106
+ - `state.turns[]` holds each prompt with its transcript: `text` (streamed, then final),
107
+ `tool` (input, clipped output, error flag), `files`, `approval`, `input` (steered text)
108
+ and `error` entries, plus the turn's `AgentResult`. Usage and cost add up in `state`.
109
+ - `send()` while a turn runs steers the agent when it supports `steer()`, and otherwise
110
+ queues the prompt; queued prompts run in order. `stop()` aborts the turn and clears the
111
+ queue.
112
+ - Approval requests wait in `state.approvals` until `approve(id, decision)`, unless
113
+ `autoApprove` decides them. `stop()` denies whatever is pending.
114
+ - `setAgent()` switches agents between turns and starts a fresh agent session; `reset()`
115
+ does the same for the current agent.
116
+
77
117
  ## Drivers
78
118
 
79
119
  | Driver | Command | Mode | Notes |
package/docs/pivot.md CHANGED
@@ -44,9 +44,10 @@ The following 1.x capabilities are intentionally removed:
44
44
  The 2.x `genaicode/agents` subpath does not restore these. It drives _external_
45
45
  coding-agent CLIs behind one task/event interface, the same way providers wrap model APIs,
46
46
  and it adds no agent loop, prompts, or repository tools of its own. See [agents.md](./agents.md).
47
- The `genaicode` bin (`npx genaicode run`) is a thin command-line front end to those drivers,
48
- under the same rule: it parses flags, prints events, and adds nothing the library does not
49
- already do.
47
+ The `genaicode` bin (`npx genaicode run`, `chat`, `ui`) is a thin front end to those drivers,
48
+ under the same rule: it parses flags, shows events, and adds nothing the library does not
49
+ already do. Its terminal and browser chat are bundled (Ink, React) into `dist/ui` and load
50
+ only for those commands, so the library keeps no UI dependencies.
50
51
 
51
52
  This is a major-version break. The old implementation remains available in git history
52
53
  and in the 1.x npm line.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "genaicode",
3
- "version": "2.7.0",
3
+ "version": "2.8.0",
4
4
  "description": "A small, provider-neutral TypeScript toolkit for calling LLMs from backend code.",
5
5
  "author": "Grzegorz Tańczyk",
6
6
  "repository": {
@@ -49,8 +49,8 @@
49
49
  },
50
50
  "scripts": {
51
51
  "clean": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
52
- "build": "npm run clean && tsc -p tsconfig.build.json",
53
- "lint": "eslint . --ext js,ts --report-unused-disable-directives --max-warnings 0",
52
+ "build": "npm run clean && tsc -p tsconfig.build.json && node scripts/build-ui.mjs",
53
+ "lint": "eslint . --ext js,ts,tsx --report-unused-disable-directives --max-warnings 0",
54
54
  "test": "vitest --config vitest.unit.config.ts --run",
55
55
  "test:e2e": "vitest --config vitest.e2e.config.ts --run",
56
56
  "test:watch": "vitest --config vitest.unit.config.ts",
@@ -66,13 +66,20 @@
66
66
  },
67
67
  "devDependencies": {
68
68
  "@types/node": "^20.0.0",
69
+ "@types/react": "^19.3.0",
70
+ "@types/react-dom": "^19.3.0",
69
71
  "@typescript-eslint/eslint-plugin": "^7.17.0",
70
72
  "@typescript-eslint/parser": "^7.17.0",
73
+ "esbuild": "^0.28.2",
71
74
  "eslint": "^8.54.0",
72
75
  "eslint-config-prettier": "^9.0.0",
73
76
  "husky": "^9.1.1",
77
+ "ink": "^6.8.0",
78
+ "ink-testing-library": "^4.0.0",
74
79
  "lint-staged": "^15.2.7",
75
80
  "prettier": "^3.1.0",
81
+ "react": "^19.3.0",
82
+ "react-dom": "^19.3.0",
76
83
  "typescript": "^5.0.0",
77
84
  "vite": "^6.4.1",
78
85
  "vitest": "^3.0.7"