New:Socket for Asana Is Now Available.Learn more
Get Started

internalcot

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

internalcot - npm Package Compare versions

Comparing version
0.1.1
to
0.2.0
+11
dist/observe-options.d.ts
import type { ReasoningEffort } from "./model.js";
/** Parsed options for the API-backed observation POC. */
export type ObserveOptions = {
readonly model: string;
readonly effort: ReasoningEffort;
readonly maxTurns: number;
readonly prompt: string | undefined;
readonly help: boolean;
};
/** Parse options accepted after `internalcot observe`. */
export declare function parseObserveOptions(args: ReadonlyArray<string>): ObserveOptions;
const EFFORTS = new Set(["none", "low", "medium", "high", "xhigh", "max"]);
function nextValue(args, index, option) {
const value = args[index + 1];
if (value === undefined) {
throw new Error(`${option} requires a value`);
}
return value;
}
/** Parse options accepted after `internalcot observe`. */
export function parseObserveOptions(args) {
let model = "gpt-5.6-sol";
let effort = "none";
let maxTurns = 8;
let help = false;
const promptParts = [];
for (let index = 0; index < args.length; index += 1) {
const argument = args[index];
if (argument === "--help" || argument === "-h") {
help = true;
continue;
}
if (argument === "--model" || argument === "-m") {
model = nextValue(args, index, argument);
index += 1;
continue;
}
if (argument === "--effort" || argument === "-e") {
const value = nextValue(args, index, argument);
if (!EFFORTS.has(value)) {
throw new Error(`Invalid effort: ${value}`);
}
effort = value;
index += 1;
continue;
}
if (argument === "--max-turns") {
const value = nextValue(args, index, argument);
const parsed = Number(value);
if (!Number.isSafeInteger(parsed) || parsed < 1) {
throw new Error(`Invalid max turns: ${value}`);
}
maxTurns = parsed;
index += 1;
continue;
}
if (argument?.startsWith("-")) {
throw new Error(`Unknown observe option: ${argument}`);
}
if (argument !== undefined) {
promptParts.push(argument);
}
}
return {
model,
effort,
maxTurns,
prompt: promptParts.length === 0 ? undefined : promptParts.join(" "),
help,
};
}
//# sourceMappingURL=observe-options.js.map
{"version":3,"file":"observe-options.js","sourceRoot":"","sources":["../src/observe-options.ts"],"names":[],"mappings":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Options:\n --codex Install the skill for Codex\n --claude Install the skill for Claude Code\n --cli-only Install only the persistent CLI command\n --skill-only Install only the skill (requires an existing CLI)\n -p, --project Install skills in the current project instead of globally\n -y, --yes Accept the displayed plan without prompting\n --dry-run Display the plan without changing anything\n -h, --help Show this help\n\nNon-interactive example:\n npx internalcot@latest setup --codex --yes";
export declare function runSetup(args: ReadonlyArray<string>): Promise<void>;
import { checkbox, confirm, select } from "@inquirer/prompts";
import { access } from "node:fs/promises";
import { homedir } from "node:os";
import { join } from "node:path";
import { parseSetupOptions } from "./setup-options.js";
import { applySetup, formatSetupPlan, planSetup } from "./setup.js";
export const SETUP_USAGE = `Usage: internalcot setup [options]
Install the internalcot CLI and skill for your coding agent.
Options:
--codex Install the skill for Codex
--claude Install the skill for Claude Code
--cli-only Install only the persistent CLI command
--skill-only Install only the skill (requires an existing CLI)
-p, --project Install skills in the current project instead of globally
-y, --yes Accept the displayed plan without prompting
--dry-run Display the plan without changing anything
-h, --help Show this help
Non-interactive example:
npx internalcot@latest setup --codex --yes`;
const promptContext = { output: process.stderr };
export async function runSetup(args) {
const options = parseSetupOptions(args);
if (options.help) {
process.stdout.write(`${SETUP_USAGE}\n`);
return;
}
const interactive = process.stdin.isTTY && process.stderr.isTTY && !options.yes;
const mode = options.mode ?? (interactive ? await promptForMode() : "bundle");
const targets = mode === "cli-only"
? []
: options.targets.length > 0
? options.targets
: interactive
? await promptForTargets()
: nonInteractiveTargetsRequired();
const plan = await planSetup({ mode, targets, project: options.project });
process.stderr.write(formatSetupPlan(plan));
if (options.dryRun) {
process.stdout.write("Dry run complete; no changes made.\n");
return;
}
if (interactive) {
const accepted = await confirm({ message: "Apply this setup plan?", default: true }, promptContext);
if (!accepted) {
process.stdout.write("Setup cancelled; no changes made.\n");
return;
}
}
const result = await applySetup(plan);
process.stdout.write(formatResult(result.cliInstalled, result.skillDirectories));
}
async function promptForMode() {
return select({
message: "What should internalcot install?",
choices: [
{
name: "CLI + skill (recommended)",
value: "bundle",
description: "Install the persistent command and agent instructions.",
},
{
name: "Skill only",
value: "skill-only",
description: "Use this when the internalcot command is already installed.",
},
{
name: "CLI only",
value: "cli-only",
description: "Install the command without agent instructions.",
},
],
}, promptContext);
}
async function promptForTargets() {
const home = homedir();
const [codexDetected, claudeDetected] = await Promise.all([
pathExists(join(home, ".codex")),
pathExists(join(home, ".claude")),
]);
while (true) {
const targets = await checkbox({
message: "Install the skill for:",
choices: [
{ name: detectedLabel("Codex", codexDetected), value: "codex", checked: codexDetected },
{ name: detectedLabel("Claude Code", claudeDetected), value: "claude", checked: claudeDetected },
],
}, promptContext);
if (targets.length > 0) {
return targets;
}
process.stderr.write("Select at least one agent, or press Ctrl+C to cancel.\n");
}
}
function nonInteractiveTargetsRequired() {
throw new Error("Choose a skill target in non-interactive mode. Try --codex or --claude.");
}
function detectedLabel(label, detected) {
return detected ? `${label} (detected)` : label;
}
function formatResult(cliInstalled, directories) {
const lines = ["internalcot setup complete."];
if (cliInstalled) {
lines.push("CLI: installed");
}
for (const directory of directories) {
lines.push(`Skill: ${directory}`);
}
if (directories.length > 0) {
lines.push("Next: restart your coding agent if $internalcot is not immediately available.");
}
return `${lines.join("\n")}\n`;
}
async function pathExists(path) {
try {
await access(path);
return true;
}
catch (cause) {
if (cause instanceof Error && "code" in cause && cause.code === "ENOENT") {
return false;
}
throw cause;
}
}
//# sourceMappingURL=setup-command.js.map
{"version":3,"file":"setup-command.js","sourceRoot":"","sources":["../src/setup-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,iBAAiB,EAAoC,MAAM,oBAAoB,CAAC;AACzF,OAAO,EAAE,UAAU,EA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AI,CAAC,IAAI,CAAC,IAAI,CAAC;AACjC,CAAC;AAED,KAAK,UAAU,UAAU,CAAC,IAAY;IACpC,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC;QACnB,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACxB,IAAI,KAAK,YAAY,KAAK,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACzE,OAAO,KAAK,CAAC;QACf,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
export type SetupMode = "bundle" | "cli-only" | "skill-only";
export type SetupTarget = "codex" | "claude";
export interface SetupOptions {
readonly mode: SetupMode | undefined;
readonly targets: ReadonlyArray<SetupTarget>;
readonly project: boolean;
readonly yes: boolean;
readonly dryRun: boolean;
readonly help: boolean;
}
export declare function parseSetupOptions(args: ReadonlyArray<string>): SetupOptions;
export function parseSetupOptions(args) {
let mode;
const targets = [];
let project = false;
let yes = false;
let dryRun = false;
let help = false;
for (const arg of args) {
switch (arg) {
case "--codex":
addTarget(targets, "codex");
break;
case "--claude":
addTarget(targets, "claude");
break;
case "--cli-only":
mode = setMode(mode, "cli-only");
break;
case "--skill-only":
mode = setMode(mode, "skill-only");
break;
case "--project":
case "-p":
project = true;
break;
case "--yes":
case "-y":
yes = true;
break;
case "--dry-run":
dryRun = true;
break;
case "--help":
case "-h":
help = true;
break;
default:
throw new Error(`Unknown setup option: ${arg}`);
}
}
if (mode === "cli-only" && targets.length > 0) {
throw new Error("--cli-only cannot be combined with --codex or --claude");
}
if (mode === "cli-only" && project) {
throw new Error("--project has no effect with --cli-only");
}
return { mode, targets, project, yes, dryRun, help };
}
function addTarget(targets, target) {
if (!targets.includes(target)) {
targets.push(target);
}
}
function setMode(current, next) {
if (current !== undefined && current !== next) {
throw new Error("Choose only one of --cli-only or --skill-only");
}
return next;
}
//# sourceMappingURL=setup-options.js.map
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AAK,CAAC,wDAAwD,CAAC,CAAC;IAC5E,CAAC;IACD,IAAI,IAAI,KAAK,UAAU,IAAI,OAAO,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;IAC7D,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;AACvD,CAAC;AAED,SAAS,SAAS,CAAC,OAA2B,EAAE,MAAmB;IACjE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAC9B,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACvB,CAAC;AACH,CAAC;AAED,SAAS,OAAO,CAAC,OAA8B,EAAE,IAAe;IAC9D,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QAC9C,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
import type { SetupMode, SetupTarget } from "./setup-options.js";
export type InstallStatus = "create" | "update" | "unchanged";
export interface SkillInstall {
readonly target: SetupTarget;
readonly label: string;
readonly directory: string;
readonly status: InstallStatus;
}
export interface SetupPlan {
readonly mode: SetupMode;
readonly scope: "global" | "project";
readonly installCli: boolean;
readonly packageSpec: string;
readonly skills: ReadonlyArray<SkillInstall>;
}
export interface PlanSetupInput {
readonly mode: SetupMode;
readonly targets: ReadonlyArray<SetupTarget>;
readonly project: boolean;
readonly cwd?: string;
readonly home?: string;
readonly packageVersion?: string;
}
export interface ApplySetupResult {
readonly cliInstalled: boolean;
readonly skillDirectories: ReadonlyArray<string>;
}
export interface SetupRuntime {
readonly installCli?: (packageSpec: string) => Promise<void>;
}
export declare function planSetup(input: PlanSetupInput): Promise<SetupPlan>;
export declare function formatSetupPlan(plan: SetupPlan): string;
export declare function applySetup(plan: SetupPlan, runtime?: SetupRuntime): Promise<ApplySetupResult>;
export declare function skillDirectory(target: SetupTarget, project: boolean, root: string): string;
import { constants } from "node:fs";
import { access, mkdir, readFile, writeFile } from "node:fs/promises";
import { homedir } from "node:os";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
import { spawn } from "node:child_process";
const SKILL_FILES = ["SKILL.md", "agents/openai.yaml"];
export async function planSetup(input) {
const root = input.project ? (input.cwd ?? process.cwd()) : (input.home ?? homedir());
const skills = input.mode === "cli-only"
? []
: await Promise.all(input.targets.map(async (target) => {
const directory = skillDirectory(target, input.project, root);
return {
target,
label: target === "codex" ? "Codex" : "Claude Code",
directory,
status: await inspectSkill(directory),
};
}));
return {
mode: input.mode,
scope: input.project ? "project" : "global",
installCli: input.mode !== "skill-only",
packageSpec: `internalcot@${input.packageVersion ?? await readPackageVersion()}`,
skills,
};
}
export function formatSetupPlan(plan) {
const lines = ["Setup plan"];
if (plan.installCli) {
lines.push(` install CLI ${plan.packageSpec} globally`);
}
for (const skill of plan.skills) {
const verb = skill.status === "unchanged" ? "keep" : skill.status;
lines.push(` ${verb.padEnd(7)} ${skill.label} skill at ${skill.directory}`);
}
return `${lines.join("\n")}\n`;
}
export async function applySetup(plan, runtime = {}) {
if (plan.installCli) {
await (runtime.installCli ?? installPersistentCli)(plan.packageSpec);
}
const installed = [];
for (const skill of plan.skills) {
if (skill.status !== "unchanged") {
await installSkill(skill.directory);
}
installed.push(skill.directory);
}
return { cliInstalled: plan.installCli, skillDirectories: installed };
}
export function skillDirectory(target, project, root) {
if (target === "codex") {
return join(root, ".agents", "skills", "internalcot");
}
return join(root, ".claude", "skills", "internalcot");
}
async function inspectSkill(directory) {
const directoryExists = await exists(directory);
if (!directoryExists) {
return "create";
}
for (const relativePath of SKILL_FILES) {
const [source, target] = await Promise.all([
readFile(join(sourceSkillDirectory(), relativePath)),
readFileIfPresent(join(directory, relativePath)),
]);
if (target === undefined || !source.equals(target)) {
return "update";
}
}
return "unchanged";
}
async function installSkill(directory) {
for (const relativePath of SKILL_FILES) {
const target = join(directory, relativePath);
await mkdir(dirname(target), { recursive: true });
await writeFile(target, await readFile(join(sourceSkillDirectory(), relativePath)));
}
}
async function installPersistentCli(packageSpec) {
const executable = process.platform === "win32" ? "npm.cmd" : "npm";
await new Promise((resolve, reject) => {
const child = spawn(executable, ["install", "--global", packageSpec], {
stdio: "inherit",
shell: false,
});
child.once("error", reject);
child.once("exit", (code, signal) => {
if (code === 0) {
resolve();
return;
}
reject(new Error(signal === null
? `npm install exited with code ${code ?? "unknown"}`
: `npm install was terminated by ${signal}`));
});
});
}
function sourceSkillDirectory() {
return fileURLToPath(new URL("../skills/internalcot/", import.meta.url));
}
async function readPackageVersion() {
const contents = await readFile(new URL("../package.json", import.meta.url), "utf8");
const value = JSON.parse(contents);
if (typeof value !== "object"
|| value === null
|| !("version" in value)
|| typeof value.version !== "string") {
throw new Error("Could not read the internalcot package version");
}
return value.version;
}
async function exists(path) {
try {
await access(path, constants.F_OK);
return true;
}
catch (cause) {
if (isMissing(cause)) {
return false;
}
throw cause;
}
}
async function readFileIfPresent(path) {
try {
return await readFile(path);
}
catch (cause) {
if (isMissing(cause)) {
return undefined;
}
throw cause;
}
}
function isMissing(cause) {
return cause instanceof Error && "code" in cause && cause.code === "ENOENT";
}
//# sourceMappingURL=setup.js.map
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAI3C,MAAM,WAAW,GAAG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ACD,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;IACpE,CAAC;IACD,OAAO,KAAK,CAAC,OAAO,CAAC;AACvB,CAAC;AAED,KAAK,UAAU,MAAM,CAAC,IAAY;IAChC,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;QACnC,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACxB,IAAI,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;YACrB,OAAO,KAAK,CAAC;QACf,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED,KAAK,UAAU,iBAAiB,CAAC,IAAY;IAC3C,IAAI,CAAC;QACH,OAAO,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACxB,IAAI,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;YACrB,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED,SAAS,SAAS,CAAC,KAAc;IAC/B,OAAO,KAAK,YAAY,KAAK,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC;AAC9E,CAAC"}
/** Rendered streams for one observable working-note record. */
export type WorkingNoteOutput = {
readonly stderr: string;
readonly stdout: string;
};
/** Result of parsing and formatting one working note. */
export type WorkingNoteResult = {
readonly ok: true;
readonly output: WorkingNoteOutput;
} | {
readonly ok: false;
readonly message: string;
};
/** Format one working note for the transcript and return a machine-readable receipt. */
export declare function formatWorkingNote(notes: string, styled: boolean): WorkingNoteResult;
const NEXT_STEP = "Continue the work. Record another note only for materially new reasoning state.";
/** Format one working note for the transcript and return a machine-readable receipt. */
export function formatWorkingNote(notes, styled) {
const normalized = notes.trim();
if (normalized.length === 0) {
return { ok: false, message: "Provide working notes as arguments or through stdin" };
}
const italic = styled ? "\u001B[3m" : "";
const reset = styled ? "\u001B[0m" : "";
return {
ok: true,
output: {
stderr: `${italic}internalcot> ${normalized}${reset}\n`,
stdout: `${JSON.stringify({ recorded: true, next: NEXT_STEP })}\n`,
},
};
}
//# sourceMappingURL=working-notes.js.map
{"version":3,"file":"working-notes.js","sourceRoot":"","sources":["../src/working-notes.ts"],"names":[],"mappings":"AAAA,MAAM,SAAS,GACb,iFAAiF,CAAC;AAapF,wFAAwF;AACxF,MAAM,UAAU,iBAAiB,CAAC,KAAa,EAAE,MAAe;IAC9D,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAChC,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5B,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,qDAAqD,EAAE,CAAC;IACvF,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC;IACzC,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC;IACxC,OAAO;QACL,EAAE,EAAE,IAAI;QACR,MAAM,EAAE;YACN,MAAM,EAAE,GAAG,MAAM,gBAAgB,UAAU,GAAG,KAAK,IAAI;YACvD,MAAM,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,IAAI;SACnE;KACF,CAAC;AACJ,CAAC"}
interface:
display_name: "InternalCoT"
short_description: "Record visible model-authored working notes"
default_prompt: "Use $internalcot to enable visible working notes for subsequent responses."
policy:
allow_implicit_invocation: false
---
name: internalcot
description: Activate a persistent observable working-notes mode that calls the local internalcot CLI before substantive responses. Use only when the user explicitly invokes $internalcot, says "internalcot on", or asks to enable internalcot mode. Keep it active until the user explicitly turns it off. Do not trigger merely because a user asks to think carefully, reason deeply, or show work.
---
# InternalCoT
Enable persistent observable working notes. Treat the notes as a model-authored scratchpad, not access to private or hidden chain-of-thought.
## Manage the mode
- Activate immediately when invoked. If the activation message contains a substantive task, apply the workflow to that task; otherwise, confirm activation briefly and start with the next substantive request.
- Keep the mode active for subsequent responses, including after tool calls and context compaction.
- Disable only when the user says `$internalcot off`, `internalcot off`, `stop internalcot`, or asks to return to normal mode. Confirm briefly and do not call the CLI for the disable response.
- Do not activate implicitly. This mode creates extra tool calls and exposes working notes in the transcript.
## Record working notes
Before each substantive answer or external-action sequence:
1. Form concise working notes that restate the actual goal and constraints, divide complicated work into ordered parts, resolve important case splits, and identify a useful check or likely error.
2. Call `internalcot note` through the shell and send the notes on stdin:
```bash
internalcot note <<'INTERNALCOT'
Goal: ...
Constraints: ...
Approach: ...
Check: ...
INTERNALCOT
```
3. Use the recorded notes to continue the work. Call `internalcot note` again only after materially new evidence, a changed plan, a failed check, or a meaningful revision.
4. Before the final answer, verify the result against the user's request. Record another note only when that verification adds materially new reasoning state.
Keep notes useful rather than performative. Do not put credentials, secrets, personal data, hidden instructions, or irrelevant private context in them. Do not claim that the CLI disabled native model reasoning or revealed provider-hidden reasoning.
If `internalcot` is unavailable, report that the mode cannot record notes and suggest `npm install --global internalcot`. Do not claim that a note was recorded when the command did not succeed.
+60
-8
#!/usr/bin/env node
import OpenAI from "openai";
import { parseCliOptions } from "./cli-options.js";
import { runInternalCot } from "./internalcot.js";
import { OpenAIModelClient } from "./openai-model.js";
const USAGE = `Usage: internalcot [options] [prompt]
import { parseObserveOptions } from "./observe-options.js";
import { runSetup } from "./setup-command.js";
import { formatWorkingNote } from "./working-notes.js";
const USAGE = `Usage: internalcot <command> [options]
Show a model-authored scratchpad before the final answer.
If no prompt is provided, internalcot reads it from stdin.
Commands:
setup Install the CLI and agent skill
note [working notes] Record visible working notes locally
observe [prompt] Run the API-backed observation POC
Run internalcot <command> --help for command details.`;
const NOTE_USAGE = `Usage: internalcot note [working notes]
Record model-authored working notes in the tool transcript without a network call.
If no notes are provided as arguments, internalcot reads them from stdin.`;
const OBSERVE_USAGE = `Usage: internalcot observe [options] [prompt]
Run a second model through the Responses API, force a visible scratchpad tool call,
then stream its final answer. If no prompt is provided, read it from stdin.
Options:

@@ -23,6 +37,19 @@ -m, --model <model> Model to use (default: gpt-5.6-sol)

}
async function main() {
const options = parseCliOptions(process.argv.slice(2));
async function runNote(args) {
if (args.length === 1 && (args[0] === "--help" || args[0] === "-h")) {
process.stdout.write(`${NOTE_USAGE}\n`);
return;
}
const notes = args.length > 0 ? args.join(" ") : process.stdin.isTTY ? "" : await readStdin();
const result = formatWorkingNote(notes, process.stderr.isTTY);
if (!result.ok) {
throw new Error(result.message);
}
process.stderr.write(result.output.stderr);
process.stdout.write(result.output.stdout);
}
async function runObserve(args) {
const options = parseObserveOptions(args);
if (options.help) {
process.stdout.write(`${USAGE}\n`);
process.stdout.write(`${OBSERVE_USAGE}\n`);
return;

@@ -32,3 +59,3 @@ }

if (prompt.length === 0) {
throw new Error("Provide a prompt as arguments or through stdin");
throw new Error("Provide an observation prompt as arguments or through stdin");
}

@@ -68,3 +95,28 @@ let scratchpadStarted = false;

}
async function main() {
const [command, ...args] = process.argv.slice(2);
if (command === undefined || command === "--help" || command === "-h") {
process.stdout.write(`${USAGE}\n`);
return;
}
if (command === "note") {
await runNote(args);
return;
}
if (command === "setup") {
await runSetup(args);
return;
}
if (command === "observe") {
await runObserve(args);
return;
}
throw new Error(`Unknown command: ${command}`);
}
main().catch((cause) => {
if (cause instanceof Error && cause.name === "ExitPromptError") {
process.stderr.write("internalcot: Setup cancelled; no changes made.\n");
process.exitCode = 130;
return;
}
const message = cause instanceof Error ? cause.message : String(cause);

@@ -71,0 +123,0 @@ process.stderr.write(`internalcot: ${message}\n`);

+1
-1

@@ -1,1 +0,1 @@

{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,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OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,gBAAgB,OAAO,IAAI,CAAC,CAAC;IAClD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC"}
{
"name": "internalcot",
"version": "0.1.1",
"description": "Expose a model-authored scratchpad through a forced function call.",
"version": "0.2.0",
"description": "Visible working notes for coding agents, plus an API observation POC.",
"license": "MIT",

@@ -18,2 +18,3 @@ "author": "morluto",

"cli",
"agent-skill",
"reasoning",

@@ -28,6 +29,7 @@ "scratchpad",

"files": [
"dist"
"dist",
"skills"
],
"scripts": {
"build": "tsc -p tsconfig.build.json",
"build": "node scripts/clean.mjs && tsc -p tsconfig.build.json",
"check": "tsc -p tsconfig.json --noEmit",

@@ -42,5 +44,6 @@ "test": "vitest run",

"engines": {
"node": ">=22"
"node": ">=22.13.0"
},
"dependencies": {
"@inquirer/prompts": "8.5.2",
"openai": "7.4.0"

@@ -47,0 +50,0 @@ },

+113
-22
# internalcot
`internalcot` asks a model to put its working notes in a visible function call before answering.
The notes are model-authored scratchpad text, not access to hidden reasoning tokens.
`internalcot` gives coding agents a persistent, observable working-notes mode. An installed skill tells the current agent to call a small local CLI before substantive responses, so its model-authored scratchpad appears in the tool transcript.
## Install
This does not reveal private or provider-hidden chain-of-thought. It records notes that the model deliberately writes for observation.
## Install the CLI and skill
Run the guided setup:
```sh
npx internalcot@latest setup
```
Choose **CLI + skill**, then select Codex, Claude Code, or both. Setup shows the exact global command and skill paths before it changes anything.
For a non-interactive Codex install:
```sh
npx internalcot@latest setup --codex --yes
```
Use `--project` to place the skill in the current repository instead of your home directory. Other useful variants are:
```sh
# Preview without making changes
npx internalcot@latest setup --codex --project --dry-run
# The persistent command already exists
npx internalcot@latest setup --codex --skill-only --yes
# Install only the command
npx internalcot@latest setup --cli-only --yes
```
Setup writes only the bundled `internalcot` skill files. Re-running it reports an unchanged installation or updates those files while preserving unrelated files in the same directory.
You can also install each part manually:
```sh
npm install --global internalcot
npx skills add morluto/internalcot
```
Set `OPENAI_API_KEY` before running the CLI. `OPENAI_BASE_URL` can point the OpenAI SDK at a compatible gateway.
Restart your coding agent if the new skill does not appear immediately.
## Usage
## Turn working notes on
Explicitly invoke the skill without giving it a task:
```text
$internalcot
```
The mode remains active for subsequent requests. The agent calls `internalcot note` before substantive work and again only when it has materially new reasoning state.
Turn it off with:
```text
$internalcot off
```
The toggle is conversational state carried by the skill instructions. It does not change the host's native reasoning setting or install a new first-class tool dynamically.
## Use the working-notes CLI directly
Pass a short note as arguments:
```sh
internalcot "Solve this problem"
cat problem.md | internalcot
internalcot --model gpt-5.6-sol --effort none "Check this proof"
internalcot note "Check the equality case before drafting."
```
Scratchpad output goes to stderr; the final answer goes to stdout so it can be redirected or piped.
For multiline notes, use stdin:
```sh
internalcot "Check this proof" >answer.md 2>scratchpad.txt
internalcot note <<'INTERNALCOT'
Goal: prove descent from the equation.
Constraint: handle every equality case.
Check: verify the mutated coordinate stays positive.
INTERNALCOT
```
Run `internalcot --help` for all options.
The note is written to stderr with an `internalcot>` prefix. Stdout receives a small JSON receipt:
## How it works
```json
{"recorded":true,"next":"Continue the work. Record another note only for materially new reasoning state."}
```
The CLI owns the Responses API request. It sets native reasoning effort to `none` by default,
requires an `internalcot` function call on the first turn, displays that call's arguments, and
then returns the tool result so the model can produce its final answer.
The command does not use the network, require an API key, or save notes to disk. The coding agent's tool transcript is the record.
This does not reveal private or hidden chain-of-thought. It elicits a separate, observable
scratchpad whose usefulness and faithfulness should be evaluated independently.
## Run the API observation POC
The separate `observe` command preserves the original experiment: it starts a second model through the OpenAI Responses API, sets its reasoning effort to `none` by default, forces an `internalcot` function call on the first turn, streams those tool arguments as a visible scratchpad, and then streams the final answer.
Create a project key in the [OpenAI dashboard](https://platform.openai.com/api-keys). Never paste a key into a prompt, issue, chat, source file, or shell command that will be saved in history. Revoke and replace any exposed key.
In Bash on macOS or Linux:
```sh
# Use OpenAI directly, not a previously configured compatible gateway.
unset OPENAI_BASE_URL
read -rsp "OpenAI API key: " OPENAI_API_KEY && echo
export OPENAI_API_KEY
internalcot observe --model gpt-5.6-luna \
"Work out 17 * 23, then give only the product."
unset OPENAI_API_KEY
```
Scratchpad output goes to stderr and the final answer to stdout, so they can be captured separately:
```sh
internalcot observe "Check whether 17 * 23 = 391" \
>answer.txt 2>scratchpad.txt
```
The default observation model is `gpt-5.6-sol`. See the [OpenAI model catalog](https://developers.openai.com/api/docs/models) and [API quickstart](https://developers.openai.com/api/docs/quickstart).
If you intentionally use an OpenAI-compatible gateway, set `OPENAI_BASE_URL` only for that gateway and use a credential issued by that provider.
## Development

@@ -49,14 +133,21 @@

Validate the bundled skill with:
```sh
npx skills add . --list
```
## Publishing
The package is public and unscoped. Before the first release:
```sh
npm login
npm whoami
npm run prepublishOnly
npm pack --dry-run
npm pack --dry-run --json
npm publish
```
Check that `internalcot` is still available on npm immediately before publishing.
Verify the packed `dist/cli.js` is executable and the `skills/internalcot` directory is included before publishing.
## Credit
The idea and original proof of concept are by [Can Bölük (@_can1357)](https://x.com/_can1357/status/2087228354399265125).
import type { ReasoningEffort } from "./model.js";
/** Parsed command-line options. */
export type CliOptions = {
readonly model: string;
readonly effort: ReasoningEffort;
readonly maxTurns: number;
readonly prompt: string | undefined;
readonly help: boolean;
};
/** Parse the small, dependency-free internalcot command surface. */
export declare function parseCliOptions(args: ReadonlyArray<string>): CliOptions;
const EFFORTS = new Set(["none", "low", "medium", "high", "xhigh", "max"]);
function nextValue(args, index, option) {
const value = args[index + 1];
if (value === undefined) {
throw new Error(`${option} requires a value`);
}
return value;
}
/** Parse the small, dependency-free internalcot command surface. */
export function parseCliOptions(args) {
let model = "gpt-5.6-sol";
let effort = "none";
let maxTurns = 8;
let help = false;
const promptParts = [];
for (let index = 0; index < args.length; index += 1) {
const argument = args[index];
if (argument === "--help" || argument === "-h") {
help = true;
continue;
}
if (argument === "--model" || argument === "-m") {
model = nextValue(args, index, argument);
index += 1;
continue;
}
if (argument === "--effort" || argument === "-e") {
const value = nextValue(args, index, argument);
if (!EFFORTS.has(value)) {
throw new Error(`Invalid effort: ${value}`);
}
effort = value;
index += 1;
continue;
}
if (argument === "--max-turns") {
const value = nextValue(args, index, argument);
const parsed = Number(value);
if (!Number.isSafeInteger(parsed) || parsed < 1) {
throw new Error(`Invalid max turns: ${value}`);
}
maxTurns = parsed;
index += 1;
continue;
}
if (argument?.startsWith("-")) {
throw new Error(`Unknown option: ${argument}`);
}
if (argument !== undefined) {
promptParts.push(argument);
}
}
return {
model,
effort,
maxTurns,
prompt: promptParts.length === 0 ? undefined : promptParts.join(" "),
help,
};
}
//# sourceMappingURL=cli-options.js.map
{"version":3,"file":"cli-options.js","sourceRoot":"","sources":["../src/cli-options.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,GAAwB,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;AAWhG,SAAS,SAAS,CAAC,IAA2B,EAAE,KAAa,EAAE,MAAc;IAC3E,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;IAC9B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,GAAG,MAAM,mBAAmB,CAAC,CAAC;IAChD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,oEAAoE;AACpE,MAAM,UAAU,eAAe,CAAC,IAA2B;IACzD,IAAI,KAAK,GAAG,aAAa,CAAC;IAC1B,IAAI,MAAM,GAAoB,MAAM,CAAC;IACrC,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,IAAI,IAAI,GAAG,KAAK,CAAC;IACjB,MAAM,WAAW,GAAkB,EAAE,CAAC;IAEtC,KA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