create-vibe-maestro 0.3.1 → 0.4.1
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/CHANGELOG.md +36 -2
- package/README.md +8 -6
- package/dist/cli/context-run.js +38 -0
- package/dist/cli/maestro.js +67 -1
- package/dist/cli/pack-run.js +44 -0
- package/dist/cli/upgrade-run.js +1 -1
- package/dist/core/context.js +169 -0
- package/dist/core/gitignore.js +11 -0
- package/dist/core/inventory.js +2 -0
- package/dist/core/pack.js +379 -0
- package/dist/core/upgrade/analyze.js +15 -1
- package/dist/core/upgrade/index.js +11 -5
- package/dist/core/upgrade/releases.js +66 -9
- package/dist/core/zip.js +133 -0
- package/docs/ROADMAP.md +74 -12
- package/docs/USER_GUIDE.md +89 -9
- package/package.json +1 -1
- package/registry/baseline/0.3.1/project/.claude/agents/code-reviewer.md +12 -0
- package/registry/baseline/0.3.1/project/.claude/agents/explorer.md +14 -0
- package/registry/baseline/0.3.1/project/.claude/rules/maestro.md +25 -0
- package/registry/baseline/0.3.1/project/protocols/build.md +17 -0
- package/registry/baseline/0.3.1/project/protocols/handoff.md +13 -0
- package/registry/baseline/0.4.0/project/.claude/rules/maestro.md +35 -0
- package/registry/baseline/0.4.0/project/protocols/completion.md +22 -0
- package/registry/baseline/0.4.0/project/protocols/handoff.md +15 -0
- package/registry/capabilities.v1.json +12 -0
- package/templates/project/.claude/agents/code-reviewer.md +1 -0
- package/templates/project/.claude/agents/explorer.md +1 -1
- package/templates/project/.claude/rules/maestro.md +11 -1
- package/templates/project/.claude/settings.json +0 -2
- package/templates/project/protocols/build.md +2 -1
- package/templates/project/protocols/completion.md +22 -0
- package/templates/project/protocols/handoff.md +2 -0
- package/templates/project/wiki/index.md +1 -0
- package/templates/project/wiki/passport.md +44 -0
- package/dist/core/upgrade/instance.js +0 -82
package/CHANGELOG.md
CHANGED
|
@@ -4,7 +4,41 @@ All notable changes to Vibe Coding Maestro are documented here.
|
|
|
4
4
|
|
|
5
5
|
The project follows Semantic Versioning while prerelease interfaces may still change between beta versions.
|
|
6
6
|
|
|
7
|
-
## 0.
|
|
7
|
+
## 0.4.1 — 2026-10-31
|
|
8
|
+
|
|
9
|
+
The second part of 0.4: packing a project for the customer and measuring the session. The set of project files is unchanged; `upgrade` from 0.4.0 rewrites the pinned version, `.claude/rules/maestro.md`, `protocols/handoff.md` and `protocols/completion.md`.
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- **`vibe-maestro pack --tag <tag>`** — a deterministic zip of the delivery tag, with no dependencies. Everything comes from the tag (`git archive`), not from the working folder, so the same tag always gives the same bytes; the command prints the sha256. Maestro and agent files at the root (`wiki/`, `maestro/`, `.claude/`, `protocols/`, `.maestro/`, `CLAUDE.md`, `AGENTS.md`, `.mcp.json`) are left out; `HANDOVER.md` is added with «смените все пароли и ключи» and the project passport from the tag. It refuses on likely secrets — `.env`/`.envrc`/`secrets.*`/key and keystore files/SQLite databases by name; private keys, OpenAI, Anthropic, GitHub, AWS, Telegram bot, Supabase service_role, Stripe, npm and Slack tokens, passwords in database URLs and in code by content (values are never printed; public Google browser keys, Supabase anon keys, `…EXAMPLE` keys, placeholders and local database URLs pass) — on agent files nested in the product, on symlinks leading outside the project, on an incomplete passport (a section with the «пока нет» placeholder or no entry), and when a different file is already at the output path. `--allow <path>` skips the check for a file the human has looked at. Submodules are reported as not included. Git settings that would change bytes (`core.autocrlf`, `log.showSignature`) are pinned. Files are stored uncompressed with a Unix timestamp field; modes are normalized to 644/755. Default output is the Desktop; `--out` takes a file or a folder.
|
|
14
|
+
- **`vibe-maestro context`** — the size of the current Claude Code session from its transcript (`~/.claude/projects/…`, `$CLAUDE_CONFIG_DIR` respected; only usage numbers are read). It picks the session from `$CLAUDE_CODE_SESSION_ID` when Claude Code provides it, otherwise the newest transcript of the folder. When `$CLAUDE_CODE_SESSION_ID` names a transcript that is missing, it refuses instead of measuring another session. It prints the context size as a share of the model window — 200 000 tokens, or 1 000 000 once the session is larger (`--window` to set) — the total input the session has sent, and plain advice: under 40% continue, from 40% start the next slice in a new session, from 70% hand off now. Entries without usage (`<synthetic>`) are skipped. The thresholds are a hypothesis to be checked by measurement.
|
|
15
|
+
- `.claude/rules/maestro.md` and `protocols/handoff.md`: after the handoff of a closed slice the agent runs `context` and tells the human in plain words whether to start a new session. `protocols/completion.md` names the `pack` command.
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- The `vibe-maestro` companion package (0.1.5) depends on exactly `create-vibe-maestro@0.4.1`.
|
|
20
|
+
- Upgrade tests use projects generated by the real published 0.4.0 package.
|
|
21
|
+
|
|
22
|
+
## 0.4.0 — 2026-10-31
|
|
23
|
+
|
|
24
|
+
The first part of 0.4: finishing a project and keeping sessions short. The set of project files changes; `vibe-maestro upgrade` migrates projects from 0.3.1, 0.3.0, 0.3.0-beta.1 – beta.4 and 0.2.0-beta.1.
|
|
25
|
+
|
|
26
|
+
### Added
|
|
27
|
+
|
|
28
|
+
- **Project passport `wiki/passport.md`** (belongs to the project): repository and delivery tag, where the project runs, domain and DNS, data and backups, external services and whose account they are on, **names** of environment variables and where they are set (never values), schedules, how to run, update and roll back. Kept from day one; an unused section says «не применимо». Works for projects without code too.
|
|
29
|
+
- **Completion protocol `protocols/completion.md`** (managed) — the missing last stage of the lifecycle: criteria checked, tests green, delivery tag, complete passport, customer documents with «change all passwords and keys», final handoff, plan closed (`status: completed`, `active_plan: none`), lessons recorded. A separate short path closes an internal project without delivery. Packaging for the customer is named as the step that arrives in 0.4.1. Linked from `protocols/build.md` and `.claude/rules/maestro.md`.
|
|
30
|
+
- **New session after a closed slice.** `.claude/rules/maestro.md`, `protocols/build.md` and `protocols/handoff.md` say: a closed slice ends with a handoff and an offer to start a new session; a second large slice is not started in the same session without the human's consent. A long session resends its whole history on every step.
|
|
31
|
+
- **API keys without hunting for files.** `.claude/rules/maestro.md` describes two ways: the human pastes the key into the chat and the agent writes it to `.env` without repeating it, or the human asks to «открой окно для ключа» and the agent adds the variable name (`NAME=`) and opens `.env` in an editor (`touch .env && open -e .env` on macOS) for the human to paste the value. It states honestly that a key typed into the chat — or read from `.env` by the agent — stays in the session history, so the agent does not open `.env` without need. The `explorer` and `code-reviewer` subagents do not open `.env` and never quote secret values.
|
|
32
|
+
- User guide: «Как подстроить защиты под проект» — the four levels (Maestro template → project `settings.json` and `rules/project.md` → personal `settings.local.json` → session permission mode), the deny → ask → allow order, typical settings in plain words, and that permissions change only on the human's «да». Linked from the README.
|
|
33
|
+
|
|
34
|
+
### Changed
|
|
35
|
+
|
|
36
|
+
- The default `.claude/settings.json` no longer denies reading `.env` and `.env.*`. Protection against committing `.env` stays: `.gitignore` and `doctor` (`git-env-tracked`). **Projects created before 0.4.0** keep their `settings.json` (it belongs to the project); to let the agent write keys itself, delete `"Read(.env)"` and `"Read(.env.*)"` from `deny` — the new rules tell the agent to offer this and to change the file only after a «да».
|
|
37
|
+
- `.gitignore` of new projects also lists `.claude/worktrees/` (temporary working copies) and `.claude/settings.local.json` (personal settings). `upgrade` appends only the missing lines to an existing `.gitignore`, names them in the proposal, and leaves the project's own lines and line endings as they are.
|
|
38
|
+
- The `vibe-maestro` companion package (0.1.4) depends on exactly `create-vibe-maestro@0.4.0`.
|
|
39
|
+
- Upgrade tests use projects generated by the real published 0.3.0 and 0.3.1 packages.
|
|
40
|
+
|
|
41
|
+
## 0.3.1 — 2026-10-31
|
|
8
42
|
|
|
9
43
|
Small fixes found in the 0.3.0 review and on a live project. The set of project files is unchanged; `upgrade` from 0.3.0 rewrites the pinned version and `.claude/rules/maestro.md`.
|
|
10
44
|
|
|
@@ -14,7 +48,7 @@ Small fixes found in the 0.3.0 review and on a live project. The set of project
|
|
|
14
48
|
- Commands inside `doctor`, `create` and `upgrade` messages are wrapped in backticks, so the period that ends a sentence no longer sticks to the path: `--path .` used to read as `--path ..`.
|
|
15
49
|
- Re-running `create` on an existing project warns when an explicit `--depth` or `--start` differs from the project and is not applied, instead of reporting success silently.
|
|
16
50
|
|
|
17
|
-
## 0.3.0 — 2026-
|
|
51
|
+
## 0.3.0 — 2026-10-31
|
|
18
52
|
|
|
19
53
|
The finished 0.3 product. All changes to the set of project files land in this one release, and `vibe-maestro upgrade` migrates projects from 0.3.0-beta.1 – beta.4 and 0.2.0-beta.1.
|
|
20
54
|
|
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
</p>
|
|
26
26
|
|
|
27
27
|
> [!IMPORTANT]
|
|
28
|
-
> **0.
|
|
28
|
+
> **0.4.1 is published on npm.** Create a project with `npx create-vibe-maestro@latest`. Every generated project records the exact Maestro version in `.claude/rules/maestro.md`, so its checks do not change under it when a new version is published; `vibe-maestro upgrade` moves it forward when you decide. Interfaces may still change before 1.0. The CLI and generated project templates are Russian-first; English localization is planned before a global release.
|
|
29
29
|
|
|
30
30
|
When an AI-assisted project lasts longer than one chat, the same problems keep returning:
|
|
31
31
|
|
|
@@ -144,11 +144,11 @@ My Project/
|
|
|
144
144
|
├── AGENTS.md # yours: entry for Codex and other AGENTS.md tools
|
|
145
145
|
├── CLAUDE.md # yours: project instructions for Claude Code
|
|
146
146
|
├── .claude/rules/ # maestro.md (Maestro rules, loaded every session) + project.md (yours)
|
|
147
|
-
├── .claude/settings.json # yours: default deny/ask rules (
|
|
147
|
+
├── .claude/settings.json # yours: default deny/ask rules (Maestro files, push, publish)
|
|
148
148
|
├── .claude/commands/ # /status, /plan, /build, /wiki, /handoff adapters
|
|
149
149
|
├── .claude/agents/ # read-only code-reviewer and explorer
|
|
150
|
-
├── protocols/ # canonical rules for planning, building and
|
|
151
|
-
├── wiki/ # shared memory: plans, decisions, progress and
|
|
150
|
+
├── protocols/ # canonical rules for planning, building, handoff and project completion
|
|
151
|
+
├── wiki/ # shared memory: plans, decisions, progress, audits and the project passport
|
|
152
152
|
├── maestro/ # inbox, runbooks, and templates for handoff, ADR and progress
|
|
153
153
|
└── .maestro/ # manifest, ownership inventory and integrity metadata
|
|
154
154
|
```
|
|
@@ -177,7 +177,7 @@ From there, `protocols/build.md` routes the agent through the relevant rules, pl
|
|
|
177
177
|
|
|
178
178
|
## A normal working cycle
|
|
179
179
|
|
|
180
|
-
The guided path above is the whole cycle: material in `maestro/inbox/` → plan → human approval → one bounded build with tests and live evidence → `doctor` → handoff. Independent audit findings are recorded with stable IDs; open `high` or `critical` findings block a green doctor result.
|
|
180
|
+
The guided path above is the whole cycle: material in `maestro/inbox/` → plan → human approval → one bounded build with tests and live evidence → `doctor` → handoff, then a new session for the next slice (`vibe-maestro context` tells the agent how large the session has grown). When the last slice is done, `protocols/completion.md` walks through delivery or closing: criteria checked, tests green, a delivery tag, a complete project passport (`wiki/passport.md`: where everything lives, names of environment variables but never their values), customer documents, a final handoff; `vibe-maestro pack` builds the customer archive from the delivery tag. Independent audit findings are recorded with stable IDs; open `high` or `critical` findings block a green doctor result.
|
|
181
181
|
|
|
182
182
|
Claude Code projects receive five thin commands:
|
|
183
183
|
|
|
@@ -201,8 +201,10 @@ Maestro is deliberately conservative around existing data and Git state:
|
|
|
201
201
|
- `doctor --strict` also treats warnings as blocking;
|
|
202
202
|
- audit findings must be resolved with evidence; `waived` is not accepted by the 0.3 contract;
|
|
203
203
|
- when the approval digest is recorded (the protocol asks the agent to), a later change of the plan text or its classification closes the gate until a human approves again — a tripwire, not a lock;
|
|
204
|
-
- `.claude/settings.json` ships default rules for Claude Code: its file tools are denied
|
|
204
|
+
- `.claude/settings.json` ships default rules for Claude Code: its file tools are denied Maestro files, and `git push`, `npm publish`, `rm -rf` and `git reset --hard` ask first; this is not a sandbox, and the file belongs to the project, so a team can change the rules — see [how to tune protections for a project](docs/USER_GUIDE.md#как-подстроить-защиты-под-проект) (Russian);
|
|
205
|
+
- API keys live only in `.env`, which `.gitignore` excludes and `doctor` reports if Git tracks it; the agent writes a key you paste into `.env` itself, or opens `.env` in an editor for you to paste it (a key typed into the chat stays in the session history);
|
|
205
206
|
- `sources` reads existing code read-only and writes nothing without an explicit `--write`;
|
|
207
|
+
- `pack` builds the customer archive only from a delivery tag, leaves Maestro and agent folders out, adds `HANDOVER.md` with «change all passwords and keys», refuses on common kinds of secrets (a sieve, not a guarantee) or an incomplete passport, and gives the same bytes for the same tag;
|
|
206
208
|
- `upgrade` is a dry run without `--apply`, refuses a modified managed file, and rolls back a failed apply;
|
|
207
209
|
- generated projects pin the exact Maestro version instead of `@latest`, so a new release cannot change a project's checks until someone runs `upgrade`;
|
|
208
210
|
- there is intentionally no `doctor --fix` that could overwrite useful work.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { FINISH_SLICE_SHARE, measureContext, NEW_SESSION_SHARE } from '../core/context.js';
|
|
2
|
+
import { EXIT_FAILED, EXIT_OK } from './io.js';
|
|
3
|
+
/** Тысячи через пробел, без зависимости от локали машины. */
|
|
4
|
+
export function formatTokens(value) {
|
|
5
|
+
return String(Math.round(value)).replace(/\B(?=(\d{3})+(?!\d))/g, ' ');
|
|
6
|
+
}
|
|
7
|
+
/** «1 токен», «2 токена», «5 токенов». */
|
|
8
|
+
export function tokensWord(value) {
|
|
9
|
+
const n = Math.abs(Math.round(value));
|
|
10
|
+
if (n % 10 === 1 && n % 100 !== 11)
|
|
11
|
+
return 'токен';
|
|
12
|
+
if ([2, 3, 4].includes(n % 10) && ![12, 13, 14].includes(n % 100))
|
|
13
|
+
return 'токена';
|
|
14
|
+
return 'токенов';
|
|
15
|
+
}
|
|
16
|
+
const ADVICE = {
|
|
17
|
+
continue: 'Можно продолжать в этой сессии.',
|
|
18
|
+
'finish-slice': 'Порцию лучше закончить в этой сессии, а следующую начать в новой — после передачи дел (/handoff).',
|
|
19
|
+
'new-session': 'Пора в новую сессию: сделайте передачу дел (/handoff) сейчас и продолжайте в новой.',
|
|
20
|
+
};
|
|
21
|
+
export async function executeContextCommand(options, io) {
|
|
22
|
+
const report = await measureContext({ root: options.path, ...(options.window === undefined ? {} : { budget: options.window }) });
|
|
23
|
+
if (options.json) {
|
|
24
|
+
io.out(JSON.stringify(report, null, 2));
|
|
25
|
+
return report.ok ? EXIT_OK : EXIT_FAILED;
|
|
26
|
+
}
|
|
27
|
+
if (!report.ok || report.level === undefined) {
|
|
28
|
+
io.err(`Vibe Coding Maestro context: ${report.message ?? 'размер сессии не измерен.'}`);
|
|
29
|
+
return EXIT_FAILED;
|
|
30
|
+
}
|
|
31
|
+
const tokens = report.contextTokens ?? 0;
|
|
32
|
+
io.out(`Размер сессии: ${formatTokens(tokens)} ${tokensWord(tokens)} (${report.percent}% окна модели в ${formatTokens(report.budget)}).`);
|
|
33
|
+
io.out(ADVICE[report.level]);
|
|
34
|
+
const total = report.totalInputTokens ?? 0;
|
|
35
|
+
io.out(`За сессию модель получила на вход ${formatTokens(total)} ${tokensWord(total)} (шагов модели: ${report.requests}): каждый шаг заново пересылает всю историю.`);
|
|
36
|
+
io.out(`Пороги ${Math.round(FINISH_SLICE_SHARE * 100)}% и ${Math.round(NEW_SESSION_SHARE * 100)}% — гипотеза; их уточнит замер.`);
|
|
37
|
+
return EXIT_OK;
|
|
38
|
+
}
|
package/dist/cli/maestro.js
CHANGED
|
@@ -13,6 +13,8 @@ const HELP = `${PRODUCT_NAME} — служебный CLI проекта.
|
|
|
13
13
|
sources read-only инвентаризация существующих исходников для планирования
|
|
14
14
|
upgrade предложение обновления канонического проекта прошлой версии
|
|
15
15
|
preflight механическая проверка права начинать код по активному плану
|
|
16
|
+
pack архив тега сдачи для заказчика: без папок Maestro, с HANDOVER.md
|
|
17
|
+
context размер текущей сессии Claude Code: пора ли в новую сессию
|
|
16
18
|
|
|
17
19
|
Общие опции команд:
|
|
18
20
|
--path <путь> корень проверяемого проекта (по умолчанию текущая папка)
|
|
@@ -30,6 +32,14 @@ const HELP = `${PRODUCT_NAME} — служебный CLI проекта.
|
|
|
30
32
|
Опции upgrade:
|
|
31
33
|
--apply выполнить обновление; без флага это только dry-run
|
|
32
34
|
|
|
35
|
+
Опции pack:
|
|
36
|
+
--tag <тег> тег сдачи (обязательно)
|
|
37
|
+
--out <файл> куда записать архив (по умолчанию — Рабочий стол)
|
|
38
|
+
--allow <путь> файл, который человек проверил: не секрет; флаг можно повторять
|
|
39
|
+
|
|
40
|
+
Опции context:
|
|
41
|
+
--window <токены> окно модели в токенах (по умолчанию 200000, у длинной сессии 1000000)
|
|
42
|
+
|
|
33
43
|
Опции preflight:
|
|
34
44
|
--scale <масштаб> ${PLAN_SCALES.join(' | ')} (по умолчанию feature)
|
|
35
45
|
--quick <критерии> через запятую: ${QUICK_CRITERIA.join(', ')}
|
|
@@ -37,7 +47,7 @@ const HELP = `${PRODUCT_NAME} — служебный CLI проекта.
|
|
|
37
47
|
Общие опции:
|
|
38
48
|
--help, -h эта справка
|
|
39
49
|
--version, -v версия`;
|
|
40
|
-
const COMMANDS = ['doctor', 'skills', 'sources', 'upgrade', 'preflight'];
|
|
50
|
+
const COMMANDS = ['doctor', 'skills', 'sources', 'upgrade', 'preflight', 'pack', 'context'];
|
|
41
51
|
const isCommand = (value) => COMMANDS.includes(value);
|
|
42
52
|
export function parseMaestroArgs(argv) {
|
|
43
53
|
if (argv.length === 0)
|
|
@@ -138,6 +148,51 @@ export function parseMaestroArgs(argv) {
|
|
|
138
148
|
i += 1;
|
|
139
149
|
break;
|
|
140
150
|
}
|
|
151
|
+
case '--tag': {
|
|
152
|
+
const message = only(arg, 'pack');
|
|
153
|
+
if (message !== null)
|
|
154
|
+
return { kind: 'error', message };
|
|
155
|
+
const tag = value();
|
|
156
|
+
if (tag === undefined)
|
|
157
|
+
return { kind: 'error', message: `Флаг ${arg} требует значение.` };
|
|
158
|
+
options.tag = tag;
|
|
159
|
+
i += 1;
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
case '--out': {
|
|
163
|
+
const message = only(arg, 'pack');
|
|
164
|
+
if (message !== null)
|
|
165
|
+
return { kind: 'error', message };
|
|
166
|
+
const out = value();
|
|
167
|
+
if (out === undefined)
|
|
168
|
+
return { kind: 'error', message: `Флаг ${arg} требует значение.` };
|
|
169
|
+
options.out = out;
|
|
170
|
+
i += 1;
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
case '--allow': {
|
|
174
|
+
const message = only(arg, 'pack');
|
|
175
|
+
if (message !== null)
|
|
176
|
+
return { kind: 'error', message };
|
|
177
|
+
const allow = value();
|
|
178
|
+
if (allow === undefined)
|
|
179
|
+
return { kind: 'error', message: `Флаг ${arg} требует значение.` };
|
|
180
|
+
options.allow = [...(options.allow ?? []), allow.split('\\').join('/')];
|
|
181
|
+
i += 1;
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
case '--window': {
|
|
185
|
+
const message = only(arg, 'context');
|
|
186
|
+
if (message !== null)
|
|
187
|
+
return { kind: 'error', message };
|
|
188
|
+
const raw = value();
|
|
189
|
+
const window = raw === undefined ? Number.NaN : Number(raw);
|
|
190
|
+
if (!Number.isInteger(window) || window <= 0)
|
|
191
|
+
return { kind: 'error', message: `Флаг ${arg} требует целое число токенов больше нуля.` };
|
|
192
|
+
options.window = window;
|
|
193
|
+
i += 1;
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
141
196
|
case '--path': {
|
|
142
197
|
const path = value();
|
|
143
198
|
if (path === undefined)
|
|
@@ -152,6 +207,9 @@ export function parseMaestroArgs(argv) {
|
|
|
152
207
|
return { kind: 'error', message: `Лишний аргумент: ${arg}` };
|
|
153
208
|
}
|
|
154
209
|
}
|
|
210
|
+
if (first === 'pack' && options.tag === undefined) {
|
|
211
|
+
return { kind: 'error', message: 'Команда pack требует --tag <тег сдачи>.' };
|
|
212
|
+
}
|
|
155
213
|
if (first === 'sources') {
|
|
156
214
|
if ((options.sources ?? []).length === 0) {
|
|
157
215
|
return { kind: 'error', message: 'Команда sources требует хотя бы один --source <путь>.' };
|
|
@@ -193,6 +251,14 @@ export async function runMaestroCli(argv, io = processIo) {
|
|
|
193
251
|
const { executeSourcesCommand } = await import('./sources-run.js');
|
|
194
252
|
return executeSourcesCommand({ ...parsed.options, sources: parsed.options.sources ?? [] }, io);
|
|
195
253
|
}
|
|
254
|
+
if (parsed.kind === 'pack') {
|
|
255
|
+
const { executePackCommand } = await import('./pack-run.js');
|
|
256
|
+
return executePackCommand({ ...parsed.options, tag: parsed.options.tag }, io);
|
|
257
|
+
}
|
|
258
|
+
if (parsed.kind === 'context') {
|
|
259
|
+
const { executeContextCommand } = await import('./context-run.js');
|
|
260
|
+
return executeContextCommand(parsed.options, io);
|
|
261
|
+
}
|
|
196
262
|
if (parsed.kind === 'preflight') {
|
|
197
263
|
const { executePreflightCommand } = await import('./preflight-run.js');
|
|
198
264
|
return executePreflightCommand(parsed.options, io);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { dirname, join, resolve } from 'node:path';
|
|
3
|
+
import { defaultArchiveName, packProject } from '../core/pack.js';
|
|
4
|
+
import { resolveDesktopDirectory } from './desktop.js';
|
|
5
|
+
import { homedir } from 'node:os';
|
|
6
|
+
import { EXIT_FAILED, EXIT_OK } from './io.js';
|
|
7
|
+
/** Архив по умолчанию кладётся на Рабочий стол: его оттуда отправляют заказчику. Нет Рабочего стола — рядом с проектом. */
|
|
8
|
+
async function defaultOut(root, tag) {
|
|
9
|
+
const name = defaultArchiveName(root, tag);
|
|
10
|
+
try {
|
|
11
|
+
const desktop = await resolveDesktopDirectory({ platform: process.platform, home: homedir() });
|
|
12
|
+
if (existsSync(desktop))
|
|
13
|
+
return join(desktop, name);
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
// без домашней папки — рядом с проектом
|
|
17
|
+
}
|
|
18
|
+
return join(dirname(resolve(root)), name);
|
|
19
|
+
}
|
|
20
|
+
export async function executePackCommand(options, io) {
|
|
21
|
+
const out = options.out === undefined ? await defaultOut(options.path, options.tag) : resolve(options.out);
|
|
22
|
+
const result = await packProject({ root: options.path, tag: options.tag, out, allow: options.allow ?? [] });
|
|
23
|
+
if (options.json) {
|
|
24
|
+
io.out(JSON.stringify({ reportVersion: 1, ...result }, null, 2));
|
|
25
|
+
return result.ok ? EXIT_OK : EXIT_FAILED;
|
|
26
|
+
}
|
|
27
|
+
if (!result.ok) {
|
|
28
|
+
io.err('Vibe Coding Maestro pack: архив не создан.');
|
|
29
|
+
for (const item of result.findings)
|
|
30
|
+
io.err(`- ${item.code}${item.path ? ` (${item.path})` : ''}: ${item.message}`);
|
|
31
|
+
return EXIT_FAILED;
|
|
32
|
+
}
|
|
33
|
+
io.out(result.reused === true
|
|
34
|
+
? `Архив тега ${result.tag} уже лежит здесь и совпадает побайтово: ${result.archive}`
|
|
35
|
+
: `Архив тега ${result.tag} готов: ${result.archive}`);
|
|
36
|
+
io.out(`Файлов: ${result.files}, размер: ${result.bytes} байт, sha256: ${result.sha256}`);
|
|
37
|
+
io.out('Не вошли: wiki/, maestro/, .claude/, protocols/, .maestro/, CLAUDE.md, AGENTS.md, .mcp.json. В корне архива — HANDOVER.md: первым делом заказчик меняет все пароли и ключи.');
|
|
38
|
+
for (const note of result.notes ?? [])
|
|
39
|
+
io.out(note);
|
|
40
|
+
if ((options.allow ?? []).length > 0)
|
|
41
|
+
io.out(`Без проверки на секреты по решению человека: ${(options.allow ?? []).join(', ')}.`);
|
|
42
|
+
io.out('Перед отправкой откройте архив и проверьте HANDOVER.md. Отправка заказчику — только после «да» человека.');
|
|
43
|
+
return EXIT_OK;
|
|
44
|
+
}
|
package/dist/cli/upgrade-run.js
CHANGED
|
@@ -55,7 +55,7 @@ export async function executeUpgradeCommand(options, io) {
|
|
|
55
55
|
}
|
|
56
56
|
io.out(`Предложение обновления ${analysis.fromVersion ?? analysis.baselineId} → ${analysis.toVersion} (ни один байт не записан).`);
|
|
57
57
|
list('Будет добавлено', analysis.creates.map((item) => item.path));
|
|
58
|
-
list('Будет обновлено', analysis.updates.map((item) => item.path));
|
|
58
|
+
list('Будет обновлено', analysis.updates.map((item) => item.appends === undefined ? item.path : `${item.path} — допишет строки: ${item.appends.join(', ')}`));
|
|
59
59
|
list('Перейдёт к проекту (дальше файл ваш, Maestro его не проверяет и не перезаписывает)', analysis.handedOver);
|
|
60
60
|
list('Уже совпадает', analysis.unchanged);
|
|
61
61
|
list('Останется без изменений', analysis.preserves);
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { open, readdir, readFile, stat } from 'node:fs/promises';
|
|
3
|
+
import { homedir } from 'node:os';
|
|
4
|
+
import { join, resolve } from 'node:path';
|
|
5
|
+
/**
|
|
6
|
+
* Размер текущей сессии Claude Code по её журналу `~/.claude/projects/<папка>/<сессия>.jsonl`.
|
|
7
|
+
*
|
|
8
|
+
* Читаются только числа из `message.usage` ответов модели: текст переписки не
|
|
9
|
+
* разбирается и не печатается. Каждый шаг сессии заново отправляет модели всю
|
|
10
|
+
* историю, поэтому длинная сессия дорожает с каждым шагом.
|
|
11
|
+
*/
|
|
12
|
+
/** Окно модели по умолчанию. Сессия больше него была бы невозможна — тогда окно 1 000 000. */
|
|
13
|
+
export const DEFAULT_BUDGET = 200_000;
|
|
14
|
+
export const LARGE_WINDOW = 1_000_000;
|
|
15
|
+
/** HYPOTHESIS: пороги подобраны на глаз и уточняются повторным замером. */
|
|
16
|
+
export const FINISH_SLICE_SHARE = 0.4;
|
|
17
|
+
export const NEW_SESSION_SHARE = 0.7;
|
|
18
|
+
/** Имя папки журналов: Claude Code заменяет в пути проекта всё, кроме латиницы и цифр, на `-`. */
|
|
19
|
+
export function projectLogDirName(root) {
|
|
20
|
+
return resolve(root).replace(/[^a-zA-Z0-9]/g, '-');
|
|
21
|
+
}
|
|
22
|
+
async function newestJsonl(dir) {
|
|
23
|
+
let names;
|
|
24
|
+
try {
|
|
25
|
+
names = (await readdir(dir)).filter((name) => name.endsWith('.jsonl'));
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
let best = null;
|
|
31
|
+
for (const name of names) {
|
|
32
|
+
const path = join(dir, name);
|
|
33
|
+
const { mtimeMs } = await stat(path);
|
|
34
|
+
if (best === null || mtimeMs > best.mtime || (mtimeMs === best.mtime && path > best.path))
|
|
35
|
+
best = { path, mtime: mtimeMs };
|
|
36
|
+
}
|
|
37
|
+
return best?.path ?? null;
|
|
38
|
+
}
|
|
39
|
+
async function tail(path, bytes) {
|
|
40
|
+
const handle = await open(path, 'r');
|
|
41
|
+
try {
|
|
42
|
+
const { size } = await handle.stat();
|
|
43
|
+
const length = Math.min(size, bytes);
|
|
44
|
+
const buffer = Buffer.alloc(length);
|
|
45
|
+
await handle.read(buffer, 0, length, size - length);
|
|
46
|
+
return buffer.toString('utf8');
|
|
47
|
+
}
|
|
48
|
+
finally {
|
|
49
|
+
await handle.close();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Журнал текущей сессии. Известен id сессии — её файл `<id>.jsonl`. Иначе самый
|
|
54
|
+
* свежий журнал в папке проекта. Длинные и не-латинские пути Claude Code может
|
|
55
|
+
* назвать иначе, поэтому запасной путь — самый свежий журнал с той же рабочей папкой.
|
|
56
|
+
*/
|
|
57
|
+
export async function findTranscript(root, claudeDir, sessionId) {
|
|
58
|
+
const projects = join(claudeDir, 'projects');
|
|
59
|
+
if (sessionId !== undefined) {
|
|
60
|
+
// Известна сессия — только её журнал: молча мерить другую сессию нельзя.
|
|
61
|
+
if (!/^[A-Za-z0-9-]+$/.test(sessionId))
|
|
62
|
+
return null;
|
|
63
|
+
const own = join(projects, projectLogDirName(root), `${sessionId}.jsonl`);
|
|
64
|
+
if (existsSync(own))
|
|
65
|
+
return own;
|
|
66
|
+
for (const dir of await readdir(projects).catch(() => [])) {
|
|
67
|
+
const candidate = join(projects, dir, `${sessionId}.jsonl`);
|
|
68
|
+
if (existsSync(candidate))
|
|
69
|
+
return candidate;
|
|
70
|
+
}
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
const direct = await newestJsonl(join(projects, projectLogDirName(root)));
|
|
74
|
+
if (direct !== null)
|
|
75
|
+
return direct;
|
|
76
|
+
let dirs;
|
|
77
|
+
try {
|
|
78
|
+
dirs = await readdir(projects);
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
const marker = `"cwd":${JSON.stringify(resolve(root))}`;
|
|
84
|
+
let best = null;
|
|
85
|
+
for (const dir of dirs) {
|
|
86
|
+
const candidate = await newestJsonl(join(projects, dir));
|
|
87
|
+
if (candidate === null)
|
|
88
|
+
continue;
|
|
89
|
+
if (!(await tail(candidate, 256 * 1024)).includes(marker))
|
|
90
|
+
continue;
|
|
91
|
+
const { mtimeMs } = await stat(candidate);
|
|
92
|
+
if (best === null || mtimeMs > best.mtime)
|
|
93
|
+
best = { path: candidate, mtime: mtimeMs };
|
|
94
|
+
}
|
|
95
|
+
return best?.path ?? null;
|
|
96
|
+
}
|
|
97
|
+
const count = (value) => (typeof value === 'number' && Number.isFinite(value) && value > 0 ? value : 0);
|
|
98
|
+
export function levelFor(share) {
|
|
99
|
+
if (share >= NEW_SESSION_SHARE)
|
|
100
|
+
return 'new-session';
|
|
101
|
+
if (share >= FINISH_SLICE_SHARE)
|
|
102
|
+
return 'finish-slice';
|
|
103
|
+
return 'continue';
|
|
104
|
+
}
|
|
105
|
+
export async function measureContext(options) {
|
|
106
|
+
let budget = options.budget ?? DEFAULT_BUDGET;
|
|
107
|
+
const claudeDir = options.claudeDir ?? (process.env.CLAUDE_CONFIG_DIR || join(homedir(), '.claude'));
|
|
108
|
+
const sessionId = options.sessionId ?? (process.env.CLAUDE_CODE_SESSION_ID || undefined);
|
|
109
|
+
const transcript = await findTranscript(options.root, claudeDir, sessionId);
|
|
110
|
+
if (transcript === null) {
|
|
111
|
+
if (sessionId !== undefined) {
|
|
112
|
+
return { reportVersion: 1, ok: false, budget, message: `Журнал сессии ${sessionId} не найден в ${join(claudeDir, 'projects')}: измерять чужую сессию вместо неё команда не будет.` };
|
|
113
|
+
}
|
|
114
|
+
return { reportVersion: 1, ok: false, budget, message: `Журнал сессии Claude Code для этой папки не найден (искал в ${join(claudeDir, 'projects')}). Команда работает внутри сессии Claude Code, открытой в папке проекта.` };
|
|
115
|
+
}
|
|
116
|
+
const seen = new Set();
|
|
117
|
+
let last = null;
|
|
118
|
+
let totalInput = 0;
|
|
119
|
+
let largest = 0;
|
|
120
|
+
let recordedSession;
|
|
121
|
+
for (const line of (await readFile(transcript, 'utf8')).split('\n')) {
|
|
122
|
+
if (line.trim() === '')
|
|
123
|
+
continue;
|
|
124
|
+
let entry;
|
|
125
|
+
try {
|
|
126
|
+
entry = JSON.parse(line);
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
continue; // незаконченная последняя строка, пока сессия пишет журнал
|
|
130
|
+
}
|
|
131
|
+
if (entry.type !== 'assistant' || entry.isSidechain === true)
|
|
132
|
+
continue;
|
|
133
|
+
const usage = entry.message?.usage;
|
|
134
|
+
const id = entry.message?.id;
|
|
135
|
+
if (usage === undefined || typeof id !== 'string')
|
|
136
|
+
continue;
|
|
137
|
+
if (typeof entry.sessionId === 'string')
|
|
138
|
+
recordedSession = entry.sessionId;
|
|
139
|
+
const size = count(usage.input_tokens) + count(usage.cache_read_input_tokens) + count(usage.cache_creation_input_tokens) + count(usage.output_tokens);
|
|
140
|
+
// Служебные записи без расхода (`<synthetic>`) не говорят о размере контекста.
|
|
141
|
+
if (size === 0)
|
|
142
|
+
continue;
|
|
143
|
+
last = usage;
|
|
144
|
+
largest = Math.max(largest, size);
|
|
145
|
+
if (seen.has(id))
|
|
146
|
+
continue;
|
|
147
|
+
seen.add(id);
|
|
148
|
+
totalInput += count(usage.input_tokens) + count(usage.cache_read_input_tokens) + count(usage.cache_creation_input_tokens);
|
|
149
|
+
}
|
|
150
|
+
if (last === null) {
|
|
151
|
+
return { reportVersion: 1, ok: false, budget, transcript, message: 'В журнале сессии пока нет ни одного ответа модели.' };
|
|
152
|
+
}
|
|
153
|
+
const contextTokens = count(last.input_tokens) + count(last.cache_read_input_tokens) + count(last.cache_creation_input_tokens) + count(last.output_tokens);
|
|
154
|
+
if (options.budget === undefined && largest > DEFAULT_BUDGET)
|
|
155
|
+
budget = LARGE_WINDOW;
|
|
156
|
+
const share = contextTokens / budget;
|
|
157
|
+
return {
|
|
158
|
+
reportVersion: 1,
|
|
159
|
+
ok: true,
|
|
160
|
+
transcript,
|
|
161
|
+
...(recordedSession === undefined ? {} : { sessionId: recordedSession }),
|
|
162
|
+
contextTokens,
|
|
163
|
+
budget,
|
|
164
|
+
percent: Math.round(share * 100),
|
|
165
|
+
level: levelFor(share),
|
|
166
|
+
totalInputTokens: totalInput,
|
|
167
|
+
requests: seen.size,
|
|
168
|
+
};
|
|
169
|
+
}
|
package/dist/core/gitignore.js
CHANGED
|
@@ -13,6 +13,8 @@ export const REQUIRED_GITIGNORE_ENTRIES = [
|
|
|
13
13
|
'!.env.example',
|
|
14
14
|
'*.log',
|
|
15
15
|
'.DS_Store',
|
|
16
|
+
'.claude/worktrees/',
|
|
17
|
+
'.claude/settings.local.json',
|
|
16
18
|
];
|
|
17
19
|
const BLOCK_HEADER = `# --- ${PRODUCT_NAME} ---`;
|
|
18
20
|
/**
|
|
@@ -57,6 +59,15 @@ export function mergeGitignore(existing, requiredEntries = REQUIRED_GITIGNORE_EN
|
|
|
57
59
|
if (addedEntries.length === 0) {
|
|
58
60
|
return { content: base, created, changed: created && base !== source, addedEntries };
|
|
59
61
|
}
|
|
62
|
+
// Файл кончается блоком Maestro — недостающие строки продолжают его, второго заголовка нет.
|
|
63
|
+
const lines = source.split(/\r?\n/);
|
|
64
|
+
const header = lines.lastIndexOf(BLOCK_HEADER);
|
|
65
|
+
const required = new Set(requiredEntries.map(normalizeEntry));
|
|
66
|
+
// Свой комментарий проекта после блока — уже не блок Maestro: тогда новый заголовок.
|
|
67
|
+
const endsWithBlock = header >= 0 && lines.slice(header + 1).every((line) => line.trim() === '' || required.has(normalizeEntry(line)));
|
|
68
|
+
if (endsWithBlock) {
|
|
69
|
+
return { content: base + addedEntries.join(eol) + eol, created, changed: true, addedEntries };
|
|
70
|
+
}
|
|
60
71
|
const block = [];
|
|
61
72
|
if (base !== '')
|
|
62
73
|
block.push('');
|
package/dist/core/inventory.js
CHANGED
|
@@ -28,6 +28,7 @@ export const TEMPLATE_FILES = [
|
|
|
28
28
|
'protocols/context-budget.md',
|
|
29
29
|
'protocols/seams.md',
|
|
30
30
|
'protocols/lessons.md',
|
|
31
|
+
'protocols/completion.md',
|
|
31
32
|
'protocols/build/step-1-rules.md',
|
|
32
33
|
'protocols/build/step-2-spec.md',
|
|
33
34
|
'protocols/build/step-3-architecture.md',
|
|
@@ -45,6 +46,7 @@ export const CONTENT_OWNED_FILES = [
|
|
|
45
46
|
'wiki/hot.md',
|
|
46
47
|
'wiki/log.md',
|
|
47
48
|
'wiki/roadmap.md',
|
|
49
|
+
'wiki/passport.md',
|
|
48
50
|
'wiki/concepts/discovery.md',
|
|
49
51
|
'wiki/plans/0001-starter.md',
|
|
50
52
|
];
|