the-crew 0.1.0 → 0.3.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.
Files changed (52) hide show
  1. package/README.md +141 -58
  2. package/core/agents/README.md +1 -1
  3. package/core/agents/desenvolve/frontend-dev.md +4 -3
  4. package/core/agents/planeja/ux-ui-design.md +2 -1
  5. package/core/skills/crew-gates/SKILL.md +1 -1
  6. package/core/skills/crew-obsidian/SKILL.md +2 -2
  7. package/core/skills/db-organizer/SKILL.md +1 -1
  8. package/core/skills/manifest.json +791 -0
  9. package/core/skills/new-project/SKILL.md +27 -0
  10. package/core/skills/po-backlog/SKILL.md +1 -1
  11. package/core/skills/projects/SKILL.md +10 -0
  12. package/dist/src/cli/commands/exec.js +1 -1
  13. package/dist/src/cli/commands/install.js +300 -0
  14. package/dist/src/cli/commands/new-project.js +86 -0
  15. package/dist/src/cli/commands/projects.js +24 -0
  16. package/dist/src/cli/commands/uninstall.js +308 -0
  17. package/dist/src/cli/commands/validate.js +6 -5
  18. package/dist/src/cli/index.js +26 -21
  19. package/dist/src/cli/lib/args.js +99 -41
  20. package/dist/src/cli/lib/common.js +120 -0
  21. package/dist/src/cli/lib/credentials.js +26 -0
  22. package/dist/src/cli/lib/github.js +36 -0
  23. package/dist/src/cli/lib/install-record.js +39 -0
  24. package/dist/src/cli/lib/legacy.js +230 -0
  25. package/dist/src/cli/lib/plans.js +251 -0
  26. package/dist/src/cli/lib/registry.js +21 -0
  27. package/dist/src/cli/lib/skills.js +186 -0
  28. package/dist/src/cli/lib/writer.js +13 -2
  29. package/package.json +10 -3
  30. package/templates/obsidian/{00 Painel.md → project/00 Painel.md } +4 -6
  31. package/templates/obsidian/team/00 Time.md +20 -0
  32. package/templates/office/AGENTS.md +12 -0
  33. package/templates/office/README.md +15 -0
  34. package/templates/project/AGENTS.md +5 -0
  35. package/templates/project/PROJECT.md +31 -0
  36. package/templates/rules/team.md +14 -0
  37. package/core/skills/catalog.json +0 -30
  38. package/dist/src/cli/commands/init.js +0 -185
  39. package/dist/src/cli/lib/plan.js +0 -300
  40. package/templates/docs/PROJECT.md +0 -36
  41. package/templates/entrypoints/crew-block.md +0 -28
  42. package/templates/entrypoints/cursor.mdc +0 -6
  43. package/templates/entrypoints/obsidian-rules.md +0 -18
  44. package/templates/entrypoints/windsurf.md +0 -5
  45. package/templates/workflows/crew-integrity.yml +0 -24
  46. /package/templates/obsidian/{_templates → team/_templates}/ADR.md +0 -0
  47. /package/templates/obsidian/{_templates → team/_templates}/Achado de seguranca.md +0 -0
  48. /package/templates/obsidian/{_templates → team/_templates}/Bug.md +0 -0
  49. /package/templates/obsidian/{_templates → team/_templates}/Handoff.md +0 -0
  50. /package/templates/obsidian/{_templates → team/_templates}/Historia.md +0 -0
  51. /package/templates/obsidian/{_templates → team/_templates}/Release.md +0 -0
  52. /package/templates/obsidian/{_templates → team/_templates}/Run.md +0 -0
@@ -0,0 +1,308 @@
1
+ import { existsSync, lstatSync, readdirSync, readFileSync, readlinkSync, rmdirSync, rmSync, unlinkSync, writeFileSync } from 'node:fs';
2
+ import { dirname, join, relative, resolve, sep } from 'node:path';
3
+ import { mcpServers } from '../lib/common.js';
4
+ import { configDir, credentialsPath, globalConfigPath, readCredentials, readGlobalConfig, userHome } from '../lib/credentials.js';
5
+ import { installRecordPath, readInstallRecord, sha256 } from '../lib/install-record.js';
6
+ import { planAssistants, vaultTeamDir } from '../lib/plans.js';
7
+ import { projectList, readRegistry } from '../lib/registry.js';
8
+ import { loadManifest, skillRulesByAgent, skillsByAgent } from '../lib/skills.js';
9
+ import { removeBlock } from '../lib/writer.js';
10
+ import { applyLegacy, displayRel, findLegacyProjects, onlyGitLeft, planLegacy } from '../lib/legacy.js';
11
+ import { loadTopology } from '../../validate/topology.js';
12
+ import { packageRoot } from '../lib/paths.js';
13
+ import { buildCtx, normalizeUserPath } from './install.js';
14
+ function isInside(child, parent) {
15
+ const rel = relative(parent, child);
16
+ return rel !== '' && !rel.startsWith('..') && !rel.startsWith(sep) && !/^[A-Za-z]:/.test(rel);
17
+ }
18
+ function lstat(p) {
19
+ try {
20
+ return lstatSync(p);
21
+ }
22
+ catch {
23
+ return undefined;
24
+ }
25
+ }
26
+ function sameJson(a, b) {
27
+ return JSON.stringify(a) === JSON.stringify(b);
28
+ }
29
+ /** Remove pastas vazias de `start` até `stop` (exclusive). */
30
+ function pruneEmpty(start, stop) {
31
+ let d = start;
32
+ while (isInside(d, stop)) {
33
+ try {
34
+ if (readdirSync(d).length > 0)
35
+ return;
36
+ rmdirSync(d);
37
+ }
38
+ catch {
39
+ return;
40
+ }
41
+ d = dirname(d);
42
+ }
43
+ }
44
+ function removeLink(p) {
45
+ try {
46
+ unlinkSync(p);
47
+ }
48
+ catch {
49
+ rmdirSync(p); // junction no Windows
50
+ }
51
+ }
52
+ /** Limpa o que a 0.1.0 deixou dentro de cada pasta onde foi instalada. */
53
+ async function runUninstallLegacy(flags, deps) {
54
+ const { prompter, log, env } = deps;
55
+ const home = userHome(env);
56
+ const roots = flags.paths?.length ? flags.paths.map((p) => normalizeUserPath(p, home)) : [...new Set([process.cwd(), home])];
57
+ log(`\nProcurando instalações da versão 0.1.0 (por projeto) em: ${roots.join(', ')}`);
58
+ const dirs = findLegacyProjects(roots, flags.paths?.length ? 6 : 4);
59
+ if (dirs.length === 0) {
60
+ log('Nenhuma encontrada. Se instalou numa pasta mais funda, passe o caminho: the-crew uninstall --legacy <pasta>');
61
+ return 0;
62
+ }
63
+ const ids = loadTopology(join(packageRoot(), 'core', 'contracts', 'topology.json')).agents.map((a) => a.id);
64
+ const plans = dirs.map((d) => planLegacy(d, ids));
65
+ for (const p of plans) {
66
+ const lines = ['', `${p.dir} (projeto "${p.projectName}"${p.current ? ', também é um projeto da versão atual' : ''})`];
67
+ for (const f of p.remove)
68
+ lines.push(` - ${displayRel(f, p.dir)}`);
69
+ for (const b of p.blocks)
70
+ lines.push(` - bloco the-crew de ${displayRel(b.path, p.dir)} (o resto fica)`);
71
+ for (const j of p.jsonKeys)
72
+ lines.push(` - ${j.keys.join(', ')} de ${displayRel(j.path, p.dir)} (os seus servidores ficam)`);
73
+ for (const k of p.keep)
74
+ lines.push(` = fica: ${displayRel(k.path, p.dir)} (${k.why})`);
75
+ if (p.vaultProjectDir)
76
+ lines.push(` ? notas no vault: ${p.vaultProjectDir}`);
77
+ log(lines.join('\n'));
78
+ }
79
+ log('\nNada fora dessas pastas é tocado. O git do projeto, o código e os arquivos seus ficam.');
80
+ if (flags.dryRun) {
81
+ log('\n(dry-run) Nada foi removido.');
82
+ return 0;
83
+ }
84
+ if (!flags.yes) {
85
+ if (!prompter.interactive) {
86
+ log('\nSem terminal interativo. Rode de novo com --yes para confirmar.');
87
+ return 1;
88
+ }
89
+ if (!(await prompter.confirm(`Limpar ${plans.length} pasta(s) acima?`, false))) {
90
+ log('Nada foi removido.');
91
+ return 0;
92
+ }
93
+ }
94
+ for (const p of plans) {
95
+ let removeVault = flags.removeVault && Boolean(p.vaultProjectDir && existsSync(p.vaultProjectDir));
96
+ if (!removeVault && p.vaultProjectDir && existsSync(p.vaultProjectDir) && prompter.interactive && !flags.yes) {
97
+ removeVault = await prompter.confirm(`Apagar também as notas de "${p.projectName}" no vault (${p.vaultProjectDir})?`, false);
98
+ }
99
+ applyLegacy(p, removeVault);
100
+ log(`✓ ${p.dir} limpo.${onlyGitLeft(p.dir) ? ' A pasta ficou só com o .git; se era só um teste, pode apagá-la.' : ''}`);
101
+ }
102
+ log('\nO token do GitHub e a instalação global (se houver) não foram tocados. Para removê-los: the-crew uninstall');
103
+ return 0;
104
+ }
105
+ /** Remove o que a instalação criou. Projetos nunca são tocados. */
106
+ export async function runUninstall(flags, deps) {
107
+ if (flags.legacy)
108
+ return runUninstallLegacy(flags, deps);
109
+ const { prompter, log, env } = deps;
110
+ const home = userHome(env);
111
+ const cfg = readGlobalConfig(env);
112
+ const creds = readCredentials(env);
113
+ const record = readInstallRecord(env);
114
+ if (!cfg && !creds.github && Object.keys(record.files).length === 0) {
115
+ log('O the-crew não está instalado nesta máquina (nenhuma configuração encontrada).');
116
+ return 0;
117
+ }
118
+ const ides = (cfg?.ides ?? ['claude-code', 'codex', 'cursor']);
119
+ const officeDir = cfg?.officeDir ?? join(home, 'the-crew');
120
+ const ctx = buildCtx(env, {
121
+ officeDir,
122
+ projectsDir: cfg?.projectsDir ?? join(home, 'projetos'),
123
+ vaultPath: cfg?.vaultPath ?? null,
124
+ ides,
125
+ mcp: (cfg?.mcp ?? []),
126
+ });
127
+ // Conteúdo esperado dos subagentes depende das skills instaladas.
128
+ let installedSkills = [];
129
+ let installedPlugins = [];
130
+ try {
131
+ const inst = JSON.parse(readFileSync(join(officeDir, 'skills', 'installed.json'), 'utf8'));
132
+ installedSkills = inst.installed ?? [];
133
+ installedPlugins = inst.plugins ?? [];
134
+ }
135
+ catch {
136
+ /* sem registro de skills */
137
+ }
138
+ const manifest = deps.skillManifest ?? loadManifest(ctx.pkgRoot);
139
+ const names = installedSkills.map((s) => s.name);
140
+ ctx.agentSkills = skillsByAgent(manifest, names);
141
+ ctx.agentSkillRules = skillRulesByAgent(manifest, names);
142
+ const plan = { files: [], modified: [], links: [], blocks: [], jsonKeys: [], plugins: [] };
143
+ const expected = new Map();
144
+ for (const w of planAssistants(ctx)) {
145
+ if (w.kind === 'file')
146
+ expected.set(w.path, sha256(w.content));
147
+ if (w.kind === 'block')
148
+ plan.blocks.push(w.path);
149
+ }
150
+ for (const [p, h] of Object.entries(record.files))
151
+ if (!expected.has(p))
152
+ expected.set(p, h);
153
+ for (const [p, h] of expected) {
154
+ const st = lstat(p);
155
+ if (!st?.isFile())
156
+ continue;
157
+ const current = sha256(readFileSync(p, 'utf8'));
158
+ if (current === h || current === record.files[p])
159
+ plan.files.push(p);
160
+ else
161
+ plan.modified.push(p);
162
+ }
163
+ plan.blocks = plan.blocks.filter((p) => existsSync(p) && removeBlock(readFileSync(p, 'utf8'), 'html').found);
164
+ for (const extra of [join(home, '.claude', 'CLAUDE.md'), join(home, '.codex', 'AGENTS.md')]) {
165
+ if (!plan.blocks.includes(extra) && existsSync(extra) && removeBlock(readFileSync(extra, 'utf8'), 'html').found)
166
+ plan.blocks.push(extra);
167
+ }
168
+ // Links de skills que apontam para o vendor do escritório.
169
+ const vendor = resolve(officeDir, 'vendor');
170
+ for (const d of [join(home, '.claude', 'skills'), join(home, '.agents', 'skills')]) {
171
+ if (!existsSync(d))
172
+ continue;
173
+ for (const name of readdirSync(d)) {
174
+ const p = join(d, name);
175
+ if (!lstat(p)?.isSymbolicLink())
176
+ continue;
177
+ if (isInside(resolve(d, readlinkSync(p)), vendor))
178
+ plan.links.push(p);
179
+ }
180
+ }
181
+ // Entradas de MCP adicionadas pelo the-crew.
182
+ const cursorMcp = join(home, '.cursor', 'mcp.json');
183
+ if (existsSync(cursorMcp)) {
184
+ try {
185
+ const data = JSON.parse(readFileSync(cursorMcp, 'utf8'));
186
+ const ours = mcpServers('cursor', ['github', 'context7', 'playwright']);
187
+ const recorded = record.jsonKeys[cursorMcp];
188
+ const keys = Object.keys(data.mcpServers ?? {}).filter((k) => recorded ? recorded.includes(k) && sameJson(data.mcpServers[k], ours[k]) : sameJson(data.mcpServers[k], ours[k]));
189
+ if (keys.length)
190
+ plan.jsonKeys.push({ path: cursorMcp, keys });
191
+ }
192
+ catch {
193
+ /* JSON inválido: não mexe */
194
+ }
195
+ }
196
+ plan.plugins = installedPlugins.filter((p) => p.status === 'installed').map((p) => p.name);
197
+ const officeExists = existsSync(officeDir);
198
+ const projects = officeExists ? projectList(readRegistry(officeDir)) : [];
199
+ const vaultDir = cfg?.vaultPath ? vaultTeamDir(cfg.vaultPath) : null;
200
+ const vaultExists = vaultDir ? existsSync(vaultDir) : false;
201
+ const rel = (p) => (isInside(p, home) ? `~/${relative(home, p).split(sep).join('/')}` : p);
202
+ const lines = ['', 'Desinstalar o the-crew. Vai ser removido:'];
203
+ if (plan.files.length)
204
+ lines.push(` · ${plan.files.length} arquivos gravados pelo the-crew (subagentes crew-*, skills e /comandos do time)`);
205
+ if (plan.links.length)
206
+ lines.push(` · ${plan.links.length} links de skills de terceiros em ~/.claude/skills e ~/.agents/skills`);
207
+ for (const b of plan.blocks)
208
+ lines.push(` · o bloco the-crew de ${rel(b)} (o resto do arquivo fica)`);
209
+ for (const j of plan.jsonKeys)
210
+ lines.push(` · ${j.keys.join(', ')} de ${rel(j.path)} (os seus servidores ficam)`);
211
+ if (existsSync(vendor))
212
+ lines.push(` · as skills baixadas em ${rel(vendor)}`);
213
+ if (creds.github)
214
+ lines.push(` · o token do GitHub de @${creds.github.login} (${rel(credentialsPath(env))})`);
215
+ lines.push(` · a configuração global (${rel(configDir(env))})`);
216
+ if (plan.modified.length) {
217
+ lines.push('', flags.force ? 'Arquivos do the-crew que você modificou (serão removidos por causa do --force):' : 'Ficam, porque você modificou (use --force para remover):');
218
+ for (const m of plan.modified)
219
+ lines.push(` · ${rel(m)}`);
220
+ }
221
+ lines.push('', `Nunca são tocados: os projetos${cfg ? ` em ${rel(cfg.projectsDir)}` : ''} e as skills que não são do the-crew.`);
222
+ log(lines.join('\n'));
223
+ if (flags.dryRun) {
224
+ log('\n(dry-run) Nada foi removido.');
225
+ return 0;
226
+ }
227
+ if (!flags.yes) {
228
+ if (!prompter.interactive) {
229
+ log('\nSem terminal interativo. Rode de novo com --yes para confirmar.');
230
+ return 1;
231
+ }
232
+ if (!(await prompter.confirm('Remover os itens acima?', false))) {
233
+ log('Nada foi removido.');
234
+ return 0;
235
+ }
236
+ }
237
+ let removeOffice = flags.removeOffice;
238
+ if (officeExists && !removeOffice && prompter.interactive && !flags.yes) {
239
+ const note = projects.length ? ` Ele registra ${projects.length} projeto(s); os projetos em si não são apagados.` : '';
240
+ removeOffice = await prompter.confirm(`Apagar também o escritório ${rel(officeDir)} (specs, contratos e projects.json)?${note}`, false);
241
+ }
242
+ let removeVault = flags.removeVault;
243
+ if (vaultExists && !removeVault && prompter.interactive && !flags.yes) {
244
+ removeVault = await prompter.confirm(`Apagar também a pasta do the-crew no vault (${vaultDir}), com as notas dos projetos?`, false);
245
+ }
246
+ const touched = new Set();
247
+ for (const f of [...plan.files, ...(flags.force ? plan.modified : [])]) {
248
+ rmSync(f, { force: true });
249
+ touched.add(dirname(f));
250
+ }
251
+ for (const l of plan.links)
252
+ removeLink(l);
253
+ for (const b of plan.blocks) {
254
+ const { text } = removeBlock(readFileSync(b, 'utf8'), 'html');
255
+ if (text.trim() === '')
256
+ rmSync(b, { force: true });
257
+ else
258
+ writeFileSync(b, text, 'utf8');
259
+ }
260
+ for (const j of plan.jsonKeys) {
261
+ const data = JSON.parse(readFileSync(j.path, 'utf8'));
262
+ for (const k of j.keys)
263
+ delete data.mcpServers[k];
264
+ if (Object.keys(data.mcpServers).length === 0 && Object.keys(data).length === 1)
265
+ rmSync(j.path, { force: true });
266
+ else
267
+ writeFileSync(j.path, JSON.stringify(data, null, 2) + '\n', 'utf8');
268
+ }
269
+ const roots = [join(home, '.claude', 'skills'), join(home, '.claude', 'agents'), join(home, '.agents', 'skills')];
270
+ for (const d of touched) {
271
+ const root = roots.find((r) => isInside(d, r));
272
+ if (root)
273
+ pruneEmpty(d, root);
274
+ }
275
+ if (removeOffice)
276
+ rmSync(officeDir, { recursive: true, force: true });
277
+ else
278
+ rmSync(vendor, { recursive: true, force: true });
279
+ if (removeVault && vaultDir)
280
+ rmSync(vaultDir, { recursive: true, force: true });
281
+ for (const p of [credentialsPath(env), globalConfigPath(env), installRecordPath(env)])
282
+ rmSync(p, { force: true });
283
+ try {
284
+ if (readdirSync(configDir(env)).length === 0)
285
+ rmdirSync(configDir(env));
286
+ }
287
+ catch {
288
+ /* já não existe */
289
+ }
290
+ const done = ['', '✓ the-crew desinstalado.'];
291
+ if (creds.github)
292
+ done.push(' O token foi apagado desta máquina. Para invalidá-lo de vez, revogue em https://github.com/settings/personal-access-tokens');
293
+ if (!removeOffice && officeExists)
294
+ done.push(` O escritório ficou em ${officeDir}.`);
295
+ if (!removeVault && vaultExists)
296
+ done.push(` As notas do vault ficaram em ${vaultDir}.`);
297
+ if (plan.plugins.length) {
298
+ done.push(' Plugins do Claude Code instalados pelo the-crew (mantidos, porque você pode usá-los fora do time). Para remover:');
299
+ for (const p of plan.plugins)
300
+ done.push(` claude plugin uninstall ${p}`);
301
+ }
302
+ if (projects.length)
303
+ done.push(' Os projetos mantêm o AGENTS.md, CLAUDE.md e .mcp.json deles; apague o bloco the-crew se quiser.');
304
+ if (plan.modified.length && !flags.force)
305
+ done.push(` ${plan.modified.length} arquivo(s) modificado(s) por você ficaram (listados acima).`);
306
+ log(done.join('\n'));
307
+ return 0;
308
+ }
@@ -2,16 +2,17 @@ import { existsSync } from 'node:fs';
2
2
  import { join, resolve } from 'node:path';
3
3
  import { formatReport } from '../../validate/report.js';
4
4
  import { loadTopology, validateTopology } from '../../validate/topology.js';
5
+ import { readGlobalConfig } from '../lib/credentials.js';
5
6
  import { packageRoot } from '../lib/paths.js';
6
- /** Procura a topologia no repo do the-crew (core/) ou num projeto instalado (.the-crew/). */
7
+ /** Procura a topologia no repo do the-crew (core/contracts) ou no escritório (contracts/). */
7
8
  export function findTopology(root) {
8
- return [join(root, 'core', 'contracts', 'topology.json'), join(root, '.the-crew', 'contracts', 'topology.json')].find((p) => existsSync(p));
9
+ return [join(root, 'core', 'contracts', 'topology.json'), join(root, 'contracts', 'topology.json')].find((p) => existsSync(p));
9
10
  }
10
- export function runValidate(dir, log) {
11
- const root = resolve(dir ?? packageRoot());
11
+ export function runValidate(dir, log, env = process.env) {
12
+ const root = resolve(dir ?? readGlobalConfig(env)?.officeDir ?? packageRoot());
12
13
  const file = findTopology(root);
13
14
  if (!file) {
14
- log(`Nenhuma topologia encontrada em ${root} (core/contracts ou .the-crew/contracts).`);
15
+ log(`Nenhuma topologia encontrada em ${root} (core/contracts ou contracts).`);
15
16
  return 2;
16
17
  }
17
18
  const result = validateTopology(loadTopology(file), root);
@@ -1,14 +1,27 @@
1
1
  #!/usr/bin/env node
2
2
  import { runExec } from './commands/exec.js';
3
- import { runInit } from './commands/init.js';
3
+ import { runInstall } from './commands/install.js';
4
4
  import { runLogin } from './commands/login.js';
5
+ import { runNewProject } from './commands/new-project.js';
6
+ import { runProjects } from './commands/projects.js';
7
+ import { runUninstall } from './commands/uninstall.js';
5
8
  import { runValidate } from './commands/validate.js';
6
9
  import { HELP, parseArgs } from './lib/args.js';
7
10
  import { packageVersion } from './lib/paths.js';
8
11
  import { createPrompter } from './lib/prompt.js';
9
12
  const log = (m) => console.log(m);
13
+ async function withPrompter(nonInteractive, fn) {
14
+ const p = createPrompter(nonInteractive);
15
+ try {
16
+ return await fn(p);
17
+ }
18
+ finally {
19
+ p.close();
20
+ }
21
+ }
10
22
  async function main() {
11
23
  const parsed = parseArgs(process.argv.slice(2));
24
+ const env = process.env;
12
25
  switch (parsed.command) {
13
26
  case 'help':
14
27
  log(HELP);
@@ -17,27 +30,19 @@ async function main() {
17
30
  log(packageVersion());
18
31
  return 0;
19
32
  case 'validate':
20
- return runValidate(parsed.positional[0], log);
33
+ return runValidate(parsed.positional[0], log, env);
34
+ case 'projects':
35
+ return runProjects(parsed.project.json, log, env);
21
36
  case 'exec':
22
- return runExec(parsed.rest, log);
23
- case 'login': {
24
- const p = createPrompter(false);
25
- try {
26
- return await runLogin(p, log, process.env);
27
- }
28
- finally {
29
- p.close();
30
- }
31
- }
32
- case 'init': {
33
- const p = createPrompter(parsed.init.yes);
34
- try {
35
- return await runInit(parsed.init, { prompter: p, log, env: process.env });
36
- }
37
- finally {
38
- p.close();
39
- }
40
- }
37
+ return runExec(parsed.rest, log, env);
38
+ case 'login':
39
+ return withPrompter(false, (p) => runLogin(p, log, env));
40
+ case 'new-project':
41
+ return withPrompter(Boolean(parsed.project.name), (p) => runNewProject(parsed.project, { prompter: p, log, env }));
42
+ case 'uninstall':
43
+ return withPrompter(parsed.uninstall.yes, (p) => runUninstall(parsed.uninstall, { prompter: p, log, env }));
44
+ case 'install':
45
+ return withPrompter(parsed.install.yes, (p) => runInstall(parsed.install, { prompter: p, log, env }));
41
46
  }
42
47
  }
43
48
  main().then((code) => {
@@ -1,4 +1,5 @@
1
- const IDES = ['claude-code', 'cursor', 'windsurf', 'other'];
1
+ const COMMANDS = ['install', 'uninstall', 'new-project', 'projects', 'validate', 'exec', 'login', 'help', 'version'];
2
+ const IDES = ['claude-code', 'codex', 'cursor', 'windsurf', 'other'];
2
3
  const MCPS = ['github', 'context7', 'playwright'];
3
4
  function list(value, allowed, flag) {
4
5
  if (value === '' || value === 'none')
@@ -13,12 +14,16 @@ export function parseArgs(argv) {
13
14
  const dd = argv.indexOf('--');
14
15
  const rest = dd === -1 ? [] : argv.slice(dd + 1);
15
16
  const args = dd === -1 ? argv : argv.slice(0, dd);
16
- const init = { yes: false, force: false, dryRun: false, github: true, gitInit: true };
17
+ const install = { yes: false, force: false, dryRun: false, github: true, gitInit: true, skills: true };
18
+ const project = { description: '', github: false, public: false, json: false, dryRun: false };
19
+ const uninstall = { removeOffice: false, removeVault: false, legacy: false };
17
20
  const positional = [];
18
21
  let command;
19
22
  for (let i = 0; i < args.length; i++) {
20
23
  const a = args[i];
21
- const [key, inline] = a.startsWith('--') && a.includes('=') ? [a.slice(0, a.indexOf('=')), a.slice(a.indexOf('=') + 1)] : [a, undefined];
24
+ const eq = a.startsWith('--') ? a.indexOf('=') : -1;
25
+ const key = eq === -1 ? a : a.slice(0, eq);
26
+ const inline = eq === -1 ? undefined : a.slice(eq + 1);
22
27
  const value = () => {
23
28
  if (inline !== undefined)
24
29
  return inline;
@@ -38,77 +43,130 @@ export function parseArgs(argv) {
38
43
  break;
39
44
  case '-y':
40
45
  case '--yes':
41
- init.yes = true;
46
+ install.yes = true;
42
47
  break;
43
48
  case '--force':
44
- init.force = true;
49
+ install.force = true;
45
50
  break;
46
51
  case '--dry-run':
47
- init.dryRun = true;
52
+ install.dryRun = true;
53
+ project.dryRun = true;
48
54
  break;
49
- case '--name':
50
- init.projectName = value();
55
+ case '--office':
56
+ install.office = value();
57
+ break;
58
+ case '--projects-dir':
59
+ install.projectsDir = value();
51
60
  break;
52
61
  case '--ide':
53
- init.ides = list(value(), IDES, '--ide');
62
+ install.ides = list(value(), IDES, '--ide');
54
63
  break;
55
64
  case '--mcp':
56
- init.mcp = list(value(), MCPS, '--mcp');
65
+ install.mcp = list(value(), MCPS, '--mcp');
57
66
  break;
58
67
  case '--vault':
59
- init.vault = value();
68
+ install.vault = value();
60
69
  break;
61
70
  case '--no-vault':
62
- init.vault = false;
71
+ install.vault = false;
63
72
  break;
64
73
  case '--no-github':
65
- init.github = false;
74
+ install.github = false;
66
75
  break;
67
- case '--ci':
68
- init.ci = true;
76
+ case '--no-git':
77
+ install.gitInit = false;
69
78
  break;
70
- case '--no-ci':
71
- init.ci = false;
79
+ case '--no-skills':
80
+ install.skills = false;
72
81
  break;
73
- case '--no-git':
74
- init.gitInit = false;
82
+ case '--remove-office':
83
+ uninstall.removeOffice = true;
84
+ break;
85
+ case '--legacy':
86
+ uninstall.legacy = true;
87
+ break;
88
+ case '--remove-vault':
89
+ uninstall.removeVault = true;
90
+ break;
91
+ case '--description':
92
+ project.description = value();
93
+ break;
94
+ case '--dir':
95
+ project.dir = value();
96
+ break;
97
+ case '--github':
98
+ project.github = true;
99
+ break;
100
+ case '--public':
101
+ project.public = true;
102
+ break;
103
+ case '--json':
104
+ project.json = true;
75
105
  break;
76
106
  case '--token':
77
107
  case '--github-token':
78
- throw new Error('Por segurança o token não é aceito como argumento (ficaria no histórico do shell). Cole quando o init pedir ou use a variável THE_CREW_GITHUB_TOKEN.');
108
+ throw new Error('Por segurança o token não é aceito como argumento (ficaria no histórico do shell). Cole quando pedido ou use a variável THE_CREW_GITHUB_TOKEN.');
79
109
  default:
80
110
  if (a.startsWith('-'))
81
111
  throw new Error(`Opção desconhecida: ${a}`);
82
- if (!command && ['init', 'validate', 'exec', 'login', 'help', 'version'].includes(a))
112
+ if (!command && COMMANDS.includes(a))
83
113
  command = a;
114
+ else if (!command && a === 'init')
115
+ command = 'install';
84
116
  else
85
117
  positional.push(a);
86
118
  }
87
119
  }
88
- command ??= 'init';
89
- if (command === 'init' && positional[0])
90
- init.dir = positional[0];
91
- return { command, positional, rest, init };
120
+ command ??= 'install';
121
+ if (command === 'new-project' && positional[0])
122
+ project.name = positional[0];
123
+ return {
124
+ command,
125
+ positional,
126
+ rest,
127
+ install,
128
+ project,
129
+ uninstall: { yes: install.yes, force: install.force, dryRun: install.dryRun, ...uninstall, paths: command === 'uninstall' ? positional : [] },
130
+ };
92
131
  }
93
- export const HELP = `the-crew: instala o escritório de 17 agentes de IA num repositório
132
+ export const HELP = `the-crew: um time de 17 agentes de IA que administra todos os seus projetos
94
133
 
95
134
  Uso:
96
- npx the-crew@latest [init] [pasta] [opções] Instala ou atualiza o time na pasta (padrão: atual)
97
- npx the-crew validate [pasta] Valida a simetria dos contratos dos agentes
98
- npx the-crew exec -- <comando> Roda um comando com o token do GitHub no ambiente
99
- npx the-crew login Salva ou troca o token do GitHub
135
+ npx the-crew@latest Instala (ou atualiza) o time nesta máquina, uma vez só
136
+ the-crew new-project "<nome>" [opções] Cria um projeto (normalmente chamado pelo /new-project)
137
+ the-crew projects [--json] Lista os projetos do time
138
+ the-crew validate [pasta] Valida a simetria dos contratos dos agentes
139
+ the-crew exec -- <comando> Roda um comando com o token do GitHub no ambiente
140
+ the-crew login Salva ou troca o token do GitHub
141
+ the-crew uninstall [opções] Remove o time desta máquina (pede confirmação)
142
+
143
+ Instalação:
144
+ -y, --yes sem perguntas; usa os padrões e nunca sobrescreve arquivos
145
+ --force sobrescreve arquivos existentes sem perguntar
146
+ --dry-run mostra o que seria feito, sem gravar
147
+ --office <pasta> escritório do time (padrão: ~/the-crew)
148
+ --projects-dir <p> onde os projetos novos são criados (padrão: ~/projetos)
149
+ --ide <lista> claude-code,codex,cursor,windsurf,other
150
+ --mcp <lista> github,context7,playwright (ou none)
151
+ --vault <pasta> vault do Obsidian | --no-vault
152
+ --no-github não configura o token
153
+ --no-git não roda git init
154
+ --no-skills não baixa as skills de terceiros
155
+
156
+ new-project:
157
+ --description "<texto>" problema e público (vai para o PROJECT.md)
158
+ --github [--public] cria o repositório no GitHub (privado por padrão)
159
+ --dir <pasta> pasta do projeto (padrão: <projetos>/<slug>)
160
+ --json saída em JSON
100
161
 
101
- Opções do init:
102
- -y, --yes Sem perguntas: usa os padrões e nunca sobrescreve arquivos existentes
103
- --force Sobrescreve arquivos existentes sem perguntar
104
- --dry-run Mostra o que seria feito, sem gravar nada
105
- --name <nome> Nome do projeto
106
- --ide <lista> claude-code,cursor,windsurf,other
107
- --mcp <lista> github,context7,playwright (ou none)
108
- --vault <pasta> Caminho do vault do Obsidian | --no-vault
109
- --no-github Não configura o token do GitHub
110
- --ci / --no-ci Workflow que valida os contratos no GitHub Actions
111
- --no-git Não roda git init
162
+ uninstall:
163
+ --dry-run mostra o que seria removido
164
+ --yes confirma sem perguntar (mantém escritório e vault)
165
+ --remove-office apaga também o escritório (~/the-crew)
166
+ --remove-vault apaga também a pasta the-crew do vault
167
+ --force remove também arquivos do the-crew que você modificou
168
+ --legacy [pastas] limpa instalações da 0.1.0 (por projeto) nas pastas dadas,
169
+ ou procura na pasta atual e na home
112
170
 
113
171
  Token do GitHub: nunca por argumento. Cole quando pedido ou use THE_CREW_GITHUB_TOKEN.
114
172
  `;