jarvis-ai-framework 8.7.0 → 9.0.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.
- package/AGENTS.md +33 -36
- package/README.md +22 -10
- package/agents/AGENTS.md +8 -14
- package/agents/README.md +17 -25
- package/agents/engineering/eng.agent.md +10 -12
- package/agents/engineering/eng.bug-hunter.md +7 -10
- package/agents/engineering/eng.dev-code-reviewer.md +1 -1
- package/agents/engineering/eng.frontend.agent.md +3 -2
- package/agents/engineering/eng.rpa.agent.md +8 -6
- package/agents/engineering/qa/eng.qa.test-planner.md +12 -4
- package/agents/engineering/qa/eng.qa.testing-engineer.md +10 -97
- package/agents/product/prod.discovery-interviewer.md +1 -1
- package/bin/README.md +10 -10
- package/bin/commands/init.js +188 -51
- package/bin/commands/rules.js +11 -24
- package/bin/commands/tokens.js +20 -42
- package/bin/commands/untrack.js +73 -0
- package/bin/commands/whoami.js +2 -18
- package/bin/lib/auth/session.js +1 -27
- package/bin/lib/cli/program.js +12 -9
- package/bin/lib/config/constants.js +97 -24
- package/bin/lib/config/ide-config.js +0 -8
- package/bin/lib/core/env-paths.js +2 -2
- package/bin/lib/core/env-upgrade.js +61 -9
- package/bin/lib/core/git-exclude.js +267 -0
- package/bin/lib/core/profile-filter.js +31 -94
- package/bin/lib/core/repos-map.js +106 -0
- package/bin/lib/core/sync-engine.js +42 -44
- package/bin/lib/core/token-report.js +11 -13
- package/bin/lib/core/workspace-mode.js +1 -1
- package/bin/lib/docs/validate-frontmatter.js +0 -42
- package/bin/lib/utils/git-parser.js +0 -5
- package/bin/lib/utils/paths.js +0 -16
- package/package.json +2 -3
- package/rules/artifact-style-rules.md +2 -4
- package/rules/company-overlay-rules.md +0 -2
- package/rules/engineering/eng-rules.md +3 -29
- package/rules/engineering/eng-security-rules.md +0 -15
- package/rules/engineering/eng.integrations-rules.md +3 -12
- package/rules/engineering/eng.skills-rules.md +0 -2
- package/rules/engineering/eng.specializations-rules.md +0 -2
- package/rules/product/prod-rules.md +1 -2
- package/rules/rtk-rules.md +0 -2
- package/rules-on-demand/doc-links-rules.md +5 -7
- package/rules-on-demand/engineering/eng.bump-rules.md +0 -2
- package/rules-on-demand/engineering/eng.gate0-rules.md +0 -2
- package/rules-on-demand/engineering/eng.plan-rules.md +0 -2
- package/rules-on-demand/engineering/eng.pr-rules.md +1 -3
- package/rules-on-demand/engineering/eng.pre-pr-rules.md +2 -4
- package/rules-on-demand/engineering/eng.rpa-rules.md +0 -2
- package/rules-on-demand/engineering/eng.security-rules.md +0 -2
- package/rules-on-demand/engineering/eng.start-rules.md +0 -2
- package/rules-on-demand/engineering/eng.tech-spec-rules.md +5 -6
- package/rules-on-demand/engineering/eng.transitions-rules.md +3 -5
- package/rules-on-demand/engineering/eng.work-rules.md +0 -2
- package/{rules → rules-on-demand}/engineering/frontend/eng.frontend-rules.md +1 -3
- package/rules-on-demand/product/prod.guided-rules.md +2 -4
- package/rules-on-demand/product/prod.spec-common-rules.md +2 -4
- package/{rules → rules-on-demand}/product/prod.spec-rules.md +2 -4
- package/rules-on-demand/warm-up-consume-rules.md +0 -2
- package/skills/AGENTS.md +7 -23
- package/skills/eng-frontend/SKILL.md +2 -0
- package/skills/{eng-backend-arch-c4 → eng-global-arch-c4}/SKILL.md +19 -27
- package/skills/{eng-backend-arch-c4 → eng-global-arch-c4}/references/1-nivel-context.md +1 -1
- package/skills/{eng-backend-arch-c4 → eng-global-arch-c4}/references/2-nivel-container.md +1 -1
- package/skills/{eng-backend-arch-c4 → eng-global-arch-c4}/references/3-nivel-component.md +1 -1
- package/skills/{eng-backend-arch-c4 → eng-global-arch-c4}/references/4-nivel-code.md +1 -1
- package/skills/{eng-backend-arch-c4 → eng-global-arch-c4}/references/5-atualizacao-e-adrs.md +1 -1
- package/skills/eng-global-docs-write/SKILL.md +5 -3
- package/skills/eng-global-tech-spec/SKILL.md +1 -1
- package/skills/eng-global-tech-spec/references/delivery-spec.md +22 -9
- package/skills/eng-global-tech-spec/references/reference-spec.md +1 -1
- package/skills/jarvis-context-detect/SKILL.md +19 -16
- package/skills/jarvis-context-detect/assets/context-profile-template.md +2 -2
- package/skills/jarvis-context-detect/references/cdd-aplicado-a-prompts.md +9 -10
- package/skills/jarvis-create-specialization/assets/skill-especializacao-template.md +0 -1
- package/skills/jarvis-docs-index/SKILL.md +1 -1
- package/skills/jarvis-evolution-architect/references/visao-geral.md +1 -1
- package/skills/jarvis-init/SKILL.md +121 -140
- package/skills/jarvis-init/assets/exemplo-execucao.md +8 -8
- package/skills/jarvis-init/assets/mapa-de-tecnologias.md +27 -0
- package/skills/jarvis-init/assets/onboarding-checklist.md +0 -1
- package/skills/jarvis-init/assets/passo-adicionar-stacks.md +9 -3
- package/skills/jarvis-init/assets/repos.md +48 -0
- package/skills/jarvis-init/assets/rules-sync-manual.md +11 -68
- package/skills/jarvis-init/assets/upgrade.md +18 -9
- package/skills/jarvis-init/assets/validacoes.md +3 -22
- package/taxonomy.md +6 -156
- package/templates/AGENTS.md +16 -16
- package/templates/ENV-template.md +18 -35
- package/templates/cdd-mind-map-template.md +2 -2
- package/templates/engineering/AGENTS-template.md +10 -2
- package/templates/engineering/RFC-template.md +17 -4
- package/templates/engineering/advisor-template.md +2 -1
- package/templates/engineering/architecture-template.md +18 -10
- package/templates/engineering/light-arch-template.md +9 -9
- package/templates/engineering/plan-template.md +5 -1
- package/templates/engineering/qa/qa.test-strategy-template.md +3 -1
- package/templates/engineering/tech-spec-delivery-template.md +88 -4
- package/templates/engineering/tech-spec-template.md +29 -2
- package/workflows/AGENTS.md +11 -17
- package/workflows/README.md +10 -23
- package/workflows/engineering/eng.build-tech-spec.md +0 -25
- package/workflows/engineering/eng.create-ard.md +74 -9
- package/workflows/engineering/eng.debug.md +8 -8
- package/workflows/engineering/eng.light-arch.md +3 -4
- package/workflows/engineering/eng.plan.md +11 -7
- package/workflows/engineering/eng.pr.md +2 -1
- package/workflows/engineering/eng.pre-pr.md +5 -2
- package/workflows/engineering/eng.rpa.robot.md +1 -1
- package/workflows/engineering/eng.start.md +2 -2
- package/workflows/engineering/eng.work.md +0 -2
- package/workflows/engineering/frontend/eng.frontend-component.md +1 -1
- package/workflows/engineering/frontend/eng.frontend-perf-audit.md +1 -1
- package/workflows/engineering/frontend/eng.frontend-review.md +2 -2
- package/workflows/product/prod.spec.ard.md +7 -5
- package/workflows/product/prod.spec.breakdown.md +3 -3
- package/workflows/product/prod.spec.clarify.md +2 -0
- package/workflows/product/prod.spec.discovery.md +1 -1
- package/workflows/product/prod.spec.epic.md +2 -2
- package/workflows/product/prod.spec.frd.md +2 -2
- package/workflows/product/prod.spec.issue.md +2 -2
- package/workflows/product/prod.spec.prd.md +2 -2
- package/workflows/taxonomy.md +10 -17
- package/workflows/warm-up.md +6 -8
- package/agents/engineering/data/eng.data-engineer.agent.md +0 -250
- package/agents/engineering/qa/eng.qa.quality-champion-task-agent.md +0 -89
- package/agents/engineering/qa/eng.qa.quality-strategist.md +0 -116
- package/members.md +0 -25
- package/rules/engineering/qa/eng.qa.cypress-standards-rules.md +0 -5
- package/rules-on-demand/engineering/eng.breakdown-subtasks-rules.md +0 -556
- package/rules-on-demand/engineering/qa/eng.qa.cypress-standards-rules.md +0 -259
- package/skills/SKILLS-ROADMAP.md +0 -232
- package/skills/eng-qa-planner/assets/test-coverage-template.md +0 -92
- package/skills/eng-qa-planner/assets/test-patterns.md +0 -178
- package/skills/product-roadmap-report/README.md +0 -303
- package/skills/product-roadmap-report/SKILL.md +0 -208
- package/skills/product-roadmap-report/commands/status.compiled.single.team.md +0 -23
- package/skills/product-roadmap-report/commands/status.list.projects.md +0 -17
- package/skills/product-roadmap-report/commands/status.memory.md +0 -192
- package/skills/product-roadmap-report/commands/status.roadmap.preview.md +0 -94
- package/skills/product-roadmap-report/references/detailed-guide.md +0 -236
- package/skills/product-roadmap-report/rules/status-report-rules.md +0 -44
- package/skills/product-roadmap-report/templates/template-multiple-teams-compiled-status.md +0 -53
- package/skills/product-roadmap-report/templates/template-projects-list.md +0 -23
- package/skills/product-roadmap-report/templates/template-single-team-compiled-status.md +0 -60
- package/skills/product-roadmap-report/templates/template-single-team-status.md +0 -49
- package/skills/product-specs/SKILL.md +0 -52
- package/skills/product-specs-update/SKILL.md +0 -295
- package/templates/engineering/breakdown-subtasks-template.md +0 -211
- package/templates/engineering/data-contract-template.md +0 -135
- package/templates/engineering/data-pipeline-template.md +0 -163
- package/templates/engineering/qa/qa.release-signoff-template.md +0 -54
- package/templates/engineering/qa/qa.sprint-plan-template.md +0 -49
- package/templates/engineering/work-progress-template.md +0 -155
- package/workflows/engineering/data/data.contract.md +0 -210
- package/workflows/engineering/data/data.new-pipeline.md +0 -241
- package/workflows/engineering/eng.breakdown-subtasks.md +0 -201
- package/workflows/engineering/eng.create-ard-from-code.md +0 -240
- package/workflows/engineering/eng.docs.md +0 -48
- package/workflows/engineering/eng.review.md +0 -185
- package/workflows/engineering/qa/eng.qa-refinement-entry.md +0 -88
- package/workflows/engineering/qa/eng.qa-release-signoff.md +0 -108
- package/workflows/engineering/qa/eng.qa-sprint-planning.md +0 -102
- package/workflows/product/prod.roadmap.preview.md +0 -115
- /package/skills/{eng-backend-arch-c4 → eng-global-arch-c4}/assets/example-code.md +0 -0
- /package/skills/{eng-backend-arch-c4 → eng-global-arch-c4}/assets/example-component.md +0 -0
- /package/skills/{eng-backend-arch-c4 → eng-global-arch-c4}/assets/example-container.md +0 -0
- /package/skills/{eng-backend-arch-c4 → eng-global-arch-c4}/assets/example-context.md +0 -0
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
// Arquivos gerados pelo Jarvis que ficam fora do git no modo projeto (#227).
|
|
2
|
+
//
|
|
3
|
+
// No modo projeto a raiz do workspace é o repositório do time. O `.gitignore` é versionado, então
|
|
4
|
+
// escrever nele é alterar o repositório; o `.git/info/exclude` é local e não aparece no PR. Por isso:
|
|
5
|
+
// - `AGENTS.md`, `CLAUDE.md` e `CDD-MIND-MAP.md` vão para o exclude;
|
|
6
|
+
// - `.jarvis/`, `docs/jarvis/` e a pasta da IDE continuam no `.gitignore` (decisão Q1/Q3 da #227);
|
|
7
|
+
// - `AGENTS.md`/`CLAUDE.md` já commitados só saem do índice (`git rm --cached`) com a confirmação da
|
|
8
|
+
// pessoa, dada no Upgrade pelo skill (`jarvis untrack`). Nada aqui faz commit ou push.
|
|
9
|
+
// Falha do git ou da gravação nunca é silenciosa: vira `error`/`errors` no resultado, para o init avisar.
|
|
10
|
+
import { execFileSync } from "node:child_process";
|
|
11
|
+
import { appendFileSync, existsSync, mkdirSync, readFileSync } from "node:fs";
|
|
12
|
+
import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
13
|
+
import { getIDEFolder } from "../config/ide-config.js";
|
|
14
|
+
import { ensureGitignore } from "./docs-migrate.js";
|
|
15
|
+
import { rootIsRepo } from "./workspace-mode.js";
|
|
16
|
+
|
|
17
|
+
/** Entradas que o init mantém no `.git/info/exclude` (modo projeto). */
|
|
18
|
+
export const LOCAL_EXCLUDE_ENTRIES = Object.freeze(["AGENTS.md", "CLAUDE.md", "CDD-MIND-MAP.md"]);
|
|
19
|
+
|
|
20
|
+
/** Só estes dois podem sair do índice pelo `jarvis untrack`. */
|
|
21
|
+
export const UNTRACKABLE_FILES = Object.freeze(["AGENTS.md", "CLAUDE.md"]);
|
|
22
|
+
|
|
23
|
+
/** Variáveis que desviam o git para outro repositório (hooks, scripts): nunca herdadas do ambiente. */
|
|
24
|
+
const GIT_REDIRECT_VARS = Object.freeze(["GIT_DIR", "GIT_WORK_TREE", "GIT_INDEX_FILE"]);
|
|
25
|
+
|
|
26
|
+
function gitEnv() {
|
|
27
|
+
const env = { ...process.env };
|
|
28
|
+
for (const name of GIT_REDIRECT_VARS) delete env[name];
|
|
29
|
+
return env;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Roda o git em `dir` sem shell, com o ambiente isolado e o stderr capturado; devolve a saída ou lança. */
|
|
33
|
+
function git(dir, args) {
|
|
34
|
+
return execFileSync("git", args, {
|
|
35
|
+
cwd: dir,
|
|
36
|
+
encoding: "utf-8",
|
|
37
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
38
|
+
env: gitEnv(),
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Primeira linha útil do stderr do git (senão, a da mensagem do erro). Nunca inclui a saída normal. */
|
|
43
|
+
function gitError(error) {
|
|
44
|
+
const fromStderr = String(error?.stderr ?? "")
|
|
45
|
+
.split(/\r?\n/)
|
|
46
|
+
.map((line) => line.trim())
|
|
47
|
+
.find(Boolean);
|
|
48
|
+
return fromStderr || String(error?.message ?? error).split("\n")[0];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Caminho do exclude e, se o git falhar, o motivo. */
|
|
52
|
+
function resolveExclude(dir) {
|
|
53
|
+
try {
|
|
54
|
+
const out = git(dir, ["rev-parse", "--git-path", "info/exclude"]).trim();
|
|
55
|
+
if (!out) return { path: null, error: "o git não devolveu o caminho do exclude" };
|
|
56
|
+
return { path: isAbsolute(out) ? out : resolve(dir, out), error: null };
|
|
57
|
+
} catch (error) {
|
|
58
|
+
return { path: null, error: gitError(error) };
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Caminho do `info/exclude` que o git usa para `dir`. Vem de `git rev-parse --git-path`, então vale
|
|
64
|
+
* também com `.git` em arquivo (worktree, submódulo).
|
|
65
|
+
* @param {string} dir
|
|
66
|
+
* @returns {string | null} `null` se o git falhar (sem git, sem repositório)
|
|
67
|
+
*/
|
|
68
|
+
export function gitExcludePath(dir) {
|
|
69
|
+
return resolveExclude(dir).path;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Garante `lines` no `.git/info/exclude` de `dir`, sem duplicar (reconhece a linha com e sem `/`
|
|
74
|
+
* inicial; espaço no início é outro padrão para o git), cria a pasta `info/` se faltar e mantém a
|
|
75
|
+
* quebra de linha do arquivo. Só age numa raiz versionada (com `.git`): no modo workspace não cria nem
|
|
76
|
+
* altera nada. Falha do git ou da gravação não lança: vem em `error` (e `gitUnavailable` quando foi o git que
|
|
77
|
+
* não respondeu, diferente de uma falha ao gravar o arquivo).
|
|
78
|
+
* @param {string} dir
|
|
79
|
+
* @param {readonly string[]} lines
|
|
80
|
+
* @returns {{ path: string | null, added: string[], existing: string[], error: string | null, gitUnavailable: boolean }}
|
|
81
|
+
*/
|
|
82
|
+
export function ensureLocalExclude(dir, lines) {
|
|
83
|
+
const result = { path: null, added: [], existing: [], error: null, gitUnavailable: false };
|
|
84
|
+
if (!rootIsRepo(dir)) return result;
|
|
85
|
+
const resolved = resolveExclude(dir);
|
|
86
|
+
if (!resolved.path) {
|
|
87
|
+
result.error = `o git não respondeu (${resolved.error})`;
|
|
88
|
+
result.gitUnavailable = true;
|
|
89
|
+
return result;
|
|
90
|
+
}
|
|
91
|
+
const path = resolved.path;
|
|
92
|
+
result.path = path;
|
|
93
|
+
|
|
94
|
+
try {
|
|
95
|
+
const text = existsSync(path) ? readFileSync(path, "utf-8") : "";
|
|
96
|
+
const present = new Set(text.split(/\r?\n/).map((l) => l.trimEnd()));
|
|
97
|
+
const missing = [];
|
|
98
|
+
for (const line of lines) {
|
|
99
|
+
const bare = line.replace(/^\//, "");
|
|
100
|
+
if (present.has(bare) || present.has(`/${bare}`)) result.existing.push(line);
|
|
101
|
+
else missing.push(line);
|
|
102
|
+
}
|
|
103
|
+
if (missing.length === 0) return result;
|
|
104
|
+
|
|
105
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
106
|
+
const eol = text.includes("\r\n") ? "\r\n" : "\n";
|
|
107
|
+
const prefix = text && !text.endsWith("\n") ? eol : "";
|
|
108
|
+
appendFileSync(path, `${prefix}${missing.join(eol)}${eol}`);
|
|
109
|
+
result.added = missing;
|
|
110
|
+
} catch (error) {
|
|
111
|
+
result.existing = [];
|
|
112
|
+
result.error = `não foi possível gravar ${path}: ${error.code || String(error.message).split("\n")[0]}`;
|
|
113
|
+
}
|
|
114
|
+
return result;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Quais de `names` estão rastreados (`git ls-files`) em `dir`. Raiz sem `.git` ou erro do git: nenhum.
|
|
119
|
+
* @param {string} dir
|
|
120
|
+
* @param {readonly string[]} [names]
|
|
121
|
+
* @returns {string[]}
|
|
122
|
+
*/
|
|
123
|
+
export function trackedFiles(dir, names = UNTRACKABLE_FILES) {
|
|
124
|
+
if (!rootIsRepo(dir)) return [];
|
|
125
|
+
return names.filter((name) => {
|
|
126
|
+
try {
|
|
127
|
+
return git(dir, ["ls-files", "--", name]).trim() !== "";
|
|
128
|
+
} catch {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Tira `name` do índice (`git rm --cached`, o arquivo local fica) e o põe no exclude. Nunca faz commit
|
|
136
|
+
* nem push: a remoção fica staged para a pessoa revisar. Recusa nome fora de `UNTRACKABLE_FILES`, raiz
|
|
137
|
+
* sem `.git` e arquivo que não está rastreado. Se o git recusar, o `reason` traz o motivo dele.
|
|
138
|
+
* @param {string} dir
|
|
139
|
+
* @param {string} name
|
|
140
|
+
* @returns {{ ok: true, excludeAdded: string[], excludeError: string | null } | { ok: false, reason: string }}
|
|
141
|
+
*/
|
|
142
|
+
export function untrackFromIndex(dir, name) {
|
|
143
|
+
if (!UNTRACKABLE_FILES.includes(name)) {
|
|
144
|
+
return { ok: false, reason: `${name} não pode sair do git por este comando (só ${UNTRACKABLE_FILES.join(" e ")})` };
|
|
145
|
+
}
|
|
146
|
+
if (!rootIsRepo(dir)) {
|
|
147
|
+
return { ok: false, reason: "a raiz não é um repositório (modo workspace): não há índice para alterar" };
|
|
148
|
+
}
|
|
149
|
+
let listed;
|
|
150
|
+
try {
|
|
151
|
+
listed = git(dir, ["ls-files", "--", name]).trim();
|
|
152
|
+
} catch (error) {
|
|
153
|
+
return { ok: false, reason: `git não respondeu (${gitError(error)})` };
|
|
154
|
+
}
|
|
155
|
+
if (listed === "") {
|
|
156
|
+
return { ok: false, reason: `${name} não está versionado` };
|
|
157
|
+
}
|
|
158
|
+
try {
|
|
159
|
+
git(dir, ["rm", "--cached", "--quiet", "--", name]);
|
|
160
|
+
} catch (error) {
|
|
161
|
+
return { ok: false, reason: `git rm --cached falhou: ${gitError(error)}` };
|
|
162
|
+
}
|
|
163
|
+
const exclude = ensureLocalExclude(dir, [name]);
|
|
164
|
+
return { ok: true, excludeAdded: exclude.added, excludeError: exclude.error };
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** Entrada do `.gitignore` para a pasta da IDE (ex.: `.claude/`, `.windsurf/`). */
|
|
168
|
+
export function ideFolderEntry(ide) {
|
|
169
|
+
return `.${getIDEFolder(ide)}/`;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** Há arquivo rastreado sob `pathspec`? Raiz sem `.git` ou erro do git: não. */
|
|
173
|
+
function hasTrackedUnder(dir, pathspec) {
|
|
174
|
+
if (!rootIsRepo(dir)) return false;
|
|
175
|
+
try {
|
|
176
|
+
return git(dir, ["ls-files", "--", pathspec]).trim() !== "";
|
|
177
|
+
} catch {
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** A pasta da IDE já está rastreada? Ignorar não a tira do git; só avisamos. */
|
|
183
|
+
export function isIdeFolderTracked(dir, ide) {
|
|
184
|
+
return hasTrackedUnder(dir, `.${getIDEFolder(ide)}`);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/** Grava `line` no `.gitignore` e diz se o arquivo mudou. Lança se o arquivo não puder ser lido/gravado. */
|
|
188
|
+
function addGitignoreLine(dir, line) {
|
|
189
|
+
const path = join(dir, ".gitignore");
|
|
190
|
+
const before = existsSync(path) ? readFileSync(path, "utf-8") : null;
|
|
191
|
+
ensureGitignore(dir, line);
|
|
192
|
+
const after = existsSync(path) ? readFileSync(path, "utf-8") : null;
|
|
193
|
+
return before !== after;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Tudo o que o modo projeto precisa no git (instalação e Upgrade usam a mesma função): as entradas
|
|
198
|
+
* locais no exclude (menos as já rastreadas: `AGENTS.md`/`CLAUDE.md` são decisão do Upgrade e o mapa só
|
|
199
|
+
* recebe aviso), a pasta da IDE e as `gitignoreLines` no `.gitignore`. Raiz sem `.git` (modo workspace):
|
|
200
|
+
* não altera nada. Nunca lança por falha do git ou de gravação: git que não responde vira `warnings` (ambiente;
|
|
201
|
+
* o init segue com saída 0) e falha ao gravar vira `errors` (setup incompleto; saída 1).
|
|
202
|
+
* @param {{ dir: string, ide: string, gitignoreLines?: readonly string[] }} input
|
|
203
|
+
* @returns {{
|
|
204
|
+
* isRepo: boolean,
|
|
205
|
+
* exclude: { path: string | null, added: string[], existing: string[], error: string | null, gitUnavailable: boolean },
|
|
206
|
+
* tracked: string[],
|
|
207
|
+
* trackedMap: boolean,
|
|
208
|
+
* ideEntry: string,
|
|
209
|
+
* ignoreAdded: string[],
|
|
210
|
+
* ideIgnoreAdded: boolean,
|
|
211
|
+
* ideFolderTracked: boolean,
|
|
212
|
+
* ignoredButTracked: string[],
|
|
213
|
+
* warnings: string[],
|
|
214
|
+
* errors: string[],
|
|
215
|
+
* }}
|
|
216
|
+
*/
|
|
217
|
+
export function applyProjectGitSetup({ dir, ide, gitignoreLines = [] }) {
|
|
218
|
+
const ideEntry = ideFolderEntry(ide);
|
|
219
|
+
const base = {
|
|
220
|
+
isRepo: false,
|
|
221
|
+
exclude: { path: null, added: [], existing: [], error: null, gitUnavailable: false },
|
|
222
|
+
tracked: [],
|
|
223
|
+
trackedMap: false,
|
|
224
|
+
ideEntry,
|
|
225
|
+
ignoreAdded: [],
|
|
226
|
+
ideIgnoreAdded: false,
|
|
227
|
+
ideFolderTracked: false,
|
|
228
|
+
ignoredButTracked: [],
|
|
229
|
+
warnings: [],
|
|
230
|
+
errors: [],
|
|
231
|
+
};
|
|
232
|
+
if (!rootIsRepo(dir)) return base;
|
|
233
|
+
|
|
234
|
+
const trackedLocal = trackedFiles(dir, LOCAL_EXCLUDE_ENTRIES);
|
|
235
|
+
const exclude = ensureLocalExclude(
|
|
236
|
+
dir,
|
|
237
|
+
LOCAL_EXCLUDE_ENTRIES.filter((entry) => !trackedLocal.includes(entry))
|
|
238
|
+
);
|
|
239
|
+
const warnings = exclude.gitUnavailable ? [exclude.error] : [];
|
|
240
|
+
const errors = exclude.error && !exclude.gitUnavailable ? [exclude.error] : [];
|
|
241
|
+
|
|
242
|
+
const ignoreAdded = [];
|
|
243
|
+
for (const line of [ideEntry, ...gitignoreLines]) {
|
|
244
|
+
try {
|
|
245
|
+
if (addGitignoreLine(dir, line)) ignoreAdded.push(line);
|
|
246
|
+
} catch (error) {
|
|
247
|
+
errors.push(
|
|
248
|
+
`não foi possível gravar ${join(dir, ".gitignore")}: ${error.code || String(error.message).split("\n")[0]}`
|
|
249
|
+
);
|
|
250
|
+
break;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
return {
|
|
255
|
+
...base,
|
|
256
|
+
isRepo: true,
|
|
257
|
+
exclude,
|
|
258
|
+
tracked: trackedLocal.filter((name) => UNTRACKABLE_FILES.includes(name)),
|
|
259
|
+
trackedMap: trackedLocal.includes("CDD-MIND-MAP.md"),
|
|
260
|
+
ignoreAdded,
|
|
261
|
+
ideIgnoreAdded: ignoreAdded.includes(ideEntry),
|
|
262
|
+
ideFolderTracked: isIdeFolderTracked(dir, ide),
|
|
263
|
+
ignoredButTracked: gitignoreLines.filter((line) => hasTrackedUnder(dir, line)),
|
|
264
|
+
warnings,
|
|
265
|
+
errors,
|
|
266
|
+
};
|
|
267
|
+
}
|
|
@@ -1,95 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview
|
|
2
|
+
* @fileoverview Quais rules entram na IDE.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* - ARTIFACT_STYLE (5º campo, opcional): ausente no bloco = `all`; perfil sem valor =
|
|
12
|
-
* `ai-generated`. Sem coringa: FULLCYCLE e GENERALIST não o satisfazem (é escolha da pessoa).
|
|
13
|
-
* - `all` casa qualquer valor; listas são separadas por vírgula.
|
|
14
|
-
* - FULLCYCLE (HUB) satisfaz qualquer HUB.
|
|
15
|
-
* - GENERALIST (POSITION) satisfaz qualquer POSITION e qualquer AREA.
|
|
16
|
-
* - Arquivo sem bloco "Applies to" é universal.
|
|
17
|
-
* - `rtk-rules.md` só entra com RTK habilitado (opt-in).
|
|
4
|
+
* Toda rule de `rules/` (e de `rules-on-demand/`) entra, menos duas, decididas pelo nome do
|
|
5
|
+
* arquivo: `artifact-style-rules.md` só com `ARTIFACT_STYLE=human-generated` e `rtk-rules.md` só
|
|
6
|
+
* com o RTK ligado (#263). Usado por `jarvis tokens` e `jarvis rules sync` (Passo 8 do
|
|
7
|
+
* `/jarvis-init`). O fallback em prosa, para quando o CLI não está disponível, é
|
|
8
|
+
* `skills/jarvis-init/assets/rules-sync-manual.md`: ao mudar a lógica aqui, mude lá também. A
|
|
9
|
+
* documentação de autoria (hierarquia, convenções, estrutura de regra) vive em
|
|
10
|
+
* `docs/estrutura/rules.md`.
|
|
18
11
|
* @module core/profile-filter
|
|
19
12
|
*/
|
|
20
13
|
|
|
21
14
|
import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
|
|
22
|
-
import { join, relative, sep } from "node:path";
|
|
23
|
-
|
|
24
|
-
// SQUAD para no próximo `|`: o 5º campo (ARTIFACT_STYLE) é opcional.
|
|
25
|
-
const APPLIES_TO_RE =
|
|
26
|
-
/> \*\*Applies to:\*\* HUB: ([^|]+)\| POSITION: ([^|]+)\| AREA: ([^|]+)\| SQUAD: ([^|\n]+)(?:\| ARTIFACT_STYLE: ([^|\n]+))?/;
|
|
15
|
+
import { basename, join, relative, sep } from "node:path";
|
|
27
16
|
|
|
28
17
|
const DEFAULT_ARTIFACT_STYLE = "ai-generated";
|
|
29
18
|
|
|
30
|
-
/**
|
|
31
|
-
* @typedef {Object} AppliesTo
|
|
32
|
-
* @property {string} HUB
|
|
33
|
-
* @property {string} POSITION
|
|
34
|
-
* @property {string} AREA
|
|
35
|
-
* @property {string} SQUAD
|
|
36
|
-
* @property {string} ARTIFACT_STYLE - `all` quando o bloco não traz o campo
|
|
37
|
-
*/
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* @typedef {Object} Profile
|
|
41
|
-
* @property {string} HUB
|
|
42
|
-
* @property {string} POSITION
|
|
43
|
-
* @property {string} AREA
|
|
44
|
-
* @property {string} SQUAD
|
|
45
|
-
* @property {string} [ARTIFACT_STYLE] - vazio = `ai-generated`
|
|
46
|
-
*/
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Lê o primeiro bloco "Applies to" do conteúdo.
|
|
50
|
-
* @param {string} content
|
|
51
|
-
* @returns {AppliesTo | null} `null` quando não há bloco (arquivo universal)
|
|
52
|
-
*/
|
|
53
|
-
export function parseAppliesTo(content) {
|
|
54
|
-
const match = content.match(APPLIES_TO_RE);
|
|
55
|
-
if (!match) return null;
|
|
56
|
-
return {
|
|
57
|
-
HUB: match[1].trim(),
|
|
58
|
-
POSITION: match[2].trim(),
|
|
59
|
-
AREA: match[3].trim(),
|
|
60
|
-
SQUAD: match[4].trim(),
|
|
61
|
-
ARTIFACT_STYLE: (match[5] || "all").trim(),
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function axisMatches(list, value) {
|
|
66
|
-
if (list.toLowerCase() === "all") return true;
|
|
67
|
-
return list
|
|
68
|
-
.split(",")
|
|
69
|
-
.map((s) => s.trim())
|
|
70
|
-
.includes(value);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Decide se um bloco "Applies to" casa com o perfil.
|
|
75
|
-
* @param {AppliesTo | null} appliesTo
|
|
76
|
-
* @param {Profile} profile
|
|
77
|
-
* @returns {boolean}
|
|
78
|
-
*/
|
|
79
|
-
export function matchesProfile(appliesTo, profile) {
|
|
80
|
-
if (!appliesTo) return true;
|
|
81
|
-
const hub = profile.HUB === "FULLCYCLE" || axisMatches(appliesTo.HUB, profile.HUB);
|
|
82
|
-
const generalist = profile.POSITION === "GENERALIST";
|
|
83
|
-
const position = generalist || axisMatches(appliesTo.POSITION, profile.POSITION);
|
|
84
|
-
const area = generalist || axisMatches(appliesTo.AREA, profile.AREA);
|
|
85
|
-
const squad = axisMatches(appliesTo.SQUAD, profile.SQUAD);
|
|
86
|
-
const style = axisMatches(
|
|
87
|
-
appliesTo.ARTIFACT_STYLE || "all",
|
|
88
|
-
profile.ARTIFACT_STYLE || DEFAULT_ARTIFACT_STYLE
|
|
89
|
-
);
|
|
90
|
-
return hub && position && area && squad && style;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
19
|
function walkMarkdown(dir) {
|
|
94
20
|
return readdirSync(dir).flatMap((name) => {
|
|
95
21
|
const p = join(dir, name);
|
|
@@ -99,25 +25,36 @@ function walkMarkdown(dir) {
|
|
|
99
25
|
}
|
|
100
26
|
|
|
101
27
|
/**
|
|
102
|
-
*
|
|
28
|
+
* Diz se uma rule entra na IDE. Toda rule entra, menos duas, decididas pelo nome do arquivo (o
|
|
29
|
+
* conteúdo não é lido): `artifact-style-rules.md` só com `ARTIFACT_STYLE=human-generated` e
|
|
30
|
+
* `rtk-rules.md` só com o RTK ligado. Vale para a rule do core e para a do overlay da empresa.
|
|
31
|
+
* @param {string} relPath - Caminho da rule, relativo à pasta `rules/` (ou `rules-on-demand/`)
|
|
32
|
+
* @param {{ artifactStyle?: string, rtkEnabled?: boolean }} [opts] - `artifactStyle` vazio = `ai-generated`
|
|
33
|
+
* @returns {boolean}
|
|
34
|
+
*/
|
|
35
|
+
export function isRuleEnabled(relPath, { artifactStyle, rtkEnabled = false } = {}) {
|
|
36
|
+
const name = basename(relPath.split("\\").join("/"));
|
|
37
|
+
if (name === "artifact-style-rules.md") {
|
|
38
|
+
return (artifactStyle || DEFAULT_ARTIFACT_STYLE).trim() === "human-generated";
|
|
39
|
+
}
|
|
40
|
+
if (name === "rtk-rules.md") return Boolean(rtkEnabled);
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Lista as rules que entram na IDE, com o tamanho em bytes (o mesmo critério do `jarvis rules sync`).
|
|
103
46
|
* @param {string} rulesDir - Pasta `rules/` do framework
|
|
104
|
-
* @param {
|
|
105
|
-
* @param {{ rtkEnabled?: boolean }} [opts]
|
|
47
|
+
* @param {{ artifactStyle?: string, rtkEnabled?: boolean }} [opts]
|
|
106
48
|
* @returns {Array<{ path: string, bytes: number }>} Ordenado do maior para o menor;
|
|
107
49
|
* `path` é relativo a `rulesDir`, com `/` como separador
|
|
108
50
|
*/
|
|
109
|
-
export function
|
|
51
|
+
export function listRules(rulesDir, opts = {}) {
|
|
110
52
|
if (!existsSync(rulesDir)) return [];
|
|
111
53
|
const result = [];
|
|
112
54
|
for (const file of walkMarkdown(rulesDir)) {
|
|
113
55
|
const rel = relative(rulesDir, file).split(sep).join("/");
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
if (rel.endsWith("rtk-rules.md") && !opts.rtkEnabled) continue;
|
|
118
|
-
if (matchesProfile(parseAppliesTo(content), profile)) {
|
|
119
|
-
result.push({ path: rel, bytes });
|
|
120
|
-
}
|
|
56
|
+
if (!isRuleEnabled(rel, opts)) continue;
|
|
57
|
+
result.push({ path: rel, bytes: Buffer.byteLength(readFileSync(file, "utf-8"), "utf-8") });
|
|
121
58
|
}
|
|
122
59
|
return result.sort((a, b) => b.bytes - a.bytes || a.path.localeCompare(b.path));
|
|
123
60
|
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// Repositórios do workspace × mapa de tecnologias (CDD-MIND-MAP.md), #225.
|
|
2
|
+
// Funções puras e só de leitura: nunca escrevem arquivo. Quem grava o mapa, o bloco do AGENTS.md e o ENV.md
|
|
3
|
+
// é o skill (`/jarvis-init repos`), com a confirmação da pessoa.
|
|
4
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
import { listGitSubdirs } from "./workspace-mode.js";
|
|
7
|
+
|
|
8
|
+
export const MAP_FILE = "CDD-MIND-MAP.md";
|
|
9
|
+
|
|
10
|
+
const norm = (s) => String(s).trim().toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "");
|
|
11
|
+
|
|
12
|
+
/** Tira negrito/crase das pontas (cabeçalho e nome) de uma célula da tabela. */
|
|
13
|
+
const unmark = (s) => String(s).replace(/^[`*\s]+|[`*\s]+$/g, "");
|
|
14
|
+
|
|
15
|
+
/** Nome do repositório: sem link (`[api](api/)` vira `api`), sem negrito/crase e sem barra no fim. */
|
|
16
|
+
const cleanName = (raw) => unmark(String(raw).replace(/\[([^\]]*)\]\([^)]*\)/g, "$1")).replace(/\/+$/, "");
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Nomes dos repositórios do mapa: a 1ª coluna da tabela cujo cabeçalho é `Repositório`.
|
|
20
|
+
* Ignora a linha separadora, a linha-modelo `{pasta}`, comentários HTML e linhas tortas (nunca lança).
|
|
21
|
+
* @param {string} text conteúdo do CDD-MIND-MAP.md
|
|
22
|
+
* @returns {string[]}
|
|
23
|
+
*/
|
|
24
|
+
export function readMapRepos(text) {
|
|
25
|
+
const names = [];
|
|
26
|
+
let inTable = false;
|
|
27
|
+
const body = String(text || "").replace(/<!--[\s\S]*?-->/g, "");
|
|
28
|
+
for (const raw of body.split(/\r?\n/)) {
|
|
29
|
+
const line = raw.trim();
|
|
30
|
+
if (!line.startsWith("|")) {
|
|
31
|
+
inTable = false;
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
const cells = line.replace(/^\|/, "").replace(/\|$/, "").split("|").map((c) => c.trim());
|
|
35
|
+
if (!inTable) {
|
|
36
|
+
if (norm(unmark(cells[0])) === "repositorio") inTable = true;
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
if (cells.every((c) => /^:?-{1,}:?$/.test(c))) continue; // separador
|
|
40
|
+
const name = cleanName(cells[0] || "");
|
|
41
|
+
if (!name || /^\{.*\}$/.test(name)) continue; // vazio ou linha-modelo
|
|
42
|
+
names.push(name);
|
|
43
|
+
}
|
|
44
|
+
return names;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Repositórios (subpastas com `.git`) que não estão no mapa. Só vale no modo `workspace`; sem o arquivo do
|
|
49
|
+
* mapa não há esta pendência (a falta do mapa é pendência própria, de `documentPendencies`); e **todas** as subpastas com `.git` entram, sem filtrar
|
|
50
|
+
* por `WORKSPACE_REPOS` (senão um clone novo, fora da lista, nunca apareceria).
|
|
51
|
+
* @param {{ workspaceDir: string, mode: string|null }} input
|
|
52
|
+
* @returns {string[]}
|
|
53
|
+
*/
|
|
54
|
+
export function reposOutsideMap({ workspaceDir, mode }) {
|
|
55
|
+
if (mode !== "workspace") return [];
|
|
56
|
+
const mapPath = join(workspaceDir, MAP_FILE);
|
|
57
|
+
if (!existsSync(mapPath)) return [];
|
|
58
|
+
let text;
|
|
59
|
+
try {
|
|
60
|
+
text = readFileSync(mapPath, "utf-8");
|
|
61
|
+
} catch {
|
|
62
|
+
return [];
|
|
63
|
+
}
|
|
64
|
+
const inMap = new Set(readMapRepos(text));
|
|
65
|
+
return listGitSubdirs(workspaceDir).filter((name) => !inMap.has(name));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Pendências dos documentos gerados (#225, ajuste do usuário): `AGENTS.md` e `CDD-MIND-MAP.md` existem sempre,
|
|
70
|
+
* nos dois modos, e o `CLAUDE.md` é sempre cópia idêntica do `AGENTS.md` (a fonte). Só lê; quem cria ou
|
|
71
|
+
* sincroniza é o `/jarvis-init upgrade` (item 9.2), com a confirmação da pessoa. Não contam como diferença: o fim de linha (CRLF = LF), o BOM
|
|
72
|
+
* no início e as quebras de linha no fim do arquivo. `AGENTS.md` vazio (só espaços) vale como ausente.
|
|
73
|
+
* @param {string} workspaceDir pasta que contém o `$IDE/`
|
|
74
|
+
* @returns {string[]} um motivo por pendência; vazio = documentos em dia
|
|
75
|
+
*/
|
|
76
|
+
export function documentPendencies(workspaceDir) {
|
|
77
|
+
const read = (name) => {
|
|
78
|
+
try {
|
|
79
|
+
return readFileSync(join(workspaceDir, name), "utf-8")
|
|
80
|
+
.replace(/^\uFEFF/, "")
|
|
81
|
+
.replace(/\r\n/g, "\n")
|
|
82
|
+
.replace(/\n+$/, "");
|
|
83
|
+
} catch {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
const reasons = [];
|
|
88
|
+
if (!existsSync(join(workspaceDir, MAP_FILE))) reasons.push(`criar o mapa de tecnologias (${MAP_FILE})`);
|
|
89
|
+
const agents = read("AGENTS.md");
|
|
90
|
+
if (agents === null || agents.trim() === "") {
|
|
91
|
+
reasons.push("criar o AGENTS.md (e o CLAUDE.md, cópia dele)");
|
|
92
|
+
} else if (read("CLAUDE.md") !== agents) {
|
|
93
|
+
reasons.push("sincronizar o CLAUDE.md com o AGENTS.md (o CLAUDE.md é sempre cópia do AGENTS.md)");
|
|
94
|
+
}
|
|
95
|
+
return reasons;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Frase da pendência. Só nomes de pasta, nunca valores do ENV.md.
|
|
100
|
+
* @param {string[]} names
|
|
101
|
+
* @returns {string} vazio se não há repositório fora do mapa
|
|
102
|
+
*/
|
|
103
|
+
export function reposPendencyLine(names) {
|
|
104
|
+
if (!names.length) return "";
|
|
105
|
+
return `Rode /jarvis-init repos: ${names.length} repositório(s) fora do mapa (${names.join(", ")})`;
|
|
106
|
+
}
|