@warpgogol/forge 9.6.0 → 9.6.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 +28 -0
- package/README.md +161 -104
- package/README.uk.md +175 -117
- package/dist/os/core/core.module.d.ts.map +1 -1
- package/dist/os/core/core.module.js +58 -5
- package/dist/os/core/core.module.js.map +1 -1
- package/dist/os/core/handlers/package-health.d.ts.map +1 -1
- package/dist/os/core/handlers/package-health.js +95 -8
- package/dist/os/core/handlers/package-health.js.map +1 -1
- package/dist/os/flow/handlers/flow-cut.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-cut.js +27 -6
- package/dist/os/flow/handlers/flow-cut.js.map +1 -1
- package/dist/os/rfc/rfc.module.d.ts.map +1 -1
- package/dist/os/rfc/rfc.module.js +7 -3
- package/dist/os/rfc/rfc.module.js.map +1 -1
- package/dist/src/onboarding/scaffold-project.d.ts.map +1 -1
- package/dist/src/onboarding/scaffold-project.js +21 -2
- package/dist/src/onboarding/scaffold-project.js.map +1 -1
- package/dist/src/validators/skill-doc-sync.d.ts +76 -0
- package/dist/src/validators/skill-doc-sync.d.ts.map +1 -0
- package/dist/src/validators/skill-doc-sync.js +333 -0
- package/dist/src/validators/skill-doc-sync.js.map +1 -0
- package/docs/concepts/governance-model.md +9 -1
- package/docs/concepts/verification-model.md +31 -0
- package/docs/guides/existing-project.md +12 -0
- package/docs/guides/skills.md +27 -8
- package/docs/guides/upgrading.md +6 -2
- package/docs/guides/verification-and-evidence.md +45 -0
- package/docs/integrations/devin.md +49 -0
- package/docs/reference/cli.md +12 -1
- package/docs/reference/fleet-measurement.md +52 -0
- package/docs/reference/programmatic-api.md +62 -33
- package/os/core/core.module.ts +70 -11
- package/os/core/handlers/package-health.test.ts +104 -23
- package/os/core/handlers/package-health.ts +133 -19
- package/os/flow/handlers/flow-cut.ts +27 -6
- package/os/flow/tests/flow-cut.rerun.test.ts +54 -4
- package/os/rfc/rfc.module.ts +7 -3
- package/package.json +1 -1
- package/profiles/forge-shell.yaml +1 -0
- package/profiles/godot-game.yaml +1 -0
- package/profiles/phaser-game.yaml +1 -0
- package/profiles/site-workshop.yaml +1 -0
- package/profiles/system.yaml +1 -0
- package/profiles/typescript.yaml +1 -0
- package/skills/fo/fo-session-retro/SKILL.md +6 -4
- package/src/onboarding/scaffold-project.ts +19 -2
- package/src/tests/skill-doc-sync.test.ts +233 -0
- package/src/validators/skill-doc-sync.ts +449 -0
package/docs/reference/cli.md
CHANGED
|
@@ -16,9 +16,12 @@ forge build
|
|
|
16
16
|
```sh
|
|
17
17
|
forge skill.validate
|
|
18
18
|
forge skill.list
|
|
19
|
+
forge skill.doc-sync [--write] [--files <csv>] [--root <dir>]
|
|
19
20
|
forge agents.generate
|
|
20
21
|
```
|
|
21
22
|
|
|
23
|
+
`forge skill.doc-sync` derives skill counts and inventory tables in docs from `FORGE_SKILLS` (in the werkstatt monorepo: `werkstatt run forge.skill.doc-sync`). `--write` re-renders paired `forge:skills-count` / `forge:skills-inventory` HTML-comment marker regions in place; the default check mode fails on marked-region drift and on skill-count claims outside markers that contradict the registry (exempt intentional claims with a same-line `forge-skill-count:ok` comment). Scans `README*.md`, `AGENTS.md`, and `docs/**/*.md` minus record trees; `forge.package.health` composes the same check as PKG-HEALTH-13.
|
|
24
|
+
|
|
22
25
|
## RFC
|
|
23
26
|
|
|
24
27
|
```sh
|
|
@@ -120,6 +123,14 @@ forge session.audit.report
|
|
|
120
123
|
forge metrics.aggregate
|
|
121
124
|
```
|
|
122
125
|
|
|
126
|
+
## Codebase measurement (RFC-1581)
|
|
127
|
+
|
|
128
|
+
```sh
|
|
129
|
+
forge codebase.measure [--json] [--out <path>]
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Read-only `git ls-files` measurement: categorized line counts (`code`/`tests`/`docs`/`generated`), per-language code/comment/blank lines, AST-derived class/function/method counts for the TS/JS family, and top directories by code lines. `--json` returns the full structured measure; `--out` writes a dated YAML snapshot to an explicit path (the command's only write). See [fleet measurement methodology](fleet-measurement.md).
|
|
133
|
+
|
|
123
134
|
## Docs
|
|
124
135
|
|
|
125
136
|
```sh
|
|
@@ -273,4 +284,4 @@ forge note.orphan.detect
|
|
|
273
284
|
|
|
274
285
|
Canonical registry names (see `docs/command-manifest.generated.yaml` for the full inventory) not covered in the usage sections above:
|
|
275
286
|
|
|
276
|
-
`audit.archive`, `file.size.lint`, `flow.publication.retire`, `flow.status`, `flow.version`, `forge.assets.check`, `forge.assets.list`, `forge.build`, `forge.conformance.run`, `forge.conformance.validate`, `forge.create`, `forge.determinism.check`, `forge.dev`, `forge.doctor`, `forge.port.scaffold`, `forge.port.validate`, `forge.profile.validate`, `forge.public-surface.validate`, `forge.release.prepare`, `forge.release.publish`, `forge.scaffold`, `forge.skill.knowledge.compact`, `forge.skill.list`, `forge.skill.validate`, `forge.validate`, `memory.compact`, `mission.archive`, `outbox.validate`, `plan.archive`, `spec.live.rebuild`, `system.map.validate`, `system.outbox.scan`, `system.task.collect`, `system.task.create`, `system.task.dispatch`, `system.task.move`, `system.task.status`, `system.versionset.record`.
|
|
287
|
+
`audit.archive`, `file.size.lint`, `flow.publication.retire`, `flow.status`, `flow.version`, `forge.assets.check`, `forge.assets.list`, `forge.build`, `forge.conformance.run`, `forge.conformance.validate`, `forge.create`, `forge.determinism.check`, `forge.dev`, `forge.doctor`, `forge.port.scaffold`, `forge.port.validate`, `forge.profile.validate`, `forge.public-surface.validate`, `forge.release.prepare`, `forge.release.publish`, `forge.scaffold`, `forge.skill.doc-sync`, `forge.skill.knowledge.compact`, `forge.skill.list`, `forge.skill.validate`, `forge.validate`, `memory.compact`, `mission.archive`, `outbox.validate`, `plan.archive`, `spec.live.rebuild`, `system.map.validate`, `system.outbox.scan`, `system.task.collect`, `system.task.create`, `system.task.dispatch`, `system.task.move`, `system.task.status`, `system.versionset.record`.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Fleet measurement methodology
|
|
2
|
+
|
|
3
|
+
The README's "Forged in production" table is produced by `forge codebase.measure` (RFC-1581) — Forge's own measurement command — run over each repository's git-tracked files at develop tip on 2026-11-13.
|
|
4
|
+
|
|
5
|
+
## What is measured
|
|
6
|
+
|
|
7
|
+
- **Scope:** `git ls-files` — tracked files only.
|
|
8
|
+
- **Classification:** every tracked line lands in exactly one category — `code`, `tests`, `docs`, or `generated`. `Total` in the README table is their sum; generated, vendored and mirrored content is classified separately, never silently merged into `code`.
|
|
9
|
+
- **Lines:** per-language code / comment / blank counts.
|
|
10
|
+
- **Symbols:** a real AST pass — the TypeScript compiler is resolved lazily from the measured workspace, so class/function/method counts come from the compiler, not regexes. Where a workspace resolves a compiler the walker cannot use, the command reports `symbolsSkipped` instead of estimating.
|
|
11
|
+
- **Exclusions:** export mirrors and deployment caches are excluded to avoid double counting the same source.
|
|
12
|
+
|
|
13
|
+
## Reproduce
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
pnpm exec forge codebase.measure --json # full structured result
|
|
17
|
+
pnpm exec forge codebase.measure --out <file.yaml> # dated YAML snapshot
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
`--out` is the command's only write; without it the run is read-only.
|
|
21
|
+
|
|
22
|
+
## Worked example
|
|
23
|
+
|
|
24
|
+
`codebase.measure --json` over the werkstatt monorepo, 2026-11-14 (develop tip, trimmed to structure):
|
|
25
|
+
|
|
26
|
+
```json
|
|
27
|
+
{
|
|
28
|
+
"command": "codebase.measure",
|
|
29
|
+
"status": "ok",
|
|
30
|
+
"repo": "werkstatt",
|
|
31
|
+
"totals": {
|
|
32
|
+
"code": { "files": 6612, "code": 812595 },
|
|
33
|
+
"tests": { "files": 2710, "code": 353483 },
|
|
34
|
+
"docs": { "files": 3836, "code": 234971 },
|
|
35
|
+
"generated": { "files": 951, "code": 346409 }
|
|
36
|
+
},
|
|
37
|
+
"binaryFiles": 36,
|
|
38
|
+
"measuredAt": "2026-11-14T05:40:44.176Z"
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
The full result also carries `languages`, `topDirs`, `symbolsSkipped`, `exclusions`, and `nextSteps`. Numbers drift between measurement days as the fleet changes — the README table states its own measurement date.
|
|
43
|
+
|
|
44
|
+
## Limitations
|
|
45
|
+
|
|
46
|
+
- **Self-measured.** The numbers come from Forge's own instrument over private repositories — an instrument reading, not an independent audit.
|
|
47
|
+
- **Lines are not outcomes.** Scale demonstrates that Forge operates on real systems; it does not by itself prove governance quality.
|
|
48
|
+
- **Revisions move.** Repositories evolve; rerun the command for current numbers.
|
|
49
|
+
|
|
50
|
+
## Observed outcome (one concrete example)
|
|
51
|
+
|
|
52
|
+
Scale aside, do the gates catch anything? `forge gate.probe` exists to answer exactly that — it seeds a declared violation at the real workspace path and proves the gate still fires (see [the scenario guide](../guides/verification-and-evidence.md#gate-probes--prove-the-gate-still-fires)). Inside the fleet, friction records document real catches — e.g. F-0208: a refused commit left `git add` residue staged in the index, which the next gate run surfaced instead of silently inheriting. The catch came from a validator refusing, not from an agent noticing.
|
|
@@ -1,23 +1,40 @@
|
|
|
1
1
|
# Programmatic API
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`@warpgogol/forge` exposes module factories, config helpers, the skill registry, and canonical types from its package root. Modules expose `commands` and `pipelines` arrays directly — read them; you do not need a registry object.
|
|
4
|
+
|
|
5
|
+
## A complete working example
|
|
6
|
+
|
|
7
|
+
This snippet compiles against the published API surface:
|
|
4
8
|
|
|
5
9
|
```ts
|
|
6
10
|
import {
|
|
7
|
-
|
|
8
|
-
forgeRfcModule,
|
|
9
|
-
forgeAdrModule,
|
|
10
|
-
forgeNamingModule,
|
|
11
|
-
forgeCompassModule,
|
|
12
|
-
forgeWorkflowModule,
|
|
13
|
-
forgeSpecModule,
|
|
14
|
-
forgeSessionModule,
|
|
15
|
-
forgePluginModule,
|
|
16
|
-
forgeProgramModule,
|
|
11
|
+
createForgeRfcModule,
|
|
17
12
|
loadForgeConfig,
|
|
18
|
-
resolveBinding,
|
|
19
13
|
FORGE_SKILLS,
|
|
14
|
+
type ForgeLogger,
|
|
15
|
+
type ForgeRuntimeContext,
|
|
20
16
|
} from "@warpgogol/forge";
|
|
17
|
+
|
|
18
|
+
const logger: ForgeLogger = {
|
|
19
|
+
section: console.log,
|
|
20
|
+
info: console.log,
|
|
21
|
+
warn: console.warn,
|
|
22
|
+
error: console.error,
|
|
23
|
+
success: console.log,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const context: ForgeRuntimeContext = {
|
|
27
|
+
workspaceRoot: process.cwd(),
|
|
28
|
+
logger,
|
|
29
|
+
dryRun: false,
|
|
30
|
+
outputFormat: "json",
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const rfcModule = await createForgeRfcModule();
|
|
34
|
+
const rfcValidate = rfcModule.commands.find((c) => c.name === "rfc.validate");
|
|
35
|
+
|
|
36
|
+
const result = await rfcValidate?.execute({ argv: [], flags: {} }, context);
|
|
37
|
+
console.log(result?.exitCode); // 0 = pass, 1 = fail
|
|
21
38
|
```
|
|
22
39
|
|
|
23
40
|
## Loading config
|
|
@@ -37,38 +54,50 @@ const cmd = resolveBinding(config, "commands.validateRfc", { id: "RFC-0001" });
|
|
|
37
54
|
|
|
38
55
|
Placeholders in binding strings are substituted with the provided values.
|
|
39
56
|
|
|
40
|
-
##
|
|
57
|
+
## Invoking commands
|
|
41
58
|
|
|
42
|
-
|
|
43
|
-
const registry = /* your ForgeModuleRegistry */;
|
|
59
|
+
Each `ForgeCommandDefinition` carries `name`, `flags`, `reads`/`writes` declarations, and `execute(input, context)`:
|
|
44
60
|
|
|
45
|
-
|
|
46
|
-
await
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
61
|
+
```ts
|
|
62
|
+
const result = await command.execute(
|
|
63
|
+
{ argv: ["--json"], flags: { json: true } },
|
|
64
|
+
context,
|
|
65
|
+
);
|
|
50
66
|
```
|
|
51
67
|
|
|
52
|
-
|
|
68
|
+
`ForgeCommandResult` carries `exitCode` (0/1), `summary`, optional `data`, `nextSteps`, and `timing`. Handlers must degrade cleanly when optional context ports (`commandRegistry`, `io`, `invoke`) are absent — under the standalone CLI, `io` and `invoke` are not populated.
|
|
69
|
+
|
|
70
|
+
`ForgeModuleRegistry` (`registerCommand`/`registerPipeline`) is the collection interface the standalone `forge` CLI builds internally — consumers read `module.commands` / `module.pipelines` instead of implementing it.
|
|
53
71
|
|
|
54
|
-
##
|
|
72
|
+
## Exported modules
|
|
55
73
|
|
|
56
|
-
|
|
74
|
+
Factories return `Promise<ForgeModule>`; `forgeCompassModule`, `forgeWerkstattModule` and `forgePluginModule` are exported consts.
|
|
75
|
+
|
|
76
|
+
| Module | Command surface (canonical names; the CLI also resolves the unqualified spelling) |
|
|
57
77
|
| --- | --- |
|
|
58
|
-
| `
|
|
59
|
-
| `
|
|
60
|
-
| `
|
|
61
|
-
| `
|
|
62
|
-
| `
|
|
63
|
-
| `
|
|
64
|
-
| `
|
|
65
|
-
| `
|
|
78
|
+
| `createForgeCoreModule` | `forge.create`, `forge.init`, `forge.scaffold`, `forge.doctor`, `forge.upgrade`, `forge.validate`, `forge.dev`, `forge.build`, `forge.skill.*`, `forge.agents.generate`, `forge.profile.validate`, `forge.port.*`, `forge.public-surface.validate`, `forge.autonomy.validate`, `forge.package.health`, `forge.release.*`, `forge.determinism.check`, `forge.assets.*`, `docs.archive`, `memory.compact`, `pinned.*`, `file.size.lint` |
|
|
79
|
+
| `createForgeRfcModule` | `rfc.list`, `rfc.create`, `rfc.validate`, `rfc.next-id`, `rfc.check`, `rfc.archive`, `rfc.acceptance.run`, `rfc.verification.*`, `rfc.implement.stamp`, `rfc.evidence.sync`, `rfc.verify.workspace`, `rfc.supersede.propose`, `rfc.index.*`, `rfc.graph`, `rfc.decision-log.generate`, `rfc.dna.trace.*`, `rfc.pipeline.status`, `rfc.command-lifecycle.validate` |
|
|
80
|
+
| `createForgeAdrModule` | `adr.list`, `adr.create`, `adr.validate`, `adr.archive`, `adr.implement.stamp` |
|
|
81
|
+
| `createForgePlanModule` | `plan.archive` |
|
|
82
|
+
| `createForgeAuditModule` | `audit.archive` |
|
|
83
|
+
| `createForgeMissionModule` | `mission.archive` |
|
|
84
|
+
| `createForgeSpecModule` | `spec.validate`, `spec.status`, `spec.materialize`, `spec.live.list`, `spec.live.show`, `spec.live.validate`, `spec.live.merge`, `spec.live.rebuild` |
|
|
85
|
+
| `createForgeProgramModule` | `program.packet.validate`, `program.packet.seal`, `program.packet.lease`, `program.packet.complete` |
|
|
66
86
|
| `forgePluginModule` | `forge.plugin.validate`, `forge.plugin.discover` |
|
|
67
|
-
| `
|
|
87
|
+
| `createForgeWorkflowModule` | `workflow.lint`, `workflow.list` |
|
|
88
|
+
| `createForgeNamingModule` | `naming.convention.lint` |
|
|
89
|
+
| `forgeCompassModule` | `compass.inventory`, `compass.validate`, `compass.summary.trim`, `compass.docs.scaffold`, `compass.docs.validate`, `compass.header.scaffold`, `compass.migrate`, `compass.invariants.generate`, `compass.audit.*` |
|
|
90
|
+
| `forgeWerkstattModule` | `werkstatt.lock.status`, `werkstatt.lock.recover`, `werkstatt.operation.validate` |
|
|
91
|
+
| `createForgeExplorationModule` | `exploration.list`, `exploration.show`, `exploration.archive` |
|
|
92
|
+
| `createForgeNotesModule` | `note.link.validate`, `note.frontmatter.validate`, `note.orphan.detect` |
|
|
93
|
+
| `createForgeFlowModule` | `flow.open`, `flow.check`, `flow.integrate`, `flow.discard`, `flow.fix`, `flow.digest`, `flow.push`, `flow.cut`, `flow.hold`, `flow.unhold`, `flow.backmerge`, `flow.install`, `flow.status`, `flow.peers`, `flow.version`, `flow.publication.retire` |
|
|
94
|
+
| `createForgeSystemModule` | `system.map.validate`, `system.outbox.scan`, `system.task.*`, `system.versionset.record`, `outbox.validate` |
|
|
95
|
+
|
|
96
|
+
Internal modules loaded by the standalone CLI (session, context, trajectory, gate, conformance, correctness, codebase, and others) are not part of the package's public export surface — drive them through the `forge` CLI rather than imports.
|
|
68
97
|
|
|
69
98
|
## FORGE_SKILLS
|
|
70
99
|
|
|
71
|
-
|
|
100
|
+
`FORGE_SKILLS` is the discovered skill registry — one `ForgeSkillEntry` (name + parsed frontmatter) per `SKILL.md` under `skills/` (`FORGE_SKILLS.length` tracks the shipped count, currently 41).
|
|
72
101
|
|
|
73
102
|
```ts
|
|
74
103
|
import { FORGE_SKILLS } from "@warpgogol/forge";
|
package/os/core/core.module.ts
CHANGED
|
@@ -6,14 +6,24 @@
|
|
|
6
6
|
</non-goals>
|
|
7
7
|
</MODULE_CONTRACT>
|
|
8
8
|
<CHANGE_SUMMARY>
|
|
9
|
-
<item>RFC-1528: extract dry-run regen gate for AC-6 evidence
|
|
10
|
-
|
|
11
|
-
shouldRunArchiveRegen makes the report-only contract a tested unit instead of an inline closure check.</item>
|
|
12
|
-
<item>RFC-1528: close review findings — manifest-union command inventory for regen/preflight</item>
|
|
13
9
|
<item>RFC-1528: note moved[] under-count on archiver throw (review F-10)</item>
|
|
14
10
|
<item>RFC-1528: exclude non-generator commands from docs.archive owner regen (F-0126)</item>
|
|
15
11
|
<item>RFC-1536: owning-checkout routing, FLOW-OPEN-01 dirty-primary warning, shared governance-id allocation (RFC+ADR)</item>
|
|
16
12
|
<item>RFC-1535: docs.archive self-stages both sides of every move pair — no half-staged EC-31 pairs (F-0038)</item>
|
|
13
|
+
<item>RFC-1585: review wave — write-path corruptions, --check flag, scaffold hydration
|
|
14
|
+
|
|
15
|
+
Independent fo-review (isolation: subagent) found: empty marker pairs lost
|
|
16
|
+
their open tag on --write, multi-line regions collapsed line numbers, a
|
|
17
|
+
leading fence injected a phantom line, --check was undocumented-undeclared,
|
|
18
|
+
and --write exited 1 on a successful heal. Fixes: open-marker capture,
|
|
19
|
+
newline-preserving placeholder, empty-chunk skip, check flag, healedRegions
|
|
20
|
+
split (write always exits 0), dryRun/io threading, byte-exact inventory
|
|
21
|
+
compare on the prettier-stable canonical form, CHECK-13 delegated through
|
|
22
|
+
commandRegistry/invoke so the registry-integrity scan stays within its
|
|
23
|
+
slice cap (KNOWN_TRUNCATED_SCANS is shrink-only), record-tree exclusions
|
|
24
|
+
extended, two real stale claims corrected, profile templates ship empty
|
|
25
|
+
markers hydrated at scaffold write time. RFC amended to implemented
|
|
26
|
+
grammar/result/exclusions; command moved to commands.added.</item>
|
|
17
27
|
<history>ADR-0021, RFC-0374, RFC-0521, RFC-0539, RFC-0542, RFC-0543, RFC-0544, RFC-0546, RFC-0640, RFC-0662, RFC-0674, RFC-0678, RFC-0679, RFC-0680, RFC-0711, RFC-0733, RFC-0877, RFC-0940, RFC-1080, RFC-1088, RFC-1089, RFC-1097, RFC-1173, RFC-1230, RFC-1231, RFC-1235, RFC-1248, RFC-1251, RFC-1254, RFC-1255, RFC-1351, RFC-1354, RFC-1360, RFC-1366, RFC-1461, RFC-1500, RFC-1505, RFC-1508, RFC-1517, RFC-1518, RFC-1522, RFC-1528</history>
|
|
18
28
|
</CHANGE_SUMMARY>
|
|
19
29
|
*/
|
|
@@ -41,6 +51,7 @@ import { resolveOwningCheckout } from "../flow/session-checkout.ts";
|
|
|
41
51
|
export async function createForgeCoreModule(): Promise<ForgeModule> {
|
|
42
52
|
const { runScaffold } = await import("../../src/onboarding/scaffold.ts");
|
|
43
53
|
const { runSkillValidate } = await import("../../src/validators/skill-validate.ts");
|
|
54
|
+
const { runSkillDocSync } = await import("../../src/validators/skill-doc-sync.ts");
|
|
44
55
|
const { runPortValidate } = await import("../../src/validators/port-validate.ts");
|
|
45
56
|
const { runDoctor } = await import("../../src/onboarding/doctor.ts");
|
|
46
57
|
const { runAgentsGenerate } = await import("../../src/onboarding/agents-generate.ts");
|
|
@@ -121,6 +132,21 @@ export async function createForgeCoreModule(): Promise<ForgeModule> {
|
|
|
121
132
|
};
|
|
122
133
|
};
|
|
123
134
|
|
|
135
|
+
const skillDocSyncWrapper = async (
|
|
136
|
+
input: ForgeCommandInput,
|
|
137
|
+
context: ForgeRuntimeContext,
|
|
138
|
+
): Promise<ForgeCommandResult> => {
|
|
139
|
+
const result = await runSkillDocSync(input, context);
|
|
140
|
+
return {
|
|
141
|
+
data: result,
|
|
142
|
+
exitCode: result.status === "pass" ? 0 : 1,
|
|
143
|
+
summary:
|
|
144
|
+
result.status === "pass"
|
|
145
|
+
? `[forge.skill.doc-sync] OK — ${result.filesScanned} files, ${result.markedRegions} marked regions${result.written.length > 0 ? `, rewrote ${result.written.length}` : ""}${result.drift.length > 0 ? `, ${result.drift.length} unhealable claim drift entries` : ""}`
|
|
146
|
+
: `[forge.skill.doc-sync] ${result.drift.length} drift entries — re-render marked regions with --write; stale claim literals need manual fixes`,
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
|
|
124
150
|
const portValidateWrapper = async (
|
|
125
151
|
input: ForgeCommandInput,
|
|
126
152
|
context: ForgeRuntimeContext,
|
|
@@ -299,6 +325,39 @@ export async function createForgeCoreModule(): Promise<ForgeModule> {
|
|
|
299
325
|
reads: ["packages/forge/src/registry.ts"],
|
|
300
326
|
execute: skillListWrapper,
|
|
301
327
|
},
|
|
328
|
+
{
|
|
329
|
+
name: "forge.skill.doc-sync",
|
|
330
|
+
mutatesState: true,
|
|
331
|
+
contract: "forge",
|
|
332
|
+
rules: [],
|
|
333
|
+
description:
|
|
334
|
+
"Derive skill counts and inventory tables in docs from FORGE_SKILLS. --write re-renders <!-- forge:skills-* --> regions; default --check fails on marked-region drift and stale skill-count claims.",
|
|
335
|
+
scope: "workspace",
|
|
336
|
+
acceptsAllFlag: false,
|
|
337
|
+
flags: {
|
|
338
|
+
check: {
|
|
339
|
+
kind: "boolean",
|
|
340
|
+
description:
|
|
341
|
+
"Explicit check mode (the default): fail on marked-region drift and stale skill-count claims.",
|
|
342
|
+
},
|
|
343
|
+
write: {
|
|
344
|
+
kind: "boolean",
|
|
345
|
+
description:
|
|
346
|
+
"Re-render marked regions in place; exits 0 and reports claim drift it cannot heal.",
|
|
347
|
+
},
|
|
348
|
+
files: {
|
|
349
|
+
kind: "string",
|
|
350
|
+
description:
|
|
351
|
+
"Comma-separated doc paths (default: README*.md, AGENTS.md, docs/**/*.md minus record trees).",
|
|
352
|
+
},
|
|
353
|
+
root: { kind: "string", description: "Package root to scan (default: workspace root)." },
|
|
354
|
+
},
|
|
355
|
+
reads: ["README*.md", "AGENTS.md", "docs/**/*.md", "src/registry.ts"],
|
|
356
|
+
writes: ["README*.md", "AGENTS.md", "docs/**/*.md"],
|
|
357
|
+
generates: [],
|
|
358
|
+
cacheable: false,
|
|
359
|
+
execute: skillDocSyncWrapper,
|
|
360
|
+
},
|
|
302
361
|
{
|
|
303
362
|
name: "forge.port.validate",
|
|
304
363
|
coverage: "operator" as const,
|
|
@@ -1199,9 +1258,8 @@ export async function createForgeCoreModule(): Promise<ForgeModule> {
|
|
|
1199
1258
|
let regenSkipped: string[] = [];
|
|
1200
1259
|
let regenExcluded: Array<{ command: string; reason: string }> = [];
|
|
1201
1260
|
let regenFailures: Array<{ command: string; error: string }> = [];
|
|
1202
|
-
const { shouldRunArchiveRegen, runArchiveRegen, stageMovedPairs } =
|
|
1203
|
-
"./archive-regen.ts"
|
|
1204
|
-
);
|
|
1261
|
+
const { shouldRunArchiveRegen, runArchiveRegen, stageMovedPairs } =
|
|
1262
|
+
await import("./archive-regen.ts");
|
|
1205
1263
|
if (shouldRunArchiveRegen(dryRun, totalMoved)) {
|
|
1206
1264
|
const movedPaths = new Set<string>();
|
|
1207
1265
|
for (const data of Object.values(results)) {
|
|
@@ -1216,7 +1274,10 @@ export async function createForgeCoreModule(): Promise<ForgeModule> {
|
|
|
1216
1274
|
}
|
|
1217
1275
|
}
|
|
1218
1276
|
}
|
|
1219
|
-
const regen = await runArchiveRegen({
|
|
1277
|
+
const regen = await runArchiveRegen({
|
|
1278
|
+
movedPaths: [...movedPaths],
|
|
1279
|
+
context: routedContext,
|
|
1280
|
+
});
|
|
1220
1281
|
regenerated = regen.regenerated;
|
|
1221
1282
|
regenFailures = regen.failures;
|
|
1222
1283
|
regenSkipped = regen.skipped;
|
|
@@ -1274,9 +1335,7 @@ export async function createForgeCoreModule(): Promise<ForgeModule> {
|
|
|
1274
1335
|
} else if (staged.staged > 0) {
|
|
1275
1336
|
stagedMovePairs = staged.staged;
|
|
1276
1337
|
if (outputFormat === "pretty") {
|
|
1277
|
-
logger.info(
|
|
1278
|
-
` docs.archive: staged ${staged.staged} move path(s) (both sides)`,
|
|
1279
|
-
);
|
|
1338
|
+
logger.info(` docs.archive: staged ${staged.staged} move path(s) (both sides)`);
|
|
1280
1339
|
}
|
|
1281
1340
|
}
|
|
1282
1341
|
}
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
</non-goals>
|
|
7
7
|
</MODULE_CONTRACT>
|
|
8
8
|
<CHANGE_SUMMARY>
|
|
9
|
-
<item>RFC-1517: make pkg-health-10 shipped-set faithful and scan the publish ref</item>
|
|
10
9
|
<item>RFC-1518: docs-drift gate PKG-HEALTH-11/12 in forge.package.health
|
|
11
10
|
|
|
12
11
|
Live-inventory docs gate: PKG-HEALTH-11 flags registered commands absent
|
|
@@ -26,6 +25,20 @@ werkstatt-knowledge CLI surface.</item>
|
|
|
26
25
|
<item>ADR-0131: pkg-health-10 suppression on the line above the literal
|
|
27
26
|
|
|
28
27
|
literalEscapesInLine accepts a // pkg-health-10: comment directly above the literal (one-line reach); the publish at-ref scan fetches that line via git show only for candidate lines; bin/cli.ts drops its prettier-ignore lines.</item>
|
|
28
|
+
<item>RFC-1585: review wave — write-path corruptions, --check flag, scaffold hydration
|
|
29
|
+
|
|
30
|
+
Independent fo-review (isolation: subagent) found: empty marker pairs lost
|
|
31
|
+
their open tag on --write, multi-line regions collapsed line numbers, a
|
|
32
|
+
leading fence injected a phantom line, --check was undocumented-undeclared,
|
|
33
|
+
and --write exited 1 on a successful heal. Fixes: open-marker capture,
|
|
34
|
+
newline-preserving placeholder, empty-chunk skip, check flag, healedRegions
|
|
35
|
+
split (write always exits 0), dryRun/io threading, byte-exact inventory
|
|
36
|
+
compare on the prettier-stable canonical form, CHECK-13 delegated through
|
|
37
|
+
commandRegistry/invoke so the registry-integrity scan stays within its
|
|
38
|
+
slice cap (KNOWN_TRUNCATED_SCANS is shrink-only), record-tree exclusions
|
|
39
|
+
extended, two real stale claims corrected, profile templates ship empty
|
|
40
|
+
markers hydrated at scaffold write time. RFC amended to implemented
|
|
41
|
+
grammar/result/exclusions; command moved to commands.added.</item>
|
|
29
42
|
<history>RFC-1311, RFC-1517</history>
|
|
30
43
|
</CHANGE_SUMMARY>
|
|
31
44
|
*/
|
|
@@ -35,11 +48,7 @@ import { join } from "node:path";
|
|
|
35
48
|
import { writeFileSync, mkdirSync, rmSync } from "node:fs";
|
|
36
49
|
import { tmpdir } from "node:os";
|
|
37
50
|
import type { ForgeCommandInput, ForgeRuntimeContext } from "../../../src/types.ts";
|
|
38
|
-
import {
|
|
39
|
-
deriveShippedFiles,
|
|
40
|
-
runPackageHealth,
|
|
41
|
-
scanFixturePathEscapes,
|
|
42
|
-
} from "./package-health.ts";
|
|
51
|
+
import { deriveShippedFiles, runPackageHealth, scanFixturePathEscapes } from "./package-health.ts";
|
|
43
52
|
|
|
44
53
|
function makeContext(workspaceRoot: string): ForgeRuntimeContext {
|
|
45
54
|
return {
|
|
@@ -590,9 +599,7 @@ test("a ../ literal resolving inside the package root is not flagged (AC-4)", as
|
|
|
590
599
|
ok: true,
|
|
591
600
|
detail: "",
|
|
592
601
|
}));
|
|
593
|
-
expect(
|
|
594
|
-
result.data?.violations.filter((v) => v.ruleId === "PKG-HEALTH-10"),
|
|
595
|
-
).toHaveLength(0);
|
|
602
|
+
expect(result.data?.violations.filter((v) => v.ruleId === "PKG-HEALTH-10")).toHaveLength(0);
|
|
596
603
|
});
|
|
597
604
|
|
|
598
605
|
test("scanFixturePathEscapes honors suppression, raw-mode, and per-extension modes", () => {
|
|
@@ -674,21 +681,53 @@ test("handles no packages/ directory gracefully", async () => {
|
|
|
674
681
|
// RFC-1518: docs drift gate — PKG-HEALTH-11 coverage + PKG-HEALTH-12 dead refs
|
|
675
682
|
// ---------------------------------------------------------------------------
|
|
676
683
|
|
|
677
|
-
function makeRegistryContext(
|
|
684
|
+
function makeRegistryContext(
|
|
685
|
+
workspaceRoot: string,
|
|
686
|
+
commands: { name: string; module: string }[],
|
|
687
|
+
): ForgeRuntimeContext {
|
|
678
688
|
return {
|
|
679
689
|
...makeContext(workspaceRoot),
|
|
680
690
|
commandRegistry: {
|
|
681
691
|
listCommandNames: () => commands.map((c) => c.name),
|
|
682
|
-
listCommands: () =>
|
|
683
|
-
|
|
692
|
+
listCommands: () =>
|
|
693
|
+
commands.map((c) => ({
|
|
694
|
+
name: c.name,
|
|
695
|
+
module: c.module,
|
|
696
|
+
provider: "workspace" as const,
|
|
697
|
+
description: "",
|
|
698
|
+
scope: "workspace" as const,
|
|
699
|
+
})),
|
|
700
|
+
// RFC-1585: package.health delegates CHECK-13 through the registry —
|
|
701
|
+
// resolve the real sibling handler so the positive control exercises
|
|
702
|
+
// the same in-process execution path production does.
|
|
703
|
+
getCommand: (name) =>
|
|
704
|
+
name === "forge.skill.doc-sync"
|
|
705
|
+
? {
|
|
706
|
+
name,
|
|
707
|
+
description: "test stub — delegates to the real doc-sync runner",
|
|
708
|
+
scope: "workspace" as const,
|
|
709
|
+
execute: async (input, context) => {
|
|
710
|
+
const { runSkillDocSync } =
|
|
711
|
+
await import("../../../src/validators/skill-doc-sync.ts");
|
|
712
|
+
const r = await runSkillDocSync(input, context);
|
|
713
|
+
return { data: r, exitCode: r.status === "pass" ? 0 : 1 };
|
|
714
|
+
},
|
|
715
|
+
}
|
|
716
|
+
: undefined,
|
|
684
717
|
},
|
|
685
718
|
};
|
|
686
719
|
}
|
|
687
720
|
|
|
688
|
-
function seedDocsPkg(
|
|
721
|
+
function seedDocsPkg(
|
|
722
|
+
opts: { name?: string; docs?: Record<string, string>; readme?: string; agents?: string } = {},
|
|
723
|
+
) {
|
|
689
724
|
const pkgDir = join(tmpDir, "packages", "lib");
|
|
690
725
|
mkdirSync(join(pkgDir, "docs", "reference"), { recursive: true });
|
|
691
|
-
writePkgJson(pkgDir, {
|
|
726
|
+
writePkgJson(pkgDir, {
|
|
727
|
+
name: opts.name ?? "@warpgogol/lib",
|
|
728
|
+
version: "1.0.0",
|
|
729
|
+
engines: { node: ">=20" },
|
|
730
|
+
});
|
|
692
731
|
for (const [rel, content] of Object.entries(opts.docs ?? {})) {
|
|
693
732
|
const abs = join(pkgDir, "docs", rel);
|
|
694
733
|
mkdirSync(join(abs, ".."), { recursive: true });
|
|
@@ -722,7 +761,8 @@ test("PKG-HEALTH-11: a registered command absent from the docs surface errors na
|
|
|
722
761
|
test("PKG-HEALTH-12: a doc token resolving to no registered command errors at doc:line; versions and config paths stay silent (AC-3)", async () => {
|
|
723
762
|
seedDocsPkg({
|
|
724
763
|
docs: {
|
|
725
|
-
"guide.md":
|
|
764
|
+
"guide.md":
|
|
765
|
+
"# Guide\n\nRun `lib.retired` first, then check `9.1.0` and `extract.config.yaml`.\n",
|
|
726
766
|
},
|
|
727
767
|
});
|
|
728
768
|
const ctx = makeRegistryContext(tmpDir, [{ name: "lib.alpha", module: "lib-mod" }]);
|
|
@@ -757,7 +797,10 @@ test("pkg-health-11/pkg-health-12 markers skip the line and journal the suppress
|
|
|
757
797
|
|
|
758
798
|
test("excluded surfaces (CHANGELOG, generated, audit archive) are never scanned (AC-5)", async () => {
|
|
759
799
|
const pkgDir = seedDocsPkg({ docs: {} });
|
|
760
|
-
writeFileSync(
|
|
800
|
+
writeFileSync(
|
|
801
|
+
join(pkgDir, "CHANGELOG.md"),
|
|
802
|
+
"# Changes\n\n## [9.9.9]\n\n- mentions `lib.retired`\n",
|
|
803
|
+
);
|
|
761
804
|
mkdirSync(join(pkgDir, "docs", "audits", "archive"), { recursive: true });
|
|
762
805
|
writeFileSync(join(pkgDir, "docs", "audits", "archive", "old.md"), "`lib.retired` history\n");
|
|
763
806
|
writeFileSync(join(pkgDir, "docs", "status.generated.md"), "`lib.retired` generated\n");
|
|
@@ -767,6 +810,20 @@ test("excluded surfaces (CHANGELOG, generated, audit archive) are never scanned
|
|
|
767
810
|
expect(v12).toHaveLength(0);
|
|
768
811
|
});
|
|
769
812
|
|
|
813
|
+
test("PKG-HEALTH-13: a stale skill-count claim in package docs errors; correct claims pass (RFC-1585)", async () => {
|
|
814
|
+
seedDocsPkg({
|
|
815
|
+
docs: {
|
|
816
|
+
"reference/cli.md": "# CLI\n\n`lib.alpha` does a thing.\n\nForge ships 999 skills.\n",
|
|
817
|
+
},
|
|
818
|
+
});
|
|
819
|
+
const ctx = makeRegistryContext(tmpDir, [{ name: "lib.alpha", module: "lib-mod" }]);
|
|
820
|
+
const result = await runPackageHealth(makeInput(), ctx, () => ({ ok: true, detail: "" }));
|
|
821
|
+
const v13 = result.data?.violations.filter((v) => v.ruleId === "PKG-HEALTH-13") ?? [];
|
|
822
|
+
expect(v13).toHaveLength(1);
|
|
823
|
+
expect(v13[0]?.message).toContain("docs/reference/cli.md");
|
|
824
|
+
expect(v13[0]?.message).toContain("999 skills");
|
|
825
|
+
});
|
|
826
|
+
|
|
770
827
|
// r1 review fixes: manifest/registry merge, private-package semantics,
|
|
771
828
|
// unquoted module-map keys, suppression journal shape.
|
|
772
829
|
|
|
@@ -782,7 +839,14 @@ test("registry entry without module preserves manifest module provenance (r1)",
|
|
|
782
839
|
...makeContext(tmpDir),
|
|
783
840
|
commandRegistry: {
|
|
784
841
|
listCommandNames: () => ["lib.alpha"],
|
|
785
|
-
listCommands: () => [
|
|
842
|
+
listCommands: () => [
|
|
843
|
+
{
|
|
844
|
+
name: "lib.alpha",
|
|
845
|
+
provider: "workspace" as const,
|
|
846
|
+
description: "",
|
|
847
|
+
scope: "workspace" as const,
|
|
848
|
+
},
|
|
849
|
+
],
|
|
786
850
|
getCommand: () => undefined,
|
|
787
851
|
},
|
|
788
852
|
};
|
|
@@ -801,8 +865,14 @@ test("private package docs: PKG-HEALTH-12 still fires, PKG-HEALTH-11 stays silen
|
|
|
801
865
|
writeFileSync(join(pkgDir, "docs", "notes.md"), "run `lib.retired` first\n");
|
|
802
866
|
const ctx = makeRegistryContext(tmpDir, [{ name: "lib.alpha", module: "lib-mod" }]);
|
|
803
867
|
const result = await runPackageHealth(makeInput(), ctx, () => ({ ok: true, detail: "" }));
|
|
804
|
-
const v11 =
|
|
805
|
-
|
|
868
|
+
const v11 =
|
|
869
|
+
result.data?.violations.filter(
|
|
870
|
+
(v) => v.ruleId === "PKG-HEALTH-11" && v.packageName === "@warpgogol/priv",
|
|
871
|
+
) ?? [];
|
|
872
|
+
const v12 =
|
|
873
|
+
result.data?.violations.filter(
|
|
874
|
+
(v) => v.ruleId === "PKG-HEALTH-12" && v.packageName === "@warpgogol/priv",
|
|
875
|
+
) ?? [];
|
|
806
876
|
expect(v11).toHaveLength(0);
|
|
807
877
|
expect(v12).toHaveLength(1);
|
|
808
878
|
expect(v12[0]?.message).toContain("lib.retired");
|
|
@@ -822,7 +892,10 @@ test("unquoted module-map keys attribute modules to packages (r1)", async () =>
|
|
|
822
892
|
join(tmpDir, "docs", "command-manifest.generated.yaml"),
|
|
823
893
|
"commands:\n - name: lib.alpha\n module: lib-mod\n",
|
|
824
894
|
);
|
|
825
|
-
const result = await runPackageHealth(makeInput(), makeContext(tmpDir), () => ({
|
|
895
|
+
const result = await runPackageHealth(makeInput(), makeContext(tmpDir), () => ({
|
|
896
|
+
ok: true,
|
|
897
|
+
detail: "",
|
|
898
|
+
}));
|
|
826
899
|
const v11 = result.data?.violations.filter((v) => v.ruleId === "PKG-HEALTH-11") ?? [];
|
|
827
900
|
expect(v11).toHaveLength(1);
|
|
828
901
|
expect(v11[0]?.packageName).toBe("@warpgogol/lib");
|
|
@@ -865,10 +938,17 @@ test("siteScope commands resolve via the SITE map; workspace commands via WORKSH
|
|
|
865
938
|
join(tmpDir, "docs", "command-manifest.generated.yaml"),
|
|
866
939
|
"commands:\n - name: deploy.artifact.build\n module: deploy\n siteScope: false\n - name: client.export\n module: deploy\n siteScope: true\n",
|
|
867
940
|
);
|
|
868
|
-
const result = await runPackageHealth(makeInput(), makeContext(tmpDir), () => ({
|
|
941
|
+
const result = await runPackageHealth(makeInput(), makeContext(tmpDir), () => ({
|
|
942
|
+
ok: true,
|
|
943
|
+
detail: "",
|
|
944
|
+
}));
|
|
869
945
|
const v11 = result.data?.violations.filter((v) => v.ruleId === "PKG-HEALTH-11") ?? [];
|
|
870
946
|
// Workshop deploy.artifact.build attributes to @warpgogol/lib and is uncovered.
|
|
871
|
-
expect(
|
|
947
|
+
expect(
|
|
948
|
+
v11.some(
|
|
949
|
+
(v) => v.packageName === "@warpgogol/lib" && v.message.includes("deploy.artifact.build"),
|
|
950
|
+
),
|
|
951
|
+
).toBe(true);
|
|
872
952
|
// Site-scope client.export attributes to the private sitepkg — never to lib.
|
|
873
953
|
expect(v11.some((v) => v.message.includes("client.export"))).toBe(false);
|
|
874
954
|
});
|
|
@@ -936,7 +1016,8 @@ test("suppression journal sorts by package, file, line (r2)", async () => {
|
|
|
936
1016
|
seedDocsPkg({
|
|
937
1017
|
docs: {
|
|
938
1018
|
"b.md": "`lib.gone` <!-- pkg-health-12: removed -->\n",
|
|
939
|
-
"a.md":
|
|
1019
|
+
"a.md":
|
|
1020
|
+
"`lib.dead` <!-- pkg-health-12: removed -->\n`lib.dead2` <!-- pkg-health-12: removed -->\n",
|
|
940
1021
|
},
|
|
941
1022
|
});
|
|
942
1023
|
const ctx = makeRegistryContext(tmpDir, [{ name: "lib.alpha", module: "lib-mod" }]);
|