wendkeep 0.46.2 → 0.47.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/CHANGELOG.md +23 -0
- package/README.md +8 -4
- package/bin/wendkeep.mjs +9 -1
- package/hooks/change-core.mjs +105 -2
- package/package.json +1 -1
- package/src/change.mjs +11 -1
- package/src/init.mjs +5 -33
- package/src/theme.mjs +89 -0
- package/src/vault-theme.mjs +11 -0
- package/src/verify.mjs +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,29 @@ All notable changes to **wendkeep** are documented here. Format based on
|
|
|
4
4
|
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/); this project follows
|
|
5
5
|
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [0.47.0] — 2026-07-23
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- **Grafo do vault conectado: todo artefato de change linka o hub.** `change new` gera
|
|
12
|
+
`design.md` e `tarefas.md` com um backlink full-path pro `proposta.md` da própria change —
|
|
13
|
+
antes nasciam sem nenhum wikilink, ilhas no grafo do Obsidian (num vault real: 48 de 63
|
|
14
|
+
`.md` de `08-Mudanças` órfãos). O full-path (nunca basename, ambíguo entre changes) sobrevive
|
|
15
|
+
ao archive: o `rewriteChangeLinks` retargeta pro `_arquivo` junto com os demais links.
|
|
16
|
+
- **Auto-heal do backlink em `spec.md`.** O delta de spec é escrito à mão, então `verify` e
|
|
17
|
+
`archive` passam a injetar o backlink pro proposta em cada `specs/<capability>/spec.md` que
|
|
18
|
+
estiver sem — idempotente. Nenhum artefato de change fica desconectado do plano↔sessão.
|
|
19
|
+
- **`wendkeep change backlink [--apply]`** — backfill dos artefatos órfãos que já existem no
|
|
20
|
+
vault (changes open e arquivadas), apontando cada `design`/`tarefas`/`spec` pro proposta no
|
|
21
|
+
seu local atual. Dry-run por default; `--apply` escreve. Idempotente.
|
|
22
|
+
- **`wendkeep theme sync`** — re-aplica o color system (snippet CSS + graph color groups) num
|
|
23
|
+
vault existente, sem re-`init`. Recupera o grafo que ficou cinza quando o Obsidian (dono do
|
|
24
|
+
`graph.json`) zera os `colorGroups`. O instalador virou módulo compartilhado com o `init`,
|
|
25
|
+
então os dois nunca divergem.
|
|
26
|
+
- **Snippet define `--file-line-width`.** O CSS gerado passa a definir a largura de linha
|
|
27
|
+
legível (1400px, ajustável) sobre o `body` com `!important` — antes era edição manual em
|
|
28
|
+
cada vault. As capabilities `change-graph` e `vault-theme` documentam o contrato em `07-Specs`.
|
|
29
|
+
|
|
7
30
|
## [0.46.2] — 2026-07-19
|
|
8
31
|
|
|
9
32
|
### Fixed
|
package/README.md
CHANGED
|
@@ -70,7 +70,7 @@ npx wendkeep init
|
|
|
70
70
|
- **`dotcontext`** — *legacy, not recommended, and hidden from the picker.* wendkeep's native a2 loop (`change` / `verify` / gate) already does its job, so installing it **duplicates the harness**. Reachable only via an explicit `--companions dotcontext` for anyone already invested (tune with `--dotcontext-mcp` / `--dotcontext-hooks`).
|
|
71
71
|
|
|
72
72
|
Control with `--companions <csv>` or `--no-companions`. The Claude Code plugin layer (`extraKnownMarketplaces` + `enabledPlugins`) is wired as a bonus where the companion has one.
|
|
73
|
-
6. Install a **color system** into the vault's `.obsidian/`: a CSS snippet that accents notes by type (session/decision/bug/learning, via the `cssclasses` the hooks emit) plus graph color groups by folder. Non-destructive merge into `appearance.json`/`graph.json`; skip with `--no-colors`.
|
|
73
|
+
6. Install a **color system** into the vault's `.obsidian/`: a CSS snippet that accents notes by type (session/decision/bug/learning, via the `cssclasses` the hooks emit) plus graph color groups by folder. Non-destructive merge into `appearance.json`/`graph.json`; skip with `--no-colors`. Re-apply it any time on an existing vault with `wendkeep theme sync` — Obsidian owns `graph.json` and can drop the color groups (a grey graph); the re-sync restores them without a full re-`init`.
|
|
74
74
|
7. Seed the **curated memory layer**: `.brain/CORE.md` (the hand-curated hot layer, with the 3 required sections) and `.brain/COMPACTION_PROTOCOL.md` (the protocol guide). The auto layers (`DIGEST.md`, `index.jsonl`) are generated by the hooks. Validate the curated layer with `wendkeep validate-memory` (cap 25 lines, 3 sections, no secrets/PII).
|
|
75
75
|
8. Seed the **definitions + skills layer**: `.brain/agents/` + `.brain/skills/` (versioned source of truth), including the native process skills `wk-workflow` / `wk-tdd` / `wk-debugging` / `wk-brainstorming` / `wk-planning` / `wk-verify` (some ship templates — e.g. `wk-verify`'s `verdict-template.json` + reviewer prompt). `init` runs `wendkeep sync-defs` for you, delivering the skills to `.claude/skills/` and `.agents/skills/`, and the agent definitions (`.brain/agents/*.toml`) to `.codex/agents/`, plus a managed section in `AGENTS.md` that indexes the skills for Codex; `sync-defs --check` detects stale copies (re-run `sync-defs` after editing `.brain`).
|
|
76
76
|
9. Seed the **change/spec lifecycle**: the `07-Specs/` + `08-Mudanças/` folders and a native `wendkeep.sensors.json` — a critical `memory-validation` sensor (`npx wendkeep validate-memory`) plus one for each of `typecheck` / `test` / `lint` / `build` found in your `package.json`. Add your own with `wendkeep sensors add`. Drives `wendkeep change` / `wendkeep verify` — see **Change lifecycle** below.
|
|
@@ -252,9 +252,13 @@ npx wendkeep change archive dark-mode # gate: sensors + verdict + no op
|
|
|
252
252
|
```
|
|
253
253
|
|
|
254
254
|
The archive promotes the delta into generated `07-Specs/ui.md`, mints an ADR, and the
|
|
255
|
-
Obsidian graph now links *session ↔ change ↔ requirement ↔ decision*.
|
|
256
|
-
|
|
257
|
-
|
|
255
|
+
Obsidian graph now links *session ↔ change ↔ requirement ↔ decision*. Every generated
|
|
256
|
+
artifact (`design`/`tarefas`) is born linking its change's `proposta` hub, and hand-authored
|
|
257
|
+
`spec.md` deltas are auto-linked on `verify`/`archive` — no change artifact is a graph island.
|
|
258
|
+
To backfill older changes that predate this, run `wendkeep change backlink --apply` (dry-run
|
|
259
|
+
without `--apply`). A change that names no `[req:]` still runs `verify --deep`, but skips the
|
|
260
|
+
`wk-verify` reading pass: the command writes a trivial verdict on its own and the sensor gate
|
|
261
|
+
is the real proof.
|
|
258
262
|
|
|
259
263
|
## How it works
|
|
260
264
|
|
package/bin/wendkeep.mjs
CHANGED
|
@@ -44,8 +44,11 @@ Usage:
|
|
|
44
44
|
|
|
45
45
|
wendkeep doctor [--vault P] Run a vault health check.
|
|
46
46
|
wendkeep change <sub> Change lifecycle: new [--simple] | use | bind <slug> --session <id> | continue | list | show |
|
|
47
|
-
status | done <id> | undone <id> | diff | archive [--force] | abandon.
|
|
47
|
+
status | done <id> | undone <id> | diff | archive [--force] | abandon | relink | backlink.
|
|
48
48
|
archive exige verdict (rode verify --deep); abandon descarta sem ADR.
|
|
49
|
+
backlink [--apply]: injeta o backlink pro proposta em design/tarefas/spec órfãos (open + _arquivo).
|
|
50
|
+
wendkeep theme sync Re-aplica o color system (snippet CSS + graph color groups) num vault
|
|
51
|
+
existente — recupera o grafo cinza sem re-init. --vault P.
|
|
49
52
|
wendkeep session <sub> Session registry: list | show <id> | use <id>.
|
|
50
53
|
wendkeep spec <sub> Specs: list | show | effective [--change] [--json] | migrate | rebase.
|
|
51
54
|
wendkeep sensors <sub> list | add <id> "<command>" [--severity --type --report].
|
|
@@ -175,6 +178,11 @@ async function main() {
|
|
|
175
178
|
runSession(rest);
|
|
176
179
|
break;
|
|
177
180
|
}
|
|
181
|
+
case 'theme': {
|
|
182
|
+
const { runTheme } = await import('../src/theme.mjs');
|
|
183
|
+
runTheme(rest);
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
178
186
|
case 'verify': {
|
|
179
187
|
const { runVerify } = await import('../src/verify.mjs');
|
|
180
188
|
runVerify(rest);
|
package/hooks/change-core.mjs
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
// Native change/spec lifecycle in the vault (Pilar B). Vault-facing lib consumed by
|
|
3
3
|
// the `wendkeep change` CLI (src/change.mjs) and the brain-inject hook. No external deps.
|
|
4
4
|
import { existsSync, mkdirSync, readFileSync, readdirSync, renameSync, statSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
5
|
-
import { dirname, join } from 'node:path';
|
|
5
|
+
import { dirname, join, relative } from 'node:path';
|
|
6
6
|
import { ensureDir, wikilinkFromRel, monthFolderRelFromDateStr } from './obsidian-common.mjs';
|
|
7
7
|
import { parseSpecsList, promoteSpecs, discoverSpecDeltas, tasksHashOf, captureSpecBaseline, REQ_ID_RE_SRC } from './spec-core.mjs';
|
|
8
|
-
import { getLocale } from './locale.mjs';
|
|
8
|
+
import { getLocale, LOCALES } from './locale.mjs';
|
|
9
9
|
|
|
10
10
|
export const ARCHIVE_DIR = '_arquivo';
|
|
11
11
|
const POINTER = '.brain/CURRENT_CHANGE.md';
|
|
@@ -39,12 +39,21 @@ specs: []
|
|
|
39
39
|
|
|
40
40
|
${en ? '## Why\n\n(reason for the change)\n\n## What changes\n\n(scope of the change)' : '## Por quê\n\n(motivo da mudança)\n\n## O que muda\n\n(escopo da mudança)'}
|
|
41
41
|
`;
|
|
42
|
+
// Hub backlink: design/tarefas link the change's proposta so no generated artifact is a
|
|
43
|
+
// graph island. Full-path (never basename — proposta/design exist in every change) so the
|
|
44
|
+
// archive's rewriteChangeLinks retargets it to _arquivo when the change moves.
|
|
45
|
+
const changesFolder = (LOCALES[locale] || LOCALES['pt-BR']).folders.changes;
|
|
46
|
+
const hubLink = `> ${en ? 'Change:' : 'Mudança:'} [[${changesFolder}/${slug}/proposta]]`;
|
|
42
47
|
const design = `# ${slug} — design
|
|
43
48
|
|
|
49
|
+
${hubLink}
|
|
50
|
+
|
|
44
51
|
${en ? '## Approach\n\n(technical approach)' : '## Abordagem\n\n(abordagem técnica)'}
|
|
45
52
|
`;
|
|
46
53
|
const tarefas = `# ${slug} — ${en ? 'tasks' : 'tarefas'}
|
|
47
54
|
|
|
55
|
+
${hubLink}
|
|
56
|
+
|
|
48
57
|
- [ ] 1.1 ${en ? '(first task)' : '(primeira tarefa)'}
|
|
49
58
|
`;
|
|
50
59
|
const reqHeading = en ? 'Requirement' : 'Requisito';
|
|
@@ -419,6 +428,10 @@ export function archiveChange(vaultBase, slug, { gate = gateGreen, dateStr, adrN
|
|
|
419
428
|
let reqIds = [];
|
|
420
429
|
try { reqIds = [...new Set(parseTasks(readFileSync(join(src, 'tarefas.md'), 'utf8')).flatMap((t) => t.reqs ?? []))]; } catch { /* sem tarefas */ }
|
|
421
430
|
|
|
431
|
+
// Backlink dos artefatos escritos à mão (spec.md) ANTES do move — o rewriteChangeLinks
|
|
432
|
+
// abaixo retargeta o wikilink pro _arquivo junto com os demais. Fail-quiet.
|
|
433
|
+
try { healSpecBacklinks(src, vaultBase); } catch { /* heal é bônus */ }
|
|
434
|
+
|
|
422
435
|
ensureDir(join(vaultBase, chDir, ARCHIVE_DIR));
|
|
423
436
|
try {
|
|
424
437
|
renameSync(src, destAbs);
|
|
@@ -512,6 +525,96 @@ function rewriteChangeLinks(vaultBase, fromRel, toRel) {
|
|
|
512
525
|
return touched;
|
|
513
526
|
}
|
|
514
527
|
|
|
528
|
+
// --- backlinks de artefato -> hub proposta (grafo conectado) -------------------
|
|
529
|
+
// design/tarefas nascem linkando o hub (renderChangeScaffold); spec.md é escrito à mão,
|
|
530
|
+
// então recebe o backlink por auto-heal (verify/archive) + backfill dos vaults existentes.
|
|
531
|
+
function backlinkLabel(loc) {
|
|
532
|
+
return loc.id === 'en' ? 'Change:' : 'Mudança:';
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
// Injeta a linha de backlink logo abaixo do primeiro heading — mas NUNCA acima de um bloco
|
|
536
|
+
// de frontmatter YAML: prepender antes do `---` quebra o frontmatter (Obsidian para de ler
|
|
537
|
+
// cssclasses/tags). Ordem: preserva o frontmatter, depois cai abaixo do 1º heading do corpo,
|
|
538
|
+
// senão no topo do corpo.
|
|
539
|
+
function insertBacklink(content, backlinkLine) {
|
|
540
|
+
let head = '';
|
|
541
|
+
let body = content;
|
|
542
|
+
const fm = content.match(/^---\n[\s\S]*?\n---\n?/);
|
|
543
|
+
if (fm) { head = fm[0]; body = content.slice(fm[0].length); }
|
|
544
|
+
const h = body.match(/^\s*#[^\n]*\n/);
|
|
545
|
+
if (h) {
|
|
546
|
+
const rest = body.slice(h[0].length).replace(/^\n+/, '');
|
|
547
|
+
return `${head}${h[0]}\n${backlinkLine}\n\n${rest}`;
|
|
548
|
+
}
|
|
549
|
+
const rest = body.replace(/^\n+/, '');
|
|
550
|
+
return `${head}${backlinkLine}\n\n${rest}`;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
// Auto-heal (0.47): garante o backlink pro proposta em cada specs/<cap>/spec.md do change.
|
|
554
|
+
// Idempotente (pula quem já tem o link exato). Chamado no verify e no archive (antes do move,
|
|
555
|
+
// pra o rewriteChangeLinks retargetar pro _arquivo). Retorna quantos arquivos healou.
|
|
556
|
+
export function healSpecBacklinks(changeDir, vaultBase) {
|
|
557
|
+
const loc = getLocale(vaultBase);
|
|
558
|
+
const propRel = `${relative(vaultBase, changeDir).replaceAll('\\', '/')}/proposta`;
|
|
559
|
+
const link = `[[${propRel}]]`;
|
|
560
|
+
const line = `> ${backlinkLabel(loc)} ${link}`;
|
|
561
|
+
let caps = [];
|
|
562
|
+
try { caps = readdirSync(join(changeDir, 'specs'), { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name); }
|
|
563
|
+
catch { return 0; }
|
|
564
|
+
let healed = 0;
|
|
565
|
+
for (const cap of caps) {
|
|
566
|
+
const p = join(changeDir, 'specs', cap, 'spec.md');
|
|
567
|
+
let c;
|
|
568
|
+
try { c = readFileSync(p, 'utf8'); } catch { continue; }
|
|
569
|
+
if (c.includes(link)) continue;
|
|
570
|
+
try { writeFileSync(p, insertBacklink(c, line), 'utf8'); healed += 1; } catch { /* readonly — segue */ }
|
|
571
|
+
}
|
|
572
|
+
return healed;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
// Backfill (0.47): cura design/tarefas/spec órfãos em changes já existentes — open e _arquivo.
|
|
576
|
+
// Aponta cada artefato pro proposta no seu local atual (arquivado usa o path do _arquivo).
|
|
577
|
+
// Dry-run por default; `apply` escreve. Idempotente (pula quem já linka o proposta certo).
|
|
578
|
+
export function backfillArtifactLinks(vaultBase, { apply = false } = {}) {
|
|
579
|
+
const loc = getLocale(vaultBase);
|
|
580
|
+
const chDir = loc.folders.changes;
|
|
581
|
+
const label = backlinkLabel(loc);
|
|
582
|
+
const base = join(vaultBase, chDir);
|
|
583
|
+
const dirs = [];
|
|
584
|
+
try {
|
|
585
|
+
for (const name of readdirSync(base)) {
|
|
586
|
+
if (name === ARCHIVE_DIR) continue;
|
|
587
|
+
const d = join(base, name);
|
|
588
|
+
if (existsSync(join(d, 'proposta.md'))) dirs.push(d);
|
|
589
|
+
}
|
|
590
|
+
} catch { /* sem changes */ }
|
|
591
|
+
try {
|
|
592
|
+
for (const name of readdirSync(join(base, ARCHIVE_DIR))) {
|
|
593
|
+
const d = join(base, ARCHIVE_DIR, name);
|
|
594
|
+
if (existsSync(join(d, 'proposta.md'))) dirs.push(d);
|
|
595
|
+
}
|
|
596
|
+
} catch { /* sem arquivo */ }
|
|
597
|
+
|
|
598
|
+
const changed = [];
|
|
599
|
+
for (const dir of dirs) {
|
|
600
|
+
const propRel = `${relative(vaultBase, dir).replaceAll('\\', '/')}/proposta`;
|
|
601
|
+
const link = `[[${propRel}]]`;
|
|
602
|
+
const line = `> ${label} ${link}`;
|
|
603
|
+
let caps = [];
|
|
604
|
+
try { caps = readdirSync(join(dir, 'specs'), { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => join('specs', e.name, 'spec.md')); }
|
|
605
|
+
catch { /* sem specs */ }
|
|
606
|
+
for (const rel of ['design.md', 'tarefas.md', ...caps]) {
|
|
607
|
+
const p = join(dir, rel);
|
|
608
|
+
let c;
|
|
609
|
+
try { c = readFileSync(p, 'utf8'); } catch { continue; }
|
|
610
|
+
if (c.includes(link)) continue;
|
|
611
|
+
if (apply) { try { writeFileSync(p, insertBacklink(c, line), 'utf8'); } catch { continue; } }
|
|
612
|
+
changed.push(relative(vaultBase, p).replaceAll('\\', '/'));
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
return { applied: apply, scanned: dirs.length, changed };
|
|
616
|
+
}
|
|
617
|
+
|
|
515
618
|
// Cura retroativa (vaults pré-0.35): wikilinks para changes que já moveram sem reescrita.
|
|
516
619
|
// Dry-run por default; match por slug no nome datado do archive (`<data>-<slug>[-abandonada]`);
|
|
517
620
|
// ambíguo (mesmo slug arquivado 2×) é reportado e pulado — nunca chuta.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wendkeep",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.47.0",
|
|
4
4
|
"description": "A persistent-memory harness for AI coding agents on your Obsidian vault: turn-by-turn session capture plus a native, zero-dependency spec→change→verify→archive loop (sensor-gated, independent verdict, mutation discrimination). Local-first, agent-agnostic (Claude Code, Codex, Cursor…).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
package/src/change.mjs
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
archiveChange,
|
|
15
15
|
abandonChange,
|
|
16
16
|
relinkChanges,
|
|
17
|
+
backfillArtifactLinks,
|
|
17
18
|
scaffoldPlaceholders,
|
|
18
19
|
} from '../hooks/change-core.mjs';
|
|
19
20
|
import { evaluateGate, requiredSensors } from '../hooks/sensors-core.mjs';
|
|
@@ -308,6 +309,15 @@ export function runChange(argv) {
|
|
|
308
309
|
process.exit(0);
|
|
309
310
|
}
|
|
310
311
|
|
|
312
|
+
if (sub === 'backlink') {
|
|
313
|
+
const r = backfillArtifactLinks(vaultBase, { apply: rest.includes('--apply') });
|
|
314
|
+
if (rest.includes('--json')) { process.stdout.write(`${JSON.stringify(r, null, 2)}\n`); process.exit(0); }
|
|
315
|
+
process.stdout.write(`${r.changed.length} artefato(s) órfão(s) em ${r.scanned} change(s)${r.applied ? ' · reescritos' : ''}\n`);
|
|
316
|
+
for (const f of r.changed) process.stdout.write(` ${f}\n`);
|
|
317
|
+
if (!r.applied && r.changed.length) process.stdout.write('\ndry-run — nada escrito. Rode com --apply para injetar os backlinks.\n');
|
|
318
|
+
process.exit(0);
|
|
319
|
+
}
|
|
320
|
+
|
|
311
321
|
if (sub === 'abandon') {
|
|
312
322
|
const slug = slugArg() || activeChange(vaultBase);
|
|
313
323
|
if (!slug) { process.stderr.write('wendkeep change abandon: missing <slug> and no active change\n'); process.exit(2); }
|
|
@@ -317,6 +327,6 @@ export function runChange(argv) {
|
|
|
317
327
|
process.exit(0);
|
|
318
328
|
}
|
|
319
329
|
|
|
320
|
-
process.stderr.write(`wendkeep change: unknown subcommand "${sub}". Known: new, use, continue, list, show, status, done, undone, diff, archive, abandon, relink.\n`);
|
|
330
|
+
process.stderr.write(`wendkeep change: unknown subcommand "${sub}". Known: new, use, continue, list, show, status, done, undone, diff, archive, abandon, relink, backlink.\n`);
|
|
321
331
|
process.exit(2);
|
|
322
332
|
}
|
package/src/init.mjs
CHANGED
|
@@ -31,13 +31,7 @@ import {
|
|
|
31
31
|
import { renderVaultReadme } from './vault-readme.mjs';
|
|
32
32
|
import { seedVaultViews } from './vault-views.mjs';
|
|
33
33
|
import { canInteractiveSelect, selectCompanionsInteractive } from './companion-select.mjs';
|
|
34
|
-
import {
|
|
35
|
-
SNIPPET_NAME,
|
|
36
|
-
renderColorSnippetCss,
|
|
37
|
-
mergeAppearance,
|
|
38
|
-
graphColorGroups,
|
|
39
|
-
mergeGraphColorGroups,
|
|
40
|
-
} from './vault-theme.mjs';
|
|
34
|
+
import { syncVaultTheme } from './theme.mjs';
|
|
41
35
|
import { renderCoreSkeleton, renderCompactionProtocol } from './validate-core.mjs';
|
|
42
36
|
import { seedDefinitions, syncDefs } from './sync-defs.mjs';
|
|
43
37
|
import { seedWkSkills } from './skills-seed.mjs';
|
|
@@ -261,33 +255,11 @@ function runCavemanInstaller(log) {
|
|
|
261
255
|
}
|
|
262
256
|
}
|
|
263
257
|
|
|
264
|
-
// Install the vault color system into .obsidian: write wendkeep's CSS snippet,
|
|
265
|
-
//
|
|
266
|
-
// Unparseable user JSON is left untouched
|
|
258
|
+
// Install the vault color system into .obsidian: write wendkeep's CSS snippet, enable it
|
|
259
|
+
// (non-destructive), and add graph color groups. Shared installer lives in theme.mjs so
|
|
260
|
+
// `init` and `theme sync` never drift. Unparseable user JSON is left untouched.
|
|
267
261
|
function installVaultColors(vaultPath) {
|
|
268
|
-
|
|
269
|
-
const obsidianDir = join(vaultPath, '.obsidian');
|
|
270
|
-
const snippetsDir = join(obsidianDir, 'snippets');
|
|
271
|
-
mkdirSync(snippetsDir, { recursive: true });
|
|
272
|
-
writeFileSync(join(snippetsDir, `${SNIPPET_NAME}.css`), renderColorSnippetCss(loc), 'utf8');
|
|
273
|
-
|
|
274
|
-
let enabled = false;
|
|
275
|
-
const appPath = join(obsidianDir, 'appearance.json');
|
|
276
|
-
const appRead = readJsonSafe(appPath);
|
|
277
|
-
if (appRead.ok) {
|
|
278
|
-
writeJson(appPath, mergeAppearance(appRead.data || {}, SNIPPET_NAME));
|
|
279
|
-
enabled = true;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
let groups = 0;
|
|
283
|
-
const graphPath = join(obsidianDir, 'graph.json');
|
|
284
|
-
const graphRead = readJsonSafe(graphPath);
|
|
285
|
-
if (graphRead.ok) {
|
|
286
|
-
const merged = mergeGraphColorGroups(graphRead.data || {}, graphColorGroups(loc));
|
|
287
|
-
writeJson(graphPath, merged);
|
|
288
|
-
groups = graphColorGroups(loc).length;
|
|
289
|
-
}
|
|
290
|
-
return `snippet ${SNIPPET_NAME}.css${enabled ? ' (enabled)' : ' (enable by hand: appearance.json unreadable)'} + ${groups} graph group(s)`;
|
|
262
|
+
return syncVaultTheme(vaultPath).summary;
|
|
291
263
|
}
|
|
292
264
|
|
|
293
265
|
// --- main -------------------------------------------------------------------
|
package/src/theme.mjs
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// `wendkeep theme sync` — re-apply the vault color system into .obsidian on an EXISTING
|
|
2
|
+
// vault, idempotently: rewrite the CSS snippet, enable it (non-destructive), and (re)merge
|
|
3
|
+
// the graph color groups. The installer is shared with `wendkeep init` so the two never drift.
|
|
4
|
+
//
|
|
5
|
+
// Why a re-sync exists: .obsidian/graph.json is owned by Obsidian, which can drop the
|
|
6
|
+
// colorGroups wendkeep wrote (vault init'd by an older version, or Obsidian rewriting the
|
|
7
|
+
// file). Without a re-apply path the only fix was a full re-init. This command restores the
|
|
8
|
+
// graph colors without touching anything else.
|
|
9
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
10
|
+
import { isAbsolute, join, resolve } from 'node:path';
|
|
11
|
+
import { getLocale } from '../hooks/locale.mjs';
|
|
12
|
+
import {
|
|
13
|
+
SNIPPET_NAME,
|
|
14
|
+
renderColorSnippetCss,
|
|
15
|
+
mergeAppearance,
|
|
16
|
+
graphColorGroups,
|
|
17
|
+
mergeGraphColorGroups,
|
|
18
|
+
} from './vault-theme.mjs';
|
|
19
|
+
|
|
20
|
+
// { ok, data }. ok=false means the file EXISTS but is unparseable — never clobber it.
|
|
21
|
+
// Absent -> ok=true, data=null (we create it).
|
|
22
|
+
function readJsonSafe(path) {
|
|
23
|
+
if (!existsSync(path)) return { ok: true, data: null };
|
|
24
|
+
try { return { ok: true, data: JSON.parse(readFileSync(path, 'utf8')) }; }
|
|
25
|
+
catch { return { ok: false, data: null }; }
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function writeJson(path, obj) {
|
|
29
|
+
writeFileSync(path, `${JSON.stringify(obj, null, 2)}\n`, 'utf8');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Pure-ish installer (does file I/O, no process exit). Returns a short summary + counts.
|
|
33
|
+
// Consumed by both `wendkeep init` (installVaultColors) and `wendkeep theme sync`.
|
|
34
|
+
export function syncVaultTheme(vaultPath) {
|
|
35
|
+
const loc = getLocale(vaultPath);
|
|
36
|
+
const obsidianDir = join(vaultPath, '.obsidian');
|
|
37
|
+
const snippetsDir = join(obsidianDir, 'snippets');
|
|
38
|
+
mkdirSync(snippetsDir, { recursive: true });
|
|
39
|
+
writeFileSync(join(snippetsDir, `${SNIPPET_NAME}.css`), renderColorSnippetCss(loc), 'utf8');
|
|
40
|
+
|
|
41
|
+
let enabled = false;
|
|
42
|
+
const appPath = join(obsidianDir, 'appearance.json');
|
|
43
|
+
const appRead = readJsonSafe(appPath);
|
|
44
|
+
if (appRead.ok) {
|
|
45
|
+
writeJson(appPath, mergeAppearance(appRead.data || {}, SNIPPET_NAME));
|
|
46
|
+
enabled = true;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
let groups = 0;
|
|
50
|
+
const graphPath = join(obsidianDir, 'graph.json');
|
|
51
|
+
const graphRead = readJsonSafe(graphPath);
|
|
52
|
+
if (graphRead.ok) {
|
|
53
|
+
writeJson(graphPath, mergeGraphColorGroups(graphRead.data || {}, graphColorGroups(loc)));
|
|
54
|
+
groups = graphColorGroups(loc).length;
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
enabled,
|
|
58
|
+
groups,
|
|
59
|
+
summary: `snippet ${SNIPPET_NAME}.css${enabled ? ' (enabled)' : ' (enable by hand: appearance.json unreadable)'} + ${groups} graph group(s)`,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function resolveVault(argv) {
|
|
64
|
+
let vault;
|
|
65
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
66
|
+
const a = argv[i];
|
|
67
|
+
if (a === '--vault') vault = argv[++i];
|
|
68
|
+
else if (a.startsWith('--vault=')) vault = a.slice(8);
|
|
69
|
+
}
|
|
70
|
+
const base = vault || process.env.OBSIDIAN_VAULT_PATH;
|
|
71
|
+
if (!base) {
|
|
72
|
+
process.stderr.write('wendkeep theme: no vault. Pass --vault <path> or set OBSIDIAN_VAULT_PATH.\n');
|
|
73
|
+
process.exit(2);
|
|
74
|
+
}
|
|
75
|
+
return isAbsolute(base) ? base : resolve(process.cwd(), base);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function runTheme(argv) {
|
|
79
|
+
const [sub, ...rest] = argv;
|
|
80
|
+
if (sub !== 'sync') {
|
|
81
|
+
process.stderr.write(`wendkeep theme: unknown subcommand "${sub || ''}". Known: sync.\n`);
|
|
82
|
+
process.exit(2);
|
|
83
|
+
}
|
|
84
|
+
const vaultBase = resolveVault(rest);
|
|
85
|
+
const r = syncVaultTheme(vaultBase);
|
|
86
|
+
process.stdout.write(`theme sync: ${r.summary}\n`);
|
|
87
|
+
process.stdout.write('feche o Obsidian antes de rodar e reabra depois — ele é dono do graph.json e recarrega as cores na abertura.\n');
|
|
88
|
+
process.exit(0);
|
|
89
|
+
}
|
package/src/vault-theme.mjs
CHANGED
|
@@ -8,6 +8,10 @@
|
|
|
8
8
|
|
|
9
9
|
export const SNIPPET_NAME = 'wendkeep-colors';
|
|
10
10
|
|
|
11
|
+
// Readable line width for note content — Obsidian's default (~700px) wastes wide monitors.
|
|
12
|
+
// Ajuste aqui (1200px / 1400px / 100vw) para mudar em todos os vaults de uma vez.
|
|
13
|
+
export const READABLE_LINE_WIDTH = '1400px';
|
|
14
|
+
|
|
11
15
|
import { LOCALES } from '../hooks/locale.mjs';
|
|
12
16
|
const PT = LOCALES['pt-BR'];
|
|
13
17
|
|
|
@@ -86,6 +90,13 @@ ${rootVars}
|
|
|
86
90
|
.theme-dark { --us-line-tint: 44%; }
|
|
87
91
|
.theme-light { --us-line-tint: 36%; }
|
|
88
92
|
|
|
93
|
+
/* --- Readable line width: wider than Obsidian's ~700px default ------------ */
|
|
94
|
+
/* !important porque o Obsidian declara --file-line-width com specificity alta; sem ele
|
|
95
|
+
a regra do body não vence e a linha volta pro ~700px. */
|
|
96
|
+
body {
|
|
97
|
+
--file-line-width: ${READABLE_LINE_WIDTH} !important;
|
|
98
|
+
}
|
|
99
|
+
|
|
89
100
|
/* --- File explorer: accented folders ------------------------------------- */
|
|
90
101
|
${FX} {
|
|
91
102
|
border-left: 3px solid transparent;
|
package/src/verify.mjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// the VAULT. Writes 08-Mudanças/<slug>/evidencia.json; exit 1 if a critical sensor is red.
|
|
4
4
|
import { readFileSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
5
5
|
import { isAbsolute, join, resolve } from 'node:path';
|
|
6
|
-
import { parseTasks, activeChange, appendFixTasks } from '../hooks/change-core.mjs';
|
|
6
|
+
import { parseTasks, activeChange, appendFixTasks, healSpecBacklinks } from '../hooks/change-core.mjs';
|
|
7
7
|
import { loadSensorsDetailed, findProjectRoot, requiredSensors, runSensors, evaluateGate } from '../hooks/sensors-core.mjs';
|
|
8
8
|
import {
|
|
9
9
|
buildEffectiveRequirementPackage,
|
|
@@ -41,6 +41,9 @@ export function runVerify(argv) {
|
|
|
41
41
|
try { tarefas = readFileSync(join(changeDir, 'tarefas.md'), 'utf8'); }
|
|
42
42
|
catch { process.stderr.write(`wendkeep verify: change not found: ${slug}\n`); process.exit(2); }
|
|
43
43
|
|
|
44
|
+
// Backlink dos specs escritos à mão pro hub proposta (grafo conectado). Idempotente, fail-quiet.
|
|
45
|
+
try { healSpecBacklinks(changeDir, vaultBase); } catch { /* heal é bônus */ }
|
|
46
|
+
|
|
44
47
|
const ids = requiredSensors(parseTasks(tarefas));
|
|
45
48
|
const loaded = loadSensorsDetailed(projectRoot);
|
|
46
49
|
if (loaded.error) {
|