@forwardimpact/libwiki 0.2.35 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +53 -52
  2. package/package.json +6 -8
  3. package/src/active-claims.js +5 -5
  4. package/src/agent-roster.js +2 -2
  5. package/src/audit/admission.js +14 -11
  6. package/src/audit/conflict-markers-rule.js +9 -9
  7. package/src/audit/grammar.js +21 -18
  8. package/src/audit/rule-builders.js +20 -19
  9. package/src/audit/rules.js +35 -32
  10. package/src/audit/scopes.js +35 -34
  11. package/src/audit/status-row.js +14 -15
  12. package/src/block-renderer.js +5 -4
  13. package/src/boot.js +10 -8
  14. package/src/budget-gate.js +39 -36
  15. package/src/budget.js +3 -3
  16. package/src/cli-definition.js +35 -32
  17. package/src/commands/audit.js +3 -3
  18. package/src/commands/boot.js +2 -2
  19. package/src/commands/claim.js +46 -40
  20. package/src/commands/curate.js +34 -31
  21. package/src/commands/fix.js +74 -70
  22. package/src/commands/inbox.js +2 -2
  23. package/src/commands/init.js +13 -8
  24. package/src/commands/ledger.js +12 -12
  25. package/src/commands/log.js +20 -18
  26. package/src/commands/memo.js +5 -2
  27. package/src/commands/product-mix.js +18 -17
  28. package/src/commands/refresh.js +25 -22
  29. package/src/commands/rotate.js +10 -9
  30. package/src/commands/sync.js +26 -17
  31. package/src/conflict-markers.js +21 -21
  32. package/src/constants.js +38 -34
  33. package/src/gitattributes.js +10 -9
  34. package/src/integrity.js +29 -27
  35. package/src/issue-list-renderer.js +24 -16
  36. package/src/lane-files.js +11 -10
  37. package/src/ledger/anchor.js +6 -6
  38. package/src/ledger/projection.js +35 -32
  39. package/src/ledger/reader.js +4 -4
  40. package/src/marker-scanner.js +3 -2
  41. package/src/sanitize.js +12 -11
  42. package/src/secret-gate.js +41 -40
  43. package/src/status.js +12 -11
  44. package/src/storyboard-skeleton.js +20 -18
  45. package/src/util/agent-flag.js +8 -8
  46. package/src/util/clock.js +1 -1
  47. package/src/util/wiki-dir.js +7 -7
  48. package/src/weekly-log.js +115 -101
  49. package/src/wiki-sync.js +411 -379
  50. package/bin/fit-wiki.js +0 -94
package/bin/fit-wiki.js DELETED
@@ -1,94 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import "@forwardimpact/libpreflight/node22";
4
-
5
- import { createDefaultRuntime } from "@forwardimpact/libutil/runtime";
6
- import { GitClient } from "@forwardimpact/libutil/git-client";
7
- import { GhClient } from "@forwardimpact/libutil/gh-client";
8
- import { createScriptConfig } from "@forwardimpact/libconfig";
9
- import { createCli } from "@forwardimpact/libcli";
10
- import { createLogger } from "@forwardimpact/libtelemetry";
11
- import { WikiSync } from "../src/wiki-sync.js";
12
- import {
13
- resolveProjectRoot,
14
- resolveWikiRoot,
15
- wikiExists,
16
- } from "../src/util/wiki-dir.js";
17
- import { createDefinition } from "../src/cli-definition.js";
18
-
19
- // Commands that mutate or sync the remote wiki need a constructed WikiSync
20
- // (and its config-backed token resolver); the rest run against the local tree.
21
- const NEEDS_WIKI_SYNC = new Set(["claim", "release", "push", "pull", "init"]);
22
-
23
- // The ledger command reads and writes the allocation-anchor surface (the
24
- // obstacle issue's comments) over the GitHub API, so it needs a GhClient.
25
- const NEEDS_GH_CLIENT = new Set(["ledger"]);
26
-
27
- async function main() {
28
- const runtime = createDefaultRuntime();
29
- const definition = createDefinition();
30
- const cli = createCli(definition, {
31
- runtime,
32
- packageJsonUrl: new URL("../package.json", import.meta.url),
33
- });
34
-
35
- const parsed = cli.parse(runtime.proc.argv.slice(2));
36
- if (!parsed) return runtime.proc.exit(0); // --help / --version already printed
37
-
38
- const { positionals } = parsed;
39
- if (positionals.length === 0) {
40
- cli.showHelp();
41
- return runtime.proc.exit(0);
42
- }
43
-
44
- const command = positionals[0];
45
- if (!definition.commands.some((c) => c.name === command)) {
46
- cli.usageError(`unknown command "${command}"`);
47
- return runtime.proc.exit(2);
48
- }
49
-
50
- // Every command except `init` operates on an existing wiki tree. When it is
51
- // absent (e.g. a fresh worktree where bootstrap.sh never ran), degrade
52
- // gracefully: warn and exit 0 so the session Stop hook and other callers do
53
- // not fail loudly. `init` is exempt — it creates the tree.
54
- if (command !== "init") {
55
- const wikiDir = resolveWikiRoot(runtime, parsed.values);
56
- if (!wikiExists(runtime, wikiDir)) {
57
- createLogger("wiki", runtime).warn(
58
- command,
59
- `no wiki at ${wikiDir}; skipping (run \`fit-wiki init\` to create one)`,
60
- );
61
- return runtime.proc.exit(0);
62
- }
63
- }
64
-
65
- const gitClient = new GitClient({ runtime });
66
- let wikiSync;
67
- if (NEEDS_WIKI_SYNC.has(command)) {
68
- const projectRoot = resolveProjectRoot(runtime);
69
- const wikiDir = resolveWikiRoot(runtime, parsed.values);
70
- const config = await createScriptConfig("wiki");
71
- wikiSync = new WikiSync({
72
- runtime,
73
- gitClient,
74
- wikiDir,
75
- parentDir: projectRoot,
76
- resolveToken: () => config.ghToken(),
77
- });
78
- }
79
-
80
- let ghClient;
81
- if (NEEDS_GH_CLIENT.has(command)) {
82
- ghClient = new GhClient({ runtime });
83
- }
84
-
85
- const result = await cli.dispatch(parsed, {
86
- deps: { runtime, wikiSync, gitClient, ghClient },
87
- });
88
-
89
- const envelope = result ?? { ok: true };
90
- if (!envelope.ok && envelope.error) cli.usageError(envelope.error);
91
- runtime.proc.exit(envelope.ok ? 0 : (envelope.code ?? 1));
92
- }
93
-
94
- main();