@anhvupt/tito 0.1.0 → 0.1.2

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.
package/README.md CHANGED
@@ -84,10 +84,18 @@ npx tito init --profile client-careful
84
84
  npx tito init --profile client-careful --confirm
85
85
  ```
86
86
 
87
- The first `init` prints the plan and writes nothing. `--confirm` creates the
88
- missing Tito files and specialist agents. It keeps an existing `AGENTS.md` and
89
- refuses to overwrite a file that is already there. Open a new Cursor chat, then
90
- start with `/tito`.
87
+ The first `init` prints the plan and writes nothing. In a terminal, omitting
88
+ `--profile` asks you to choose `client-careful`, `solo-balanced`, or
89
+ `solo-fast`. A script or piped command must still pass `--profile`.
90
+ `--confirm` creates the missing `tito.yaml`, specialist agents, and `/tito`
91
+ skills. If `AGENTS.md` already exists, Tito appends its bootstrap and leaves
92
+ the existing guidance in place. It refuses to overwrite a Tito file that is
93
+ already there. Open a new Cursor chat, then start with `/tito`.
94
+
95
+ Tito is installed in each project. It is not a required global command, and
96
+ there is no global configuration yet. A future personal default would be
97
+ overridden by that project's `tito.yaml`. The safety floor still cannot be
98
+ weakened.
91
99
 
92
100
  ## What works today
93
101
 
package/dist/cli.js CHANGED
@@ -1,9 +1,11 @@
1
1
  #!/usr/bin/env node
2
+ import { createInterface } from "node:readline/promises";
3
+ import { stdin as input, stdout as output } from "node:process";
2
4
  import { readFileSync } from "node:fs";
3
5
  import { parseArgs } from "node:util";
4
6
  import { InspectionError, formatInspection, inspectRepository, } from "./core/inspect.js";
5
7
  import { PlanError, formatAdoptionPlan, planAdoption } from "./core/plan.js";
6
- import { InitError, applyInitialization, formatInitialization, planInitialization, } from "./core/init.js";
8
+ import { InitError, applyInitialization, formatInitialization, planInitialization, promptForProfile, } from "./core/init.js";
7
9
  const packageJson = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
8
10
  const help = `Tito — quiet orchestration for solo builders
9
11
 
@@ -11,7 +13,7 @@ Usage:
11
13
  tito [options]
12
14
  tito inspect [--root <path>]
13
15
  tito apply --dry-run --profile <id> [--root <path>]
14
- tito init --profile <id> [--root <path>] [--confirm]
16
+ tito init [--profile <id>] [--root <path>] [--confirm]
15
17
 
16
18
  Options:
17
19
  -h, --help Show help
@@ -106,7 +108,7 @@ function runApply(args) {
106
108
  throw error;
107
109
  }
108
110
  }
109
- function runInit(args) {
111
+ async function runInit(args) {
110
112
  if (args.includes("-h") || args.includes("--help")) {
111
113
  process.stdout.write(help);
112
114
  return;
@@ -136,8 +138,17 @@ function runInit(args) {
136
138
  return;
137
139
  }
138
140
  if (profile === undefined) {
139
- fail("Missing required option --profile.");
140
- return;
141
+ if (!input.isTTY) {
142
+ fail("Missing required option --profile.");
143
+ return;
144
+ }
145
+ const prompts = createInterface({ input, output });
146
+ try {
147
+ profile = await promptForProfile((prompt) => prompts.question(prompt));
148
+ }
149
+ finally {
150
+ prompts.close();
151
+ }
141
152
  }
142
153
  try {
143
154
  const plan = planInitialization(inspectRepository(root), profile);
@@ -163,7 +174,7 @@ function runInit(args) {
163
174
  throw error;
164
175
  }
165
176
  }
166
- function run(args) {
177
+ async function run(args) {
167
178
  if (args[0] === "inspect") {
168
179
  runInspect(args.slice(1));
169
180
  return;
@@ -173,8 +184,7 @@ function run(args) {
173
184
  return;
174
185
  }
175
186
  if (args[0] === "init") {
176
- runInit(args.slice(1));
177
- return;
187
+ return runInit(args.slice(1));
178
188
  }
179
189
  let helpRequested = false;
180
190
  let versionRequested = false;
package/dist/core/init.js CHANGED
@@ -1,7 +1,9 @@
1
- import { mkdirSync, statSync, unlinkSync, writeFileSync } from "node:fs";
1
+ import { mkdirSync, readFileSync, readdirSync, statSync, unlinkSync, writeFileSync } from "node:fs";
2
2
  import { dirname, join } from "node:path";
3
+ import { fileURLToPath } from "node:url";
3
4
  import { compiledCursorAgents } from "./agents.js";
4
- import { PlanError, planAdoption, } from "./plan.js";
5
+ import { ACTIVE_RISK_PROFILE_IDS } from "./profiles.js";
6
+ import { ADOPTION_AGENTS_MD, PlanError, planAdoption, } from "./plan.js";
5
7
  export class InitError extends Error {
6
8
  code;
7
9
  constructor(message) {
@@ -10,6 +12,17 @@ export class InitError extends Error {
10
12
  this.code = "conflict";
11
13
  }
12
14
  }
15
+ export async function promptForProfile(ask) {
16
+ const choices = ACTIVE_RISK_PROFILE_IDS.map((id, index) => ` ${index + 1}. ${id}`).join("\n");
17
+ const answer = (await ask(`Profiles:\n${choices}\nProfile: `)).trim();
18
+ const index = Number(answer);
19
+ if (Number.isInteger(index) &&
20
+ index >= 1 &&
21
+ index <= ACTIVE_RISK_PROFILE_IDS.length) {
22
+ return ACTIVE_RISK_PROFILE_IDS[index - 1] ?? answer;
23
+ }
24
+ return answer;
25
+ }
13
26
  function exists(root, path) {
14
27
  try {
15
28
  return statSync(join(root, path)).isFile();
@@ -18,19 +31,47 @@ function exists(root, path) {
18
31
  return false;
19
32
  }
20
33
  }
34
+ function shippedSkills() {
35
+ const root = join(dirname(fileURLToPath(import.meta.url)), "../../templates/cursor/skills");
36
+ return readdirSync(root, { withFileTypes: true })
37
+ .filter((entry) => entry.isDirectory())
38
+ .map((entry) => ({
39
+ path: `.cursor/skills/${entry.name}/SKILL.md`,
40
+ body: readFileSync(join(root, entry.name, "SKILL.md"), "utf8"),
41
+ }));
42
+ }
43
+ function agentsBootstrap(report) {
44
+ if (report.agentsMd === "absent") {
45
+ return { path: "AGENTS.md", action: "create", body: ADOPTION_AGENTS_MD };
46
+ }
47
+ const current = readFileSync(join(report.root, "AGENTS.md"), "utf8");
48
+ if (current.includes("Hola, Tito here!")) {
49
+ return { path: "AGENTS.md", action: "keep" };
50
+ }
51
+ return {
52
+ path: "AGENTS.md",
53
+ action: "append",
54
+ body: `\n${ADOPTION_AGENTS_MD}`,
55
+ };
56
+ }
21
57
  export function planInitialization(report, profile) {
22
58
  const adoption = planAdoption(report, profile);
59
+ const files = adoption.files.map((file) => file.path === "AGENTS.md" ? agentsBootstrap(report) : file);
23
60
  const agents = compiledCursorAgents().map((agent) => exists(report.root, agent.path)
24
61
  ? { path: agent.path, action: "conflict" }
25
62
  : { path: agent.path, action: "create", body: agent.body });
26
- return { root: adoption.root, profile: adoption.profile, files: [...adoption.files, ...agents] };
63
+ const skills = shippedSkills().map((skill) => exists(report.root, skill.path)
64
+ ? { path: skill.path, action: "keep" }
65
+ : { path: skill.path, action: "create", body: skill.body });
66
+ return { root: adoption.root, profile: adoption.profile, files: [...files, ...agents, ...skills] };
27
67
  }
28
68
  export function formatInitialization(plan) {
29
69
  const lines = [`root: ${plan.root}`, `profile: ${plan.profile}`];
30
70
  for (const file of plan.files) {
31
71
  lines.push(`${file.path}: ${file.action}`);
32
- if (file.action === "create")
72
+ if (file.action === "create" || file.action === "append") {
33
73
  lines.push("---", file.body.trimEnd(), "---");
74
+ }
34
75
  }
35
76
  return `${lines.join("\n")}\n`;
36
77
  }
@@ -42,6 +83,13 @@ export function applyInitialization(plan) {
42
83
  const created = [];
43
84
  try {
44
85
  for (const file of plan.files) {
86
+ if (file.action === "append") {
87
+ const absolute = join(plan.root, file.path);
88
+ const current = readFileSync(absolute, "utf8");
89
+ const separator = current.endsWith("\n") ? "\n" : "\n\n";
90
+ writeFileSync(absolute, `${current}${separator}${file.body}`, "utf8");
91
+ continue;
92
+ }
45
93
  if (file.action !== "create")
46
94
  continue;
47
95
  const absolute = join(plan.root, file.path);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anhvupt/tito",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Local-first AI development harness for solo builders.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -9,6 +9,7 @@
9
9
  },
10
10
  "files": [
11
11
  "dist/",
12
+ "templates/",
12
13
  "README.md",
13
14
  "LICENSE"
14
15
  ],
@@ -0,0 +1,33 @@
1
+ ---
2
+ name: tito
3
+ description: Runs Tito's chat-first engineering coordination workflow. Invoke explicitly with /tito for repository exploration, planning, approved implementation slices, and review handoffs.
4
+ disable-model-invocation: true
5
+ ---
6
+
7
+ # Tito
8
+
9
+ Act as the root Tito coordinator in this project.
10
+ Start every response exactly with `Hola, Tito here!`
11
+
12
+ Ordinary chat follows `AGENTS.md`. `/tito` is the explicit coordinator. Read `tito.yaml` for the risk profile. Read project documentation only when the task needs it. Do not replace existing project guidance.
13
+
14
+ ## Route the task
15
+
16
+ Recommend one mode before acting:
17
+
18
+ - **Ask** for read-only exploration, explanation, impact analysis, or diagnosis.
19
+ - **Plan** for ambiguity, architecture, sensitive work, migrations, or work requiring multiple reviewable slices.
20
+ - **Agent** only for one explicitly approved implementation slice.
21
+
22
+ For Plan work, the planner decides the technical approach and includes guidance code when it removes ambiguity. Ask the user only for a genuine product or business choice.
23
+
24
+ ## Execute
25
+
26
+ 1. Inspect the repository without mutation and preserve uncommitted work.
27
+ 2. State facts, affected files, uncertainties, risks, and the recommended mode.
28
+ 3. For Plan work, produce independent slices and stop for approval.
29
+ 4. Use one code writer. Specialist advisers and reviewers stay read-only.
30
+ 5. Implement and verify only the approved slice, then stop for review.
31
+ 6. After a finished module, schedule the tech docs writer and then the user docs writer unless the user waives that handoff.
32
+
33
+ Never commit, push, publish, deploy, or perform irreversible external actions without explicit approval.
@@ -0,0 +1,12 @@
1
+ ---
2
+ name: tito-apply
3
+ description: Dry-run Tito's adoption plan. Invoke explicitly with /tito-apply. Uses the same output as tito apply --dry-run.
4
+ disable-model-invocation: true
5
+ ---
6
+
7
+ # Tito apply
8
+
9
+ Chat adapter for `npx tito apply --dry-run`. Show the command stdout unchanged.
10
+ Start the chat response exactly with `Hola, Tito here!`
11
+
12
+ The user must name `client-careful`, `solo-balanced`, or `solo-fast`. If they do not, ask which profile to use and stop. Do not omit `--dry-run`. Do not write project files.
@@ -0,0 +1,12 @@
1
+ ---
2
+ name: tito-init
3
+ description: Preview or confirm Tito initialization. Invoke explicitly with /tito-init. Uses the same plan as tito init.
4
+ disable-model-invocation: true
5
+ ---
6
+
7
+ # Tito init
8
+
9
+ Chat adapter for `npx tito init`. Show the command stdout unchanged.
10
+ Start the chat response exactly with `Hola, Tito here!`
11
+
12
+ Preview first without `--confirm`. Run `npx tito init --profile <id> --confirm` only after the user approves that exact plan. In a terminal, omitting `--profile` asks for one. Do not overwrite existing project guidance.
@@ -0,0 +1,12 @@
1
+ ---
2
+ name: tito-inspect
3
+ description: Run Tito's read-only repository inspection. Invoke explicitly with /tito-inspect. Uses the same report as tito inspect.
4
+ disable-model-invocation: true
5
+ ---
6
+
7
+ # Tito inspect
8
+
9
+ Chat adapter for `npx tito inspect`. Run that command and show its stdout unchanged.
10
+ Start the chat response exactly with `Hola, Tito here!` The greeting is not part of the command output.
11
+
12
+ Add `--root <path>` only when the user names another directory. Do not reimplement inspection by reading files yourself. Do not write project files.