forjajs 4.1.1 → 4.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/bin/create-memory-nest-kit.js +0 -0
- package/dist/bin/forja.js +0 -0
- package/dist/bin/init-project.js +0 -0
- package/dist/lib/specs-index.d.ts +1 -0
- package/dist/lib/specs-index.js +22 -3
- package/dist/lib/status-model.js +6 -1
- package/dist/lib/workspace.js +13 -1
- package/dist/scripts/forja-status.d.ts +1 -1
- package/dist/scripts/forja-status.js +28 -1
- package/dist/scripts/hook-session-start.js +9 -1
- package/dist/scripts/sprint-manager.js +19 -7
- package/dist/scripts/sync-universal-memory.js +30 -14
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -19,6 +19,22 @@ GitHub reusa esse bloco. O README também é reconciliado na mesma entrega — v
|
|
|
19
19
|
|
|
20
20
|
_(preencher a cada release: diff de produto vs. a versão anterior, antes das seções técnicas)_
|
|
21
21
|
|
|
22
|
+
## [4.1.2] — 2026-09-18 — Correção: status reconhece specs e indexador suporta symlinks de projetos
|
|
23
|
+
|
|
24
|
+
### O que melhorou
|
|
25
|
+
|
|
26
|
+
- **`forja status` e `forja next` passam a reconhecer as specs do projeto corretamente.** Quando executado a partir de um projeto consumidor (modo embedded ou via CLI), o status não mais reporta falsamente "nenhuma spec" nem lista as specs do próprio framework Forja. A raiz do repositório/projeto é resolvida dinamicamente, permitindo também consultar um projeto específico (`forja status <projeto>`).
|
|
27
|
+
- **O parser de status das specs agora é flexível e tolerante.** Suporta cabeçalhos de status com ou sem negrito/bullets, remove backticks (ex.: `` `approved` ``) e reconhece termos em português (`em implementação` → `implementing`, `concluído` → `done`, `aprovado` → `approved`).
|
|
28
|
+
- **Indexador da memória universal (`sync:universal`) e `project:list` passam a reconhecer vínculos simbólicos (symlinks).** Diretórios de projetos linkados via symlink em `projects/` (como em `~/forja-workspace/projects/`) deixam de ser ignorados por `Dirent.isDirectory()`, sendo totalmente descobertos, listados e indexados com seus diretórios de `specs/`, `memory/`, `docs/` e `design-md/`.
|
|
29
|
+
|
|
30
|
+
### Corrigido
|
|
31
|
+
|
|
32
|
+
- `scripts/forja-status.ts`, `scripts/hook-session-start.ts` e `scripts/sprint-manager.ts`: substituída a resolução estática baseada em `__dirname` por resolução dinâmica (`resolveRepoRoot` / `getWorkspaceRoot` / `process.cwd()`), eliminando o bug em que o caminho apontava para `node_modules/forjajs/dist` ou a raiz do framework (#70).
|
|
33
|
+
- `lib/specs-index.ts`: regex e normalizador flexíveis para cabeçalhos de status SDD em specs (#70).
|
|
34
|
+
- `lib/workspace.ts`: `listProjects()` atualizado para inspecionar `entry.isSymbolicLink()` via `fs.statSync()`, permitindo listar diretórios linkados por symlinks (#70).
|
|
35
|
+
- `scripts/sync-universal-memory.ts`: `walk()` atualizado para seguir links simbólicos de diretórios, uso de `listProjects()` na varredura de projetos e inclusão de `projectPath/specs` na indexação (#70).
|
|
36
|
+
|
|
37
|
+
|
|
22
38
|
## [4.1.1] — 2026-09-08 — Disciplina de release: README + "O que melhorou" acompanham toda versão
|
|
23
39
|
|
|
24
40
|
### O que melhorou
|
|
File without changes
|
package/dist/bin/forja.js
CHANGED
|
File without changes
|
package/dist/bin/init-project.js
CHANGED
|
File without changes
|
|
@@ -13,6 +13,7 @@ export interface SpecEntry {
|
|
|
13
13
|
/** Status de `tasks.md`, ou `null` se o arquivo não existe. */
|
|
14
14
|
readonly tasks: string | null;
|
|
15
15
|
}
|
|
16
|
+
export declare function normalizeStatus(raw: string): string;
|
|
16
17
|
/**
|
|
17
18
|
* Lista as specs versionadas do repo com o status de cada artefato SDD. `root` é a raiz do repo
|
|
18
19
|
* (onde vive `specs/`). Nunca lança.
|
package/dist/lib/specs-index.js
CHANGED
|
@@ -6,7 +6,25 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import fs from 'node:fs';
|
|
8
8
|
import path from 'node:path';
|
|
9
|
-
const
|
|
9
|
+
const STATUS_LINE_RE = /(?:^|\n)[-*]?\s*\*+Status\*+:\s*([^\n\r]+)/i;
|
|
10
|
+
const STATUS_ALT_RE = /(?:^|\n)Status:\s*([^\n\r]+)/i;
|
|
11
|
+
export function normalizeStatus(raw) {
|
|
12
|
+
const trimmed = raw.replace(/[`*]/g, '').trim().toLowerCase();
|
|
13
|
+
if (/^(done|conclu[íi]do|concluida|concluido|completed|finalizado)/i.test(trimmed))
|
|
14
|
+
return 'done';
|
|
15
|
+
if (/^(implementing|em implementa[çc][ãa]o|implementando)/i.test(trimmed))
|
|
16
|
+
return 'implementing';
|
|
17
|
+
if (/^(approved|aprovado|aprovada)/i.test(trimmed))
|
|
18
|
+
return 'approved';
|
|
19
|
+
if (/^(review|em revis[ãa]o|revis[ãa]o|revisao)/i.test(trimmed))
|
|
20
|
+
return 'review';
|
|
21
|
+
if (/^(draft|rascunho)/i.test(trimmed))
|
|
22
|
+
return 'draft';
|
|
23
|
+
if (/^(abandoned|abandonado|cancelado)/i.test(trimmed))
|
|
24
|
+
return 'abandoned';
|
|
25
|
+
const firstWord = trimmed.split(/[\s|—–-]+/)[0];
|
|
26
|
+
return firstWord || 'unknown';
|
|
27
|
+
}
|
|
10
28
|
function safeReadDir(p) {
|
|
11
29
|
try {
|
|
12
30
|
return fs.readdirSync(p);
|
|
@@ -19,8 +37,9 @@ function statusOf(file) {
|
|
|
19
37
|
try {
|
|
20
38
|
if (!fs.existsSync(file))
|
|
21
39
|
return null;
|
|
22
|
-
const
|
|
23
|
-
|
|
40
|
+
const content = fs.readFileSync(file, 'utf8');
|
|
41
|
+
const m = content.match(STATUS_LINE_RE) || content.match(STATUS_ALT_RE);
|
|
42
|
+
return m ? normalizeStatus(m[1]) : 'unknown';
|
|
24
43
|
}
|
|
25
44
|
catch {
|
|
26
45
|
return null;
|
package/dist/lib/status-model.js
CHANGED
|
@@ -93,7 +93,12 @@ export async function collectStatus(repoRoot, opts = {}) {
|
|
|
93
93
|
}
|
|
94
94
|
let recentRuns;
|
|
95
95
|
try {
|
|
96
|
-
const
|
|
96
|
+
const projectDir = path.join(repoRoot, '.context');
|
|
97
|
+
const dir = fs.existsSync(path.join(projectDir, 'forja-runs.jsonl'))
|
|
98
|
+
? projectDir
|
|
99
|
+
: wi.exists
|
|
100
|
+
? getWorkspaceContextDir()
|
|
101
|
+
: projectDir;
|
|
97
102
|
recentRuns = ok(readRecentRuns(dir, runsLimit));
|
|
98
103
|
}
|
|
99
104
|
catch (e) {
|
package/dist/lib/workspace.js
CHANGED
|
@@ -121,7 +121,19 @@ export function listProjects() {
|
|
|
121
121
|
return [];
|
|
122
122
|
return fs
|
|
123
123
|
.readdirSync(dir, { withFileTypes: true })
|
|
124
|
-
.filter((entry) =>
|
|
124
|
+
.filter((entry) => {
|
|
125
|
+
if (entry.isDirectory())
|
|
126
|
+
return true;
|
|
127
|
+
if (entry.isSymbolicLink()) {
|
|
128
|
+
try {
|
|
129
|
+
return fs.statSync(path.join(dir, entry.name)).isDirectory();
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return false;
|
|
136
|
+
})
|
|
125
137
|
.map((entry) => entry.name);
|
|
126
138
|
}
|
|
127
139
|
export function ensureDir(dir) {
|
|
@@ -8,12 +8,37 @@
|
|
|
8
8
|
* Somente leitura. Sai 0 sempre que o modelo montou (subsistema indisponível não é falha do
|
|
9
9
|
* comando). O dispatch por `status`/`next` vem do `args` do registry.
|
|
10
10
|
*/
|
|
11
|
+
import fs from 'node:fs';
|
|
11
12
|
import path from 'node:path';
|
|
12
13
|
import { fileURLToPath } from 'node:url';
|
|
13
14
|
import { collectStatus, recommendNext } from "../lib/status-model.js";
|
|
14
15
|
import { emitOk } from "../lib/cli-output.js";
|
|
16
|
+
import { getWorkspaceRoot, isInsideFrameworkRepo, resolveProject } from "../lib/workspace.js";
|
|
15
17
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
16
|
-
const
|
|
18
|
+
const frameworkRoot = path.resolve(__dirname, '..');
|
|
19
|
+
export function resolveRepoRoot(targetArg) {
|
|
20
|
+
if (targetArg && targetArg !== '.' && targetArg !== 'root' && !targetArg.startsWith('-')) {
|
|
21
|
+
try {
|
|
22
|
+
const projDir = resolveProject(targetArg);
|
|
23
|
+
if (fs.existsSync(projDir))
|
|
24
|
+
return projDir;
|
|
25
|
+
}
|
|
26
|
+
catch { }
|
|
27
|
+
const direct = path.resolve(targetArg);
|
|
28
|
+
if (fs.existsSync(direct))
|
|
29
|
+
return direct;
|
|
30
|
+
}
|
|
31
|
+
const cwd = path.resolve(process.cwd());
|
|
32
|
+
if (isInsideFrameworkRepo(cwd)) {
|
|
33
|
+
return frameworkRoot;
|
|
34
|
+
}
|
|
35
|
+
if (fs.existsSync(path.join(cwd, 'specs')) ||
|
|
36
|
+
fs.existsSync(path.join(cwd, 'memory')) ||
|
|
37
|
+
fs.existsSync(path.join(cwd, 'package.json'))) {
|
|
38
|
+
return cwd;
|
|
39
|
+
}
|
|
40
|
+
return getWorkspaceRoot();
|
|
41
|
+
}
|
|
17
42
|
function sub(s, render) {
|
|
18
43
|
return s.available ? render(s.value) : [` indisponível: ${s.reason}`];
|
|
19
44
|
}
|
|
@@ -55,6 +80,8 @@ function renderStatus(m) {
|
|
|
55
80
|
const argv = process.argv.slice(2);
|
|
56
81
|
const cmd = argv[0] === 'next' ? 'next' : 'status';
|
|
57
82
|
const json = argv.includes('--json');
|
|
83
|
+
const targetArg = argv.find((a) => a !== 'status' && a !== 'next' && a !== '--json' && !a.startsWith('-'));
|
|
84
|
+
const repoRoot = resolveRepoRoot(targetArg);
|
|
58
85
|
const model = await collectStatus(repoRoot);
|
|
59
86
|
if (cmd === 'next') {
|
|
60
87
|
const next = recommendNext(model);
|
|
@@ -14,14 +14,22 @@
|
|
|
14
14
|
* e "banco ausente" no mesmo `null`, e então prescrevia `npm install` — que não recompila binário
|
|
15
15
|
* nativo. Quem seguisse o conselho do próprio framework não consertava nada.
|
|
16
16
|
*/
|
|
17
|
+
import fs from 'node:fs';
|
|
17
18
|
import path from 'node:path';
|
|
18
19
|
import { fileURLToPath } from 'node:url';
|
|
19
20
|
import { runChecks, bucketFor, BUCKET_LABEL } from "../lib/core/health.js";
|
|
20
21
|
import { listSpecs } from "../lib/specs-index.js";
|
|
21
22
|
import { openHandoffs } from "../lib/handoffs-index.js";
|
|
23
|
+
import { getWorkspaceRoot, isInsideFrameworkRepo } from "../lib/workspace.js";
|
|
22
24
|
const __filename = fileURLToPath(import.meta.url);
|
|
23
25
|
const __dirname = path.dirname(__filename);
|
|
24
|
-
const
|
|
26
|
+
const frameworkRoot = path.resolve(__dirname, '..');
|
|
27
|
+
const cwd = path.resolve(process.cwd());
|
|
28
|
+
const root = isInsideFrameworkRepo(cwd)
|
|
29
|
+
? frameworkRoot
|
|
30
|
+
: (fs.existsSync(path.join(cwd, 'specs')) || fs.existsSync(path.join(cwd, 'package.json')))
|
|
31
|
+
? cwd
|
|
32
|
+
: getWorkspaceRoot();
|
|
25
33
|
/**
|
|
26
34
|
* Nunca lança e nunca trava a sessão: o hook reporta, o `tools:doctor` é que é gate. Se a própria
|
|
27
35
|
* lib de health não carregar, seguimos com o resto do briefing em vez de abortar (ADR-0021).
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
|
-
import { resolveProject, initWorkspace } from "../lib/workspace.js";
|
|
4
|
+
import { resolveProject, initWorkspace, isInsideFrameworkRepo } from "../lib/workspace.js";
|
|
5
5
|
const __filename = fileURLToPath(import.meta.url);
|
|
6
6
|
const __dirname = path.dirname(__filename);
|
|
7
|
-
const
|
|
7
|
+
const frameworkRoot = path.resolve(__dirname, '..');
|
|
8
|
+
const cwd = path.resolve(process.cwd());
|
|
8
9
|
const [cmd, projectArg, ...args] = process.argv.slice(2);
|
|
9
10
|
if (!cmd) {
|
|
10
11
|
console.log('Uso: node scripts/sprint-manager.js <start|status|complete> [projeto|.|root] [args]');
|
|
@@ -13,14 +14,25 @@ if (!cmd) {
|
|
|
13
14
|
}
|
|
14
15
|
const project = projectArg || '.';
|
|
15
16
|
let projectDir;
|
|
16
|
-
if (project === '
|
|
17
|
-
projectDir =
|
|
17
|
+
if (project === 'root') {
|
|
18
|
+
projectDir = frameworkRoot;
|
|
19
|
+
}
|
|
20
|
+
else if (project === '.') {
|
|
21
|
+
if (isInsideFrameworkRepo(cwd)) {
|
|
22
|
+
projectDir = frameworkRoot;
|
|
23
|
+
}
|
|
24
|
+
else if (fs.existsSync(path.join(cwd, 'memory/40-delivery')) || fs.existsSync(path.join(cwd, 'package.json'))) {
|
|
25
|
+
projectDir = cwd;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
projectDir = frameworkRoot;
|
|
29
|
+
}
|
|
18
30
|
}
|
|
19
31
|
else {
|
|
20
32
|
initWorkspace();
|
|
21
33
|
projectDir = resolveProject(project);
|
|
22
34
|
}
|
|
23
|
-
const projectLabel = projectDir ===
|
|
35
|
+
const projectLabel = projectDir === frameworkRoot ? 'framework-root' : (project === '.' ? path.basename(projectDir) : project);
|
|
24
36
|
if (!fs.existsSync(projectDir)) {
|
|
25
37
|
console.error(`Projeto nao encontrado: ${project}`);
|
|
26
38
|
process.exit(1);
|
|
@@ -164,11 +176,11 @@ ${pending.length ? pending.map((item) => `- ${item}`).join('\n') : '- Nenhuma'}
|
|
|
164
176
|
- Nova sprint ainda não iniciada.
|
|
165
177
|
|
|
166
178
|
## Próximo passo
|
|
167
|
-
- Execute: node scripts/sprint-manager.js start ${projectDir ===
|
|
179
|
+
- Execute: node scripts/sprint-manager.js start ${projectDir === frameworkRoot ? '' : project}
|
|
168
180
|
`;
|
|
169
181
|
fs.writeFileSync(sprintFile, resetSprint, 'utf8');
|
|
170
182
|
console.log(`Sprint encerrada para ${projectLabel}.`);
|
|
171
|
-
console.log(`Relatorio: ${path.relative(
|
|
183
|
+
console.log(`Relatorio: ${path.relative(projectDir, reportFile)}`);
|
|
172
184
|
if (pending.length > 0) {
|
|
173
185
|
console.log(`${pending.length} pendencia(s) devolvida(s) para Alta Prioridade no backlog.`);
|
|
174
186
|
}
|
|
@@ -4,7 +4,7 @@ import crypto from 'node:crypto';
|
|
|
4
4
|
import Database from 'better-sqlite3';
|
|
5
5
|
import { fileURLToPath } from 'node:url';
|
|
6
6
|
import { ensureSchema, getDbPath } from "./memory-schema.js";
|
|
7
|
-
import { initWorkspace, getForjaMode, getWorkspaceRoot, getProjectsDir, getWorkspaceSpecsDir, getWorkspaceProjectsMemoryDir, } from "../lib/workspace.js";
|
|
7
|
+
import { initWorkspace, getForjaMode, getWorkspaceRoot, getProjectsDir, getWorkspaceSpecsDir, getWorkspaceProjectsMemoryDir, listProjects, } from "../lib/workspace.js";
|
|
8
8
|
const __filename = fileURLToPath(import.meta.url);
|
|
9
9
|
const __dirname = path.dirname(__filename);
|
|
10
10
|
const root = path.resolve(__dirname, '..');
|
|
@@ -60,9 +60,21 @@ function walk(dir, out = []) {
|
|
|
60
60
|
if (entry.name === 'node_modules' || entry.name === '.git' || entry.name === '.memory')
|
|
61
61
|
continue;
|
|
62
62
|
const abs = path.join(dir, entry.name);
|
|
63
|
-
|
|
63
|
+
let isDir = entry.isDirectory();
|
|
64
|
+
let isFile = entry.isFile();
|
|
65
|
+
if (entry.isSymbolicLink()) {
|
|
66
|
+
try {
|
|
67
|
+
const stat = fs.statSync(abs);
|
|
68
|
+
isDir = stat.isDirectory();
|
|
69
|
+
isFile = stat.isFile();
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (isDir)
|
|
64
76
|
walk(abs, out);
|
|
65
|
-
else if (
|
|
77
|
+
else if (isFile && entry.name.endsWith('.md'))
|
|
66
78
|
out.push(abs);
|
|
67
79
|
}
|
|
68
80
|
return out;
|
|
@@ -216,7 +228,10 @@ function syncAssetCatalog() {
|
|
|
216
228
|
}
|
|
217
229
|
function syncFiles(files, projectId = null) {
|
|
218
230
|
for (const abs of files) {
|
|
219
|
-
|
|
231
|
+
let rel = path.relative(root, abs);
|
|
232
|
+
if (rel.startsWith('..')) {
|
|
233
|
+
rel = path.relative(operationRoot, abs);
|
|
234
|
+
}
|
|
220
235
|
const raw = fs.readFileSync(abs, 'utf8');
|
|
221
236
|
const hash = crypto.createHash('sha256').update(raw).digest('hex');
|
|
222
237
|
const titleMatch = raw.match(/^#\s+(.+)$/m);
|
|
@@ -257,21 +272,22 @@ if (syncProjects && mode === 'embedded') {
|
|
|
257
272
|
], pid);
|
|
258
273
|
}
|
|
259
274
|
else if (syncProjects && fs.existsSync(projectsDir)) {
|
|
260
|
-
const
|
|
261
|
-
|
|
262
|
-
.filter(e => !onlyProject || e.name === onlyProject);
|
|
263
|
-
if (onlyProject && projects.length === 0) {
|
|
275
|
+
const projectNames = listProjects().filter((name) => !onlyProject || name === onlyProject);
|
|
276
|
+
if (onlyProject && projectNames.length === 0) {
|
|
264
277
|
log(`Projeto nao encontrado para sync: ${onlyProject}`, 'warn');
|
|
265
278
|
}
|
|
266
|
-
for (const
|
|
267
|
-
log(`Sincronizando Projeto: ${
|
|
268
|
-
const projectPath = path.join(projectsDir,
|
|
269
|
-
upsertProject.run(
|
|
270
|
-
const pid = getProjectId.get(
|
|
279
|
+
for (const name of projectNames) {
|
|
280
|
+
log(`Sincronizando Projeto: ${name}...`, 'info');
|
|
281
|
+
const projectPath = path.join(projectsDir, name);
|
|
282
|
+
upsertProject.run(name, projectPath, now);
|
|
283
|
+
const pid = getProjectId.get(name).id;
|
|
271
284
|
// Indexa memória, documentação, spec SDD e referências de design do projeto (somente .md)
|
|
272
285
|
const projectMemFiles = walk(path.join(projectPath, 'memory'));
|
|
273
286
|
const projectDocsFiles = walk(path.join(projectPath, 'docs'));
|
|
274
|
-
const projectSpecFiles =
|
|
287
|
+
const projectSpecFiles = [
|
|
288
|
+
...walk(path.join(projectPath, 'specs')),
|
|
289
|
+
...walk(path.join(getWorkspaceSpecsDir(), name)),
|
|
290
|
+
];
|
|
275
291
|
const projectDesignFiles = walk(path.join(projectPath, 'design-md'));
|
|
276
292
|
syncFiles([...projectMemFiles, ...projectDocsFiles, ...projectSpecFiles, ...projectDesignFiles], pid);
|
|
277
293
|
}
|
package/package.json
CHANGED