trip-optimizer 0.1.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,98 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ generateProgram,
4
+ loadConfig
5
+ } from "../chunk-OSZUVWNK.js";
6
+
7
+ // src/commands/run-agent.ts
8
+ import { spawn, execSync } from "child_process";
9
+ import path from "path";
10
+ import fs from "fs";
11
+ import chalk from "chalk";
12
+ import yaml from "js-yaml";
13
+ async function launchAgent(tripDir, options) {
14
+ try {
15
+ execSync("which claude", { stdio: "ignore" });
16
+ } catch {
17
+ console.log(chalk.red("\n Claude Code CLI not found. Install it first: https://docs.anthropic.com/en/docs/claude-code\n"));
18
+ process.exit(1);
19
+ }
20
+ const constraintsPath = path.join(tripDir, "constraints.yaml");
21
+ if (!fs.existsSync(constraintsPath)) {
22
+ console.log(chalk.red("\n Not in a trip project directory (no constraints.yaml found).\n"));
23
+ process.exit(1);
24
+ }
25
+ const constraints = yaml.load(fs.readFileSync(constraintsPath, "utf-8"));
26
+ const config = loadConfig();
27
+ const programContent = generateProgram(constraints, config);
28
+ const programPath = path.join(tripDir, "program.md");
29
+ fs.writeFileSync(programPath, programContent);
30
+ console.log(chalk.green(`
31
+ Generated ${programPath}`));
32
+ const args = [];
33
+ if (!options.safe) {
34
+ args.push("--dangerously-skip-permissions");
35
+ }
36
+ const mode = options.safe ? "safe mode" : "yolo mode";
37
+ if (options.headless) {
38
+ args.push("-p", "Read program.md and begin the optimization loop. Run until interrupted.");
39
+ console.log(chalk.bold(` Launching Claude Code headless in ${mode}...
40
+ `));
41
+ const child2 = spawn("claude", args, {
42
+ cwd: tripDir,
43
+ stdio: ["ignore", "pipe", "pipe"]
44
+ });
45
+ child2.stdout?.on("data", (data) => {
46
+ process.stdout.write(data);
47
+ });
48
+ child2.stderr?.on("data", (data) => {
49
+ process.stderr.write(data);
50
+ });
51
+ return new Promise((resolve, reject) => {
52
+ child2.on("close", (code) => {
53
+ if (code === 0 || code === null) {
54
+ console.log(chalk.green("\n Agent exited cleanly.\n"));
55
+ } else {
56
+ console.log(chalk.yellow(`
57
+ Agent exited with code ${code}.
58
+ `));
59
+ }
60
+ resolve();
61
+ });
62
+ child2.on("error", (err) => {
63
+ console.log(chalk.red(`
64
+ Failed to launch Claude Code: ${err.message}
65
+ `));
66
+ reject(err);
67
+ });
68
+ });
69
+ }
70
+ console.log(chalk.bold(` Launching Claude Code in ${mode}...`));
71
+ console.log(chalk.dim(` program.md is ready \u2014 tell Claude to "Read program.md and start optimizing"
72
+ `));
73
+ const child = spawn("claude", args, {
74
+ cwd: tripDir,
75
+ stdio: "inherit"
76
+ });
77
+ return new Promise((resolve, reject) => {
78
+ child.on("close", (code) => {
79
+ if (code === 0 || code === null) {
80
+ console.log(chalk.green("\n Agent session ended.\n"));
81
+ } else {
82
+ console.log(chalk.yellow(`
83
+ Agent exited with code ${code}.
84
+ `));
85
+ }
86
+ resolve();
87
+ });
88
+ child.on("error", (err) => {
89
+ console.log(chalk.red(`
90
+ Failed to launch Claude Code: ${err.message}
91
+ `));
92
+ reject(err);
93
+ });
94
+ });
95
+ }
96
+ export {
97
+ launchAgent
98
+ };
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "trip-optimizer",
3
+ "version": "0.1.0",
4
+ "description": "Autonomously optimize travel plans using the autoresearch pattern",
5
+ "type": "module",
6
+ "bin": {
7
+ "trip-optimizer": "./dist/cli.js"
8
+ },
9
+ "scripts": {
10
+ "build": "tsup",
11
+ "dev": "tsx src/cli.ts",
12
+ "test": "vitest run",
13
+ "test:watch": "vitest"
14
+ },
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "https://github.com/michaelpersonal/trip-optimizer"
18
+ },
19
+ "files": [
20
+ "dist"
21
+ ],
22
+ "engines": {
23
+ "node": ">=22"
24
+ },
25
+ "license": "MIT",
26
+ "keywords": [
27
+ "travel",
28
+ "optimizer",
29
+ "ai",
30
+ "cli",
31
+ "autoresearch"
32
+ ],
33
+ "dependencies": {
34
+ "@anthropic-ai/sdk": "^0.78.0",
35
+ "@anthropic-ai/vertex-sdk": "^0.14.4",
36
+ "asciichart": "^1.5.25",
37
+ "chalk": "^5.6.2",
38
+ "commander": "^14.0.3",
39
+ "inquirer": "^13.3.0",
40
+ "js-yaml": "^4.1.1",
41
+ "ora": "^9.3.0",
42
+ "pdfkit": "^0.18.0",
43
+ "simple-git": "^3.33.0"
44
+ },
45
+ "devDependencies": {
46
+ "@types/js-yaml": "^4.0.9",
47
+ "@types/node": "^25.5.0",
48
+ "tsup": "^8.5.1",
49
+ "tsx": "^4.21.0",
50
+ "typescript": "^5.9.3",
51
+ "vitest": "^4.1.0"
52
+ }
53
+ }