Skip to content

Commit 1c26c27

Browse files
authored
Add link to cookbook (#2)
1 parent ae7b518 commit 1c26c27

3 files changed

Lines changed: 15 additions & 12 deletions

File tree

codex-cli/src/lib/text-buffer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* eslint‑disable no-bitwise */
2+
23
export type Direction =
34
| "left"
45
| "right"

codex-cli/src/utils/agent/agent-loop.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ type AgentLoopParams = {
3838
onItem: (item: ResponseItem) => void;
3939
onLoading: (loading: boolean) => void;
4040

41-
/**
42-
* Used to reach out to the user only if the command is not auto-approved.
43-
*/
41+
/** Called when the command is not auto-approved to request explicit user review. */
4442
getCommandConfirmation: (
4543
command: Array<string>,
4644
applyPatch: ApplyPatchCommand | undefined,
@@ -53,12 +51,12 @@ export class AgentLoop {
5351
private instructions?: string;
5452
private approvalPolicy: ApprovalPolicy;
5553
private config: AppConfig;
56-
// Using `InstanceType<typeof OpenAI>` sidesteps typing issues with the
57-
// OpenAI package under the TS 5+ `moduleResolution=bundler` setup.
58-
// OpenAI client instance. We keep the concrete type to avoid sprinkling
59-
// `any` across the implementation while still allowing paths where the
60-
// OpenAI SDK types may not perfectly match. The `typeof OpenAI` pattern
61-
// captures the instance shape without resorting to `any`.
54+
55+
// Using `InstanceType<typeof OpenAI>` sidesteps typing issues with the OpenAI package under
56+
// the TS 5+ `moduleResolution=bundler` setup. OpenAI client instance. We keep the concrete
57+
// type to avoid sprinkling `any` across the implementation while still allowing paths where
58+
// the OpenAI SDK types may not perfectly match. The `typeof OpenAI` pattern captures the
59+
// instance shape without resorting to `any`.
6260
private oai: OpenAI;
6361

6462
private onItem: (item: ResponseItem) => void;
@@ -688,7 +686,7 @@ export class AgentLoop {
688686
// process and surface each item (no‑op until we can depend on streaming events)
689687
if (event.type === "response.output_item.done") {
690688
const item = event.item;
691-
// if it's a reasoning item, annotate it
689+
// 1) if it's a reasoning item, annotate it
692690
type ReasoningItem = { type?: string; duration_ms?: number };
693691
const maybeReasoning = item as ReasoningItem;
694692
if (maybeReasoning.type === "reasoning") {
@@ -776,7 +774,7 @@ export class AgentLoop {
776774
// thinking times so UIs and tests can surface/verify them.
777775
// const thinkingEnd = Date.now();
778776

779-
// Per‑turn measurement – exact time spent between request and
777+
// 1) Per‑turn measurement – exact time spent between request and
780778
// response for *this* command.
781779
// this.onItem({
782780
// id: `thinking-${thinkingEnd}`,
@@ -792,7 +790,7 @@ export class AgentLoop {
792790
// ],
793791
// });
794792

795-
// Session‑wide cumulative counter so users can track overall wait
793+
// 2) Session‑wide cumulative counter so users can track overall wait
796794
// time across multiple turns.
797795
// this.cumulativeThinkingMs += thinkingEnd - thinkingStart;
798796
// this.onItem({
@@ -975,6 +973,7 @@ export class AgentLoop {
975973
}
976974

977975
const prefix = `You are operating as and within the Codex CLI, a terminal-based agentic coding assistant built by OpenAI. It wraps OpenAI models to enable natural language interaction with a local codebase. You are expected to be precise, safe, and helpful.
976+
978977
You can:
979978
- Receive user prompts, project context, and files.
980979
- Stream responses and emit function calls (e.g., shell commands, code edits).

codex-cli/src/utils/agent/apply-patch.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Based on reference implementation from
2+
// https://cookbook.openai.com/examples/gpt4-1_prompting_guide#reference-implementation-apply_patchpy
3+
14
import fs from "fs";
25
import path from "path";
36

0 commit comments

Comments
 (0)