@warpgogol/forge 9.7.0 → 10.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 +50 -27
- package/CHANGELOG.md +52 -0
- package/bin/cli.js +0 -0
- package/dist/os/adr/handlers/archive.d.ts.map +1 -1
- package/dist/os/adr/handlers/archive.js +3 -7
- package/dist/os/adr/handlers/archive.js.map +1 -1
- package/dist/os/adr/handlers/list-create.d.ts.map +1 -1
- package/dist/os/adr/handlers/list-create.js +8 -6
- package/dist/os/adr/handlers/list-create.js.map +1 -1
- package/dist/os/audit/handlers/archive.d.ts.map +1 -1
- package/dist/os/audit/handlers/archive.js +3 -7
- package/dist/os/audit/handlers/archive.js.map +1 -1
- package/dist/os/codebase/handlers/codebase-measure-symbols.d.ts.map +1 -1
- package/dist/os/codebase/handlers/codebase-measure-symbols.js +35 -4
- package/dist/os/codebase/handlers/codebase-measure-symbols.js.map +1 -1
- package/dist/os/core/archive-regen.d.ts +1 -0
- package/dist/os/core/archive-regen.d.ts.map +1 -1
- package/dist/os/core/archive-regen.js +31 -6
- package/dist/os/core/archive-regen.js.map +1 -1
- package/dist/os/core/core.module.d.ts.map +1 -1
- package/dist/os/core/core.module.js +6 -69
- package/dist/os/core/core.module.js.map +1 -1
- package/dist/os/core/handlers/assets-helpers.d.ts.map +1 -1
- package/dist/os/core/handlers/assets-helpers.js +2 -3
- package/dist/os/core/handlers/assets-helpers.js.map +1 -1
- package/dist/os/core/handlers/determinism-check.d.ts.map +1 -1
- package/dist/os/core/handlers/determinism-check.js +2 -3
- package/dist/os/core/handlers/determinism-check.js.map +1 -1
- package/dist/os/core/handlers/pinned-check.d.ts +13 -0
- package/dist/os/core/handlers/pinned-check.d.ts.map +1 -1
- package/dist/os/core/handlers/pinned-check.js +25 -0
- package/dist/os/core/handlers/pinned-check.js.map +1 -1
- package/dist/os/core/handlers/pinned-types.d.ts +7 -0
- package/dist/os/core/handlers/pinned-types.d.ts.map +1 -1
- package/dist/os/core/handlers/pinned-validate.d.ts.map +1 -1
- package/dist/os/core/handlers/pinned-validate.js +24 -1
- package/dist/os/core/handlers/pinned-validate.js.map +1 -1
- package/dist/os/core/handlers/release-prepare.d.ts.map +1 -1
- package/dist/os/core/handlers/release-prepare.js +2 -4
- package/dist/os/core/handlers/release-prepare.js.map +1 -1
- package/dist/os/flow/digest.d.ts +73 -1
- package/dist/os/flow/digest.d.ts.map +1 -1
- package/dist/os/flow/digest.js +344 -92
- package/dist/os/flow/digest.js.map +1 -1
- package/dist/os/flow/evidence-lock.d.ts +36 -0
- package/dist/os/flow/evidence-lock.d.ts.map +1 -0
- package/dist/os/flow/evidence-lock.js +156 -0
- package/dist/os/flow/evidence-lock.js.map +1 -0
- package/dist/os/flow/flow.module.d.ts.map +1 -1
- package/dist/os/flow/flow.module.js +36 -14
- package/dist/os/flow/flow.module.js.map +1 -1
- package/dist/os/flow/git.d.ts +50 -3
- package/dist/os/flow/git.d.ts.map +1 -1
- package/dist/os/flow/git.js +144 -12
- package/dist/os/flow/git.js.map +1 -1
- package/dist/os/flow/handlers/flow-digest.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-digest.js +3 -5
- package/dist/os/flow/handlers/flow-digest.js.map +1 -1
- package/dist/os/flow/handlers/flow-peers.js +1 -1
- package/dist/os/flow/handlers/flow-peers.js.map +1 -1
- package/dist/os/flow/handlers/flow-push.d.ts +81 -0
- package/dist/os/flow/handlers/flow-push.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-push.js +642 -138
- package/dist/os/flow/handlers/flow-push.js.map +1 -1
- package/dist/os/flow/locks.d.ts +8 -0
- package/dist/os/flow/locks.d.ts.map +1 -1
- package/dist/os/flow/locks.js +6 -3
- package/dist/os/flow/locks.js.map +1 -1
- package/dist/os/{mission → flow}/open-missions.d.ts +1 -2
- package/dist/os/flow/open-missions.d.ts.map +1 -0
- package/dist/os/flow/open-missions.js +37 -0
- package/dist/os/flow/open-missions.js.map +1 -0
- package/dist/os/flow/preflight.d.ts.map +1 -1
- package/dist/os/flow/preflight.js +5 -3
- package/dist/os/flow/preflight.js.map +1 -1
- package/dist/os/flow/registry.d.ts +9 -5
- package/dist/os/flow/registry.d.ts.map +1 -1
- package/dist/os/flow/registry.js +2 -2
- package/dist/os/flow/registry.js.map +1 -1
- package/dist/os/friction/friction.module.d.ts.map +1 -1
- package/dist/os/friction/friction.module.js +30 -5
- package/dist/os/friction/friction.module.js.map +1 -1
- package/dist/os/friction/handlers/friction-add.d.ts.map +1 -1
- package/dist/os/friction/handlers/friction-add.js +10 -17
- package/dist/os/friction/handlers/friction-add.js.map +1 -1
- package/dist/os/friction/handlers/friction-migrate.d.ts.map +1 -1
- package/dist/os/friction/handlers/friction-migrate.js +188 -2
- package/dist/os/friction/handlers/friction-migrate.js.map +1 -1
- package/dist/os/friction/store.d.ts +4 -0
- package/dist/os/friction/store.d.ts.map +1 -1
- package/dist/os/friction/store.js +20 -0
- package/dist/os/friction/store.js.map +1 -1
- package/dist/os/friction/types.d.ts +12 -0
- package/dist/os/friction/types.d.ts.map +1 -1
- package/dist/os/friction/types.js +8 -0
- package/dist/os/friction/types.js.map +1 -1
- package/dist/os/gate/handlers/gate-probe-catalog.d.ts.map +1 -1
- package/dist/os/gate/handlers/gate-probe-catalog.js +38 -5
- package/dist/os/gate/handlers/gate-probe-catalog.js.map +1 -1
- package/dist/os/plan/handlers/archive.d.ts.map +1 -1
- package/dist/os/plan/handlers/archive.js +3 -7
- package/dist/os/plan/handlers/archive.js.map +1 -1
- package/dist/os/rfc/handlers/archive.d.ts.map +1 -1
- package/dist/os/rfc/handlers/archive.js +3 -7
- package/dist/os/rfc/handlers/archive.js.map +1 -1
- package/dist/os/rfc/handlers/list-create.d.ts.map +1 -1
- package/dist/os/rfc/handlers/list-create.js +15 -7
- package/dist/os/rfc/handlers/list-create.js.map +1 -1
- package/dist/os/session/handlers/archive.d.ts.map +1 -1
- package/dist/os/session/handlers/archive.js +3 -7
- package/dist/os/session/handlers/archive.js.map +1 -1
- package/dist/os/system/handlers/system-product-register.d.ts +24 -0
- package/dist/os/system/handlers/system-product-register.d.ts.map +1 -0
- package/dist/os/system/handlers/system-product-register.js +322 -0
- package/dist/os/system/handlers/system-product-register.js.map +1 -0
- package/dist/os/system/handlers/system-products-status.d.ts +23 -0
- package/dist/os/system/handlers/system-products-status.d.ts.map +1 -0
- package/dist/os/system/handlers/system-products-status.js +235 -0
- package/dist/os/system/handlers/system-products-status.js.map +1 -0
- package/dist/os/system/schemas.d.ts +13 -0
- package/dist/os/system/schemas.d.ts.map +1 -1
- package/dist/os/system/schemas.js +15 -0
- package/dist/os/system/schemas.js.map +1 -1
- package/dist/os/system/system.module.d.ts.map +1 -1
- package/dist/os/system/system.module.js +113 -3
- package/dist/os/system/system.module.js.map +1 -1
- package/dist/src/command-modules.d.ts.map +1 -1
- package/dist/src/command-modules.js +0 -2
- package/dist/src/command-modules.js.map +1 -1
- package/dist/src/config/forge-config.d.ts +2 -0
- package/dist/src/config/forge-config.d.ts.map +1 -1
- package/dist/src/config/forge-config.js +11 -10
- package/dist/src/config/forge-config.js.map +1 -1
- package/dist/src/index.d.ts +0 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +0 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/onboarding/create.d.ts.map +1 -1
- package/dist/src/onboarding/create.js +27 -2
- package/dist/src/onboarding/create.js.map +1 -1
- package/dist/src/onboarding/doctor.d.ts +0 -5
- package/dist/src/onboarding/doctor.d.ts.map +1 -1
- package/dist/src/onboarding/doctor.js +6 -79
- package/dist/src/onboarding/doctor.js.map +1 -1
- package/dist/src/onboarding/npm-token-check.d.ts +1 -1
- package/dist/src/onboarding/npm-token-check.d.ts.map +1 -1
- package/dist/src/onboarding/npm-token-check.js +2 -2
- package/dist/src/onboarding/npm-token-check.js.map +1 -1
- package/dist/src/profiles/stack-profile.js +2 -2
- package/dist/src/types.js +2 -2
- package/dist/src/utils/hash.d.ts +1 -0
- package/dist/src/utils/hash.d.ts.map +1 -1
- package/dist/src/utils/hash.js +4 -0
- package/dist/src/utils/hash.js.map +1 -1
- package/dist/{os/mission → src/utils}/lockfile.d.ts +1 -18
- package/dist/src/utils/lockfile.d.ts.map +1 -0
- package/dist/src/utils/lockfile.js +70 -0
- package/dist/src/utils/lockfile.js.map +1 -0
- package/dist/src/utils/verifier-git.d.ts +27 -1
- package/dist/src/utils/verifier-git.d.ts.map +1 -1
- package/dist/src/utils/verifier-git.js +36 -6
- package/dist/src/utils/verifier-git.js.map +1 -1
- package/docs/reference/system-hub.md +104 -0
- package/os/adr/handlers/archive.ts +3 -11
- package/os/adr/handlers/list-create.test.ts +174 -0
- package/os/adr/handlers/list-create.ts +16 -8
- package/os/audit/handlers/archive.ts +3 -11
- package/os/codebase/handlers/codebase-measure-symbols.ts +32 -4
- package/os/core/archive-regen.ts +33 -7
- package/os/core/core.module.ts +10 -76
- package/os/core/docs-archive.test.ts +25 -0
- package/os/core/handlers/assets-helpers.ts +2 -4
- package/os/core/handlers/determinism-check.ts +2 -3
- package/os/core/handlers/lifecycle-handlers.test.ts +529 -0
- package/os/core/handlers/pinned-check.ts +30 -0
- package/os/core/handlers/pinned-types.ts +7 -0
- package/os/core/handlers/pinned-validate.ts +28 -3
- package/os/core/handlers/release-prepare.ts +2 -4
- package/os/correctness/gate/trust-boundary-cx18.test.ts +1 -1
- package/os/flow/digest.ts +436 -95
- package/os/flow/evidence-lock.ts +184 -0
- package/os/flow/flow.module.ts +37 -14
- package/os/flow/git.ts +206 -11
- package/os/flow/handlers/flow-digest.ts +12 -8
- package/os/flow/handlers/flow-peers.ts +1 -1
- package/os/flow/handlers/flow-push.ts +725 -137
- package/os/flow/locks.ts +24 -7
- package/os/flow/open-missions.ts +45 -0
- package/os/flow/preflight.ts +5 -3
- package/os/flow/registry.ts +7 -3
- package/os/flow/tests/digest-id-inputs.test.ts +106 -0
- package/os/flow/tests/digest-persist.test.ts +243 -0
- package/os/flow/tests/evidence-preflight-surface-skip.test.ts +218 -0
- package/os/flow/tests/flow-push-attest.test.ts +137 -0
- package/os/flow/tests/flow-push-review-baseline.test.ts +339 -0
- package/os/flow/tests/flow-push-verifier-batch.test.ts +134 -0
- package/os/flow/tests/release-lines.test.ts +136 -0
- package/os/flow/tests/state-roots.test.ts +1 -48
- package/os/friction/friction-add.test.ts +42 -0
- package/os/friction/friction-migrate.test.ts +67 -2
- package/os/friction/friction.module.ts +33 -5
- package/os/friction/handlers/friction-add.ts +10 -15
- package/os/friction/handlers/friction-migrate.ts +220 -1
- package/os/friction/store.ts +19 -0
- package/os/friction/types.ts +8 -0
- package/os/gate/handlers/gate-probe-catalog.ts +39 -7
- package/os/gate/handlers/gate-probe-ratchet.test.ts +57 -22
- package/os/plan/handlers/archive.ts +3 -11
- package/os/rfc/handlers/archive.ts +3 -11
- package/os/rfc/handlers/list-create.ts +22 -17
- package/os/rfc/handlers/validate-corpus.test.ts +149 -0
- package/os/rfc/probe-batch.test.ts +253 -0
- package/os/rfc/verifier/rfc-1391/ac10-operating-model-policy.acceptance.test.ts +63 -0
- package/os/session/handlers/archive.ts +3 -11
- package/os/system/handlers/system-product-register.ts +492 -0
- package/os/system/handlers/system-products-status.ts +395 -0
- package/os/system/schemas.ts +17 -0
- package/os/system/system.module.ts +117 -3
- package/os/system/tests/system-product-register.test.ts +304 -0
- package/os/system/tests/system-products-status.test.ts +154 -0
- package/package.json +161 -506
- package/profiles/root-agents-system.md +82 -0
- package/profiles/system.yaml +1 -0
- package/src/command-modules.ts +0 -2
- package/src/config/forge-config.ts +16 -11
- package/src/index.ts +0 -2
- package/src/onboarding/create-superfolder-guard.test.ts +73 -0
- package/src/onboarding/create.ts +28 -2
- package/src/onboarding/doctor.ts +9 -96
- package/src/onboarding/npm-token-check.ts +3 -3
- package/src/profiles/stack-profile.ts +2 -2
- package/src/tests/evidence-consult-serialization.test.ts +202 -0
- package/src/tests/pinned-validate.test.ts +194 -0
- package/src/tests/pkg-health-self-scan.test.ts +29 -0
- package/src/tests/profile-flow-hooks.test.ts +1 -0
- package/src/tests/profile-schema.test.ts +1 -0
- package/src/tests/rfc-evidence-sync.test.ts +369 -0
- package/src/tests/skill-agents-sync.test.ts +192 -0
- package/src/tests/stack-profile.test.ts +1 -0
- package/src/types.ts +2 -2
- package/src/utils/hash.ts +5 -0
- package/src/utils/lockfile.ts +78 -0
- package/src/utils/verifier-git.ts +53 -5
- package/dist/os/core/handlers/forge-autonomy-validate.d.ts +0 -25
- package/dist/os/core/handlers/forge-autonomy-validate.d.ts.map +0 -1
- package/dist/os/core/handlers/forge-autonomy-validate.js +0 -208
- package/dist/os/core/handlers/forge-autonomy-validate.js.map +0 -1
- package/dist/os/mission/handlers/archive.d.ts +0 -4
- package/dist/os/mission/handlers/archive.d.ts.map +0 -1
- package/dist/os/mission/handlers/archive.js +0 -587
- package/dist/os/mission/handlers/archive.js.map +0 -1
- package/dist/os/mission/importer-block.d.ts +0 -19
- package/dist/os/mission/importer-block.d.ts.map +0 -1
- package/dist/os/mission/importer-block.js +0 -124
- package/dist/os/mission/importer-block.js.map +0 -1
- package/dist/os/mission/index.d.ts +0 -2
- package/dist/os/mission/index.d.ts.map +0 -1
- package/dist/os/mission/index.js +0 -15
- package/dist/os/mission/index.js.map +0 -1
- package/dist/os/mission/lockfile.d.ts.map +0 -1
- package/dist/os/mission/lockfile.js +0 -138
- package/dist/os/mission/lockfile.js.map +0 -1
- package/dist/os/mission/mission.module.d.ts +0 -3
- package/dist/os/mission/mission.module.d.ts.map +0 -1
- package/dist/os/mission/mission.module.js +0 -63
- package/dist/os/mission/mission.module.js.map +0 -1
- package/dist/os/mission/open-missions.d.ts.map +0 -1
- package/dist/os/mission/open-missions.js +0 -42
- package/dist/os/mission/open-missions.js.map +0 -1
- package/dist/os/mission/types.d.ts +0 -23
- package/dist/os/mission/types.d.ts.map +0 -1
- package/dist/os/mission/types.js +0 -19
- package/dist/os/mission/types.js.map +0 -1
- package/dist/os/werkstatt/handlers/lock.d.ts +0 -10
- package/dist/os/werkstatt/handlers/lock.d.ts.map +0 -1
- package/dist/os/werkstatt/handlers/lock.js +0 -153
- package/dist/os/werkstatt/handlers/lock.js.map +0 -1
- package/dist/os/werkstatt/handlers/schema.d.ts +0 -33
- package/dist/os/werkstatt/handlers/schema.d.ts.map +0 -1
- package/dist/os/werkstatt/handlers/schema.js +0 -42
- package/dist/os/werkstatt/handlers/schema.js.map +0 -1
- package/dist/os/werkstatt/handlers/werkstatt-lock-recover.d.ts +0 -15
- package/dist/os/werkstatt/handlers/werkstatt-lock-recover.d.ts.map +0 -1
- package/dist/os/werkstatt/handlers/werkstatt-lock-recover.js +0 -171
- package/dist/os/werkstatt/handlers/werkstatt-lock-recover.js.map +0 -1
- package/dist/os/werkstatt/handlers/werkstatt-lock-status.d.ts +0 -18
- package/dist/os/werkstatt/handlers/werkstatt-lock-status.d.ts.map +0 -1
- package/dist/os/werkstatt/handlers/werkstatt-lock-status.js +0 -51
- package/dist/os/werkstatt/handlers/werkstatt-lock-status.js.map +0 -1
- package/dist/os/werkstatt/handlers/werkstatt-operation-validate.d.ts +0 -11
- package/dist/os/werkstatt/handlers/werkstatt-operation-validate.d.ts.map +0 -1
- package/dist/os/werkstatt/handlers/werkstatt-operation-validate.js +0 -86
- package/dist/os/werkstatt/handlers/werkstatt-operation-validate.js.map +0 -1
- package/dist/os/werkstatt/handlers/workspace-deps.d.ts +0 -12
- package/dist/os/werkstatt/handlers/workspace-deps.d.ts.map +0 -1
- package/dist/os/werkstatt/handlers/workspace-deps.js +0 -42
- package/dist/os/werkstatt/handlers/workspace-deps.js.map +0 -1
- package/dist/os/werkstatt/index.d.ts +0 -7
- package/dist/os/werkstatt/index.d.ts.map +0 -1
- package/dist/os/werkstatt/index.js +0 -18
- package/dist/os/werkstatt/index.js.map +0 -1
- package/dist/os/werkstatt/werkstatt.module.d.ts +0 -3
- package/dist/os/werkstatt/werkstatt.module.d.ts.map +0 -1
- package/dist/os/werkstatt/werkstatt.module.js +0 -91
- package/dist/os/werkstatt/werkstatt.module.js.map +0 -1
- package/os/core/handlers/forge-autonomy-validate.ts +0 -276
- package/os/correctness/gate/trust-boundary-cx19.test.ts +0 -514
- package/os/mission/handlers/archive.test.ts +0 -764
- package/os/mission/handlers/archive.ts +0 -719
- package/os/mission/handlers/ship-inflight-degraded.test.ts +0 -105
- package/os/mission/importer-block.ts +0 -119
- package/os/mission/index.ts +0 -15
- package/os/mission/lockfile.ts +0 -152
- package/os/mission/mission.module.ts +0 -68
- package/os/mission/open-missions.ts +0 -50
- package/os/mission/types.ts +0 -42
- package/os/werkstatt/handlers/lock.ts +0 -168
- package/os/werkstatt/handlers/schema.ts +0 -47
- package/os/werkstatt/handlers/werkstatt-lock-recover.ts +0 -206
- package/os/werkstatt/handlers/werkstatt-lock-status.ts +0 -82
- package/os/werkstatt/handlers/werkstatt-operation-validate.ts +0 -112
- package/os/werkstatt/handlers/workspace-deps.ts +0 -56
- package/os/werkstatt/index.ts +0 -39
- package/os/werkstatt/werkstatt.module.ts +0 -95
- package/src/tests/doctor-autonomy.test.ts +0 -246
- package/src/tests/forge-autonomy-validate.test.ts +0 -159
- package/src/tests/werkstatt-lock.test.ts +0 -357
|
@@ -0,0 +1,492 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>system.product.register command handler (RFC-1641) — the roster
|
|
4
|
+
write surface for a system hub. The explicit form records one product
|
|
5
|
+
(--id --remote [--folder] [--offers]* [--frozen] [--update]); --discover
|
|
6
|
+
scans the hub's parent directory for forge-governed siblings and registers
|
|
7
|
+
every unregistered one. Writes system/products.yaml and the gitignored
|
|
8
|
+
system/products.local.yaml — the session commits. Errors refuse before any
|
|
9
|
+
write; warnings never fail the run.</purpose>
|
|
10
|
+
<non-goals>
|
|
11
|
+
<item>No removal or reordering — products.yaml stays hand-editable for rare operations.</item>
|
|
12
|
+
<item>No edge-matrix authoring — system/edges.yaml is curated contract policy.</item>
|
|
13
|
+
<item>No validation beyond what registration needs — system.map.validate owns SYSTEM-MAP-02..05.</item>
|
|
14
|
+
</non-goals>
|
|
15
|
+
</MODULE_CONTRACT>
|
|
16
|
+
<CHANGE_SUMMARY>
|
|
17
|
+
<item>RFC-1641: system.product.register — roster write surface with --discover sibling scan</item>
|
|
18
|
+
<item>RFC-1641: step 1 — system.product.register handler + tests</item>
|
|
19
|
+
</CHANGE_SUMMARY>
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import path from "node:path";
|
|
23
|
+
|
|
24
|
+
import YAML from "yaml";
|
|
25
|
+
|
|
26
|
+
import { resolveIo } from "../../../src/utils/io.ts";
|
|
27
|
+
import type {
|
|
28
|
+
Diagnostic,
|
|
29
|
+
ForgeCommandInput,
|
|
30
|
+
ForgeCommandResult,
|
|
31
|
+
ForgeRuntimeContext,
|
|
32
|
+
WorkspaceIO,
|
|
33
|
+
} from "../../../src/types.ts";
|
|
34
|
+
import { git } from "../../flow/git.ts";
|
|
35
|
+
import {
|
|
36
|
+
assertSystemRepository,
|
|
37
|
+
FORGE_CONFIG_FILE,
|
|
38
|
+
loadSystemMap,
|
|
39
|
+
SYSTEM_LOCAL_FILE,
|
|
40
|
+
SYSTEM_PRODUCTS_FILE,
|
|
41
|
+
} from "../repo.ts";
|
|
42
|
+
import type { SystemMap } from "../repo.ts";
|
|
43
|
+
import {
|
|
44
|
+
SYSTEM_ID_PATTERN,
|
|
45
|
+
type SystemProduct,
|
|
46
|
+
type SystemProductsLocal,
|
|
47
|
+
} from "../schemas.ts";
|
|
48
|
+
|
|
49
|
+
interface RegisteredEntry {
|
|
50
|
+
id: string;
|
|
51
|
+
folder: string | null;
|
|
52
|
+
updated: boolean;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
interface SkippedEntry {
|
|
56
|
+
name: string;
|
|
57
|
+
reason: string;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface SystemProductRegisterResult {
|
|
61
|
+
command: "system.product.register";
|
|
62
|
+
status: "ok" | "warn" | "fail";
|
|
63
|
+
mode: "explicit" | "discover";
|
|
64
|
+
dryRun: boolean;
|
|
65
|
+
registered: RegisteredEntry[];
|
|
66
|
+
skipped: SkippedEntry[];
|
|
67
|
+
written: string[];
|
|
68
|
+
warnings: Diagnostic[];
|
|
69
|
+
errors: Diagnostic[];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function flagString(input: ForgeCommandInput, name: string): string | null {
|
|
73
|
+
const v = input.flags[name];
|
|
74
|
+
return typeof v === "string" && v.length > 0 ? v : null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function flagList(input: ForgeCommandInput, name: string): string[] {
|
|
78
|
+
const v = input.flags[name];
|
|
79
|
+
return Array.isArray(v) ? v.filter((x): x is string => typeof x === "string") : [];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function flagBool(input: ForgeCommandInput, name: string): boolean {
|
|
83
|
+
return input.flags[name] === true;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function errDiag(file: string, message: string, fixHint: string): Diagnostic {
|
|
87
|
+
return { ruleId: "SYSTEM-PRODUCTS-03", severity: "error", file, message, fixHint };
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function warnDiag(file: string, message: string, fixHint: string): Diagnostic {
|
|
91
|
+
return { ruleId: "SYSTEM-PRODUCTS-04", severity: "warning", file, message, fixHint };
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async function dirExists(io: WorkspaceIO, abs: string): Promise<boolean> {
|
|
95
|
+
try {
|
|
96
|
+
return (await io.stat(abs)).isDirectory;
|
|
97
|
+
} catch {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** Serialize the products registry — schema order, `ignored[]` preserved. */
|
|
103
|
+
function serializeProducts(products: SystemMap["products"]): string {
|
|
104
|
+
const body: Record<string, unknown> = {
|
|
105
|
+
schema: "forge/system-products@1",
|
|
106
|
+
products: products.products.map((p) => ({
|
|
107
|
+
id: p.id,
|
|
108
|
+
remote: p.remote,
|
|
109
|
+
offers: p.offers,
|
|
110
|
+
...(p.frozen === true ? { frozen: true } : {}),
|
|
111
|
+
})),
|
|
112
|
+
};
|
|
113
|
+
if (products.ignored !== undefined && products.ignored.length > 0) {
|
|
114
|
+
body.ignored = products.ignored.map((i) => ({
|
|
115
|
+
id: i.id,
|
|
116
|
+
...(i.note !== undefined ? { note: i.note } : {}),
|
|
117
|
+
}));
|
|
118
|
+
}
|
|
119
|
+
return YAML.stringify(body);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function serializeLocal(local: SystemProductsLocal): string {
|
|
123
|
+
const body: Record<string, unknown> = {
|
|
124
|
+
schema: "forge/system-products-local@1",
|
|
125
|
+
folders: local.folders,
|
|
126
|
+
};
|
|
127
|
+
if (local.launcher !== undefined) body.launcher = local.launcher;
|
|
128
|
+
return YAML.stringify(body);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** Resolve a --folder value to an absolute path for the existence check. */
|
|
132
|
+
function resolveFolder(root: string, folder: string): string {
|
|
133
|
+
return path.isAbsolute(folder) ? folder : path.join(root, folder);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export async function runSystemProductRegister(
|
|
137
|
+
input: ForgeCommandInput,
|
|
138
|
+
context: ForgeRuntimeContext,
|
|
139
|
+
): Promise<ForgeCommandResult<SystemProductRegisterResult>> {
|
|
140
|
+
const io = resolveIo(context.io);
|
|
141
|
+
const root = context.workspaceRoot;
|
|
142
|
+
const dryRun = context.dryRun || flagBool(input, "dry-run");
|
|
143
|
+
const warnings: Diagnostic[] = [];
|
|
144
|
+
const errors: Diagnostic[] = [];
|
|
145
|
+
const registered: RegisteredEntry[] = [];
|
|
146
|
+
const skipped: SkippedEntry[] = [];
|
|
147
|
+
const written: string[] = [];
|
|
148
|
+
|
|
149
|
+
const refusal = await assertSystemRepository(root, io);
|
|
150
|
+
if (refusal) {
|
|
151
|
+
errors.push(refusal);
|
|
152
|
+
return finish("explicit", dryRun, registered, skipped, written, warnings, errors, context);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const loaded = await loadSystemMap(root, io);
|
|
156
|
+
for (const d of loaded.diagnostics) {
|
|
157
|
+
(d.severity === "error" ? errors : warnings).push(d);
|
|
158
|
+
}
|
|
159
|
+
const map = loaded.map;
|
|
160
|
+
if (map === null) {
|
|
161
|
+
return finish("explicit", dryRun, registered, skipped, written, warnings, errors, context);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const discover = flagBool(input, "discover");
|
|
165
|
+
const id = flagString(input, "id");
|
|
166
|
+
if (!discover && id === null) {
|
|
167
|
+
errors.push(
|
|
168
|
+
errDiag(
|
|
169
|
+
SYSTEM_PRODUCTS_FILE,
|
|
170
|
+
"system.product.register needs --id <product> or --discover",
|
|
171
|
+
"Pass --id <kebab-id> --remote <url> to register one product, or --discover to scan siblings.",
|
|
172
|
+
),
|
|
173
|
+
);
|
|
174
|
+
return finish("explicit", dryRun, registered, skipped, written, warnings, errors, context);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// Mutation state — applied to a copy; files write once at the end.
|
|
178
|
+
const products: SystemProduct[] = map.products.products.map((p) => ({ ...p }));
|
|
179
|
+
const folders: Record<string, string> = { ...(map.local?.folders ?? {}) };
|
|
180
|
+
let productsDirty = false;
|
|
181
|
+
let localDirty = false;
|
|
182
|
+
|
|
183
|
+
if (discover) {
|
|
184
|
+
const outcome = await runDiscover(map, root, products, folders, registered, skipped, io);
|
|
185
|
+
productsDirty = outcome.productsDirty;
|
|
186
|
+
localDirty = outcome.localDirty;
|
|
187
|
+
warnings.push(...outcome.warnings);
|
|
188
|
+
errors.push(...outcome.errors);
|
|
189
|
+
} else {
|
|
190
|
+
const outcome = await runExplicit(input, map, root, products, folders, registered, skipped, io);
|
|
191
|
+
productsDirty = outcome.productsDirty;
|
|
192
|
+
localDirty = outcome.localDirty;
|
|
193
|
+
warnings.push(...outcome.warnings);
|
|
194
|
+
errors.push(...outcome.errors);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if (errors.length === 0 && !dryRun) {
|
|
198
|
+
if (productsDirty) {
|
|
199
|
+
await io.writeFile(
|
|
200
|
+
path.join(root, SYSTEM_PRODUCTS_FILE),
|
|
201
|
+
serializeProducts({ ...map.products, products }),
|
|
202
|
+
);
|
|
203
|
+
written.push(SYSTEM_PRODUCTS_FILE);
|
|
204
|
+
}
|
|
205
|
+
if (localDirty) {
|
|
206
|
+
const local: SystemProductsLocal = {
|
|
207
|
+
schema: "forge/system-products-local@1",
|
|
208
|
+
folders,
|
|
209
|
+
...(map.local?.launcher !== undefined ? { launcher: map.local.launcher } : {}),
|
|
210
|
+
};
|
|
211
|
+
await io.mkdir(path.join(root, "system"));
|
|
212
|
+
await io.writeFile(path.join(root, SYSTEM_LOCAL_FILE), serializeLocal(local));
|
|
213
|
+
written.push(SYSTEM_LOCAL_FILE);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
if (dryRun && (productsDirty || localDirty)) {
|
|
217
|
+
written.push(
|
|
218
|
+
...(productsDirty ? [SYSTEM_PRODUCTS_FILE] : []),
|
|
219
|
+
...(localDirty ? [SYSTEM_LOCAL_FILE] : []),
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
return finish(
|
|
224
|
+
discover ? "discover" : "explicit",
|
|
225
|
+
dryRun,
|
|
226
|
+
registered,
|
|
227
|
+
skipped,
|
|
228
|
+
written,
|
|
229
|
+
warnings,
|
|
230
|
+
errors,
|
|
231
|
+
context,
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
interface PathOutcome {
|
|
236
|
+
productsDirty: boolean;
|
|
237
|
+
localDirty: boolean;
|
|
238
|
+
warnings: Diagnostic[];
|
|
239
|
+
errors: Diagnostic[];
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/** Explicit `--id` registration (insert or --update). */
|
|
243
|
+
async function runExplicit(
|
|
244
|
+
input: ForgeCommandInput,
|
|
245
|
+
map: SystemMap,
|
|
246
|
+
root: string,
|
|
247
|
+
products: SystemProduct[],
|
|
248
|
+
folders: Record<string, string>,
|
|
249
|
+
registered: RegisteredEntry[],
|
|
250
|
+
skipped: SkippedEntry[],
|
|
251
|
+
io: WorkspaceIO,
|
|
252
|
+
): Promise<PathOutcome> {
|
|
253
|
+
const warnings: Diagnostic[] = [];
|
|
254
|
+
const errors: Diagnostic[] = [];
|
|
255
|
+
const id = flagString(input, "id")!;
|
|
256
|
+
const remote = flagString(input, "remote");
|
|
257
|
+
const folder = flagString(input, "folder");
|
|
258
|
+
const offers = flagList(input, "offers");
|
|
259
|
+
const frozen = flagBool(input, "frozen");
|
|
260
|
+
const update = flagBool(input, "update");
|
|
261
|
+
|
|
262
|
+
if (!SYSTEM_ID_PATTERN.test(id)) {
|
|
263
|
+
errors.push(
|
|
264
|
+
errDiag(
|
|
265
|
+
SYSTEM_PRODUCTS_FILE,
|
|
266
|
+
`product id "${id}" is not kebab-case`,
|
|
267
|
+
"Product ids match ^[a-z0-9]+(-[a-z0-9]+)*$ — pick a conforming id.",
|
|
268
|
+
),
|
|
269
|
+
);
|
|
270
|
+
return { productsDirty: false, localDirty: false, warnings, errors };
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
const existing = products.find((p) => p.id === id);
|
|
274
|
+
if (existing !== undefined && !update) {
|
|
275
|
+
// Rerun-safe: an identical re-registration reports a skip, not an error.
|
|
276
|
+
const sameRemote = remote === null || existing.remote === remote;
|
|
277
|
+
const sameOffers = offers.length === 0 || sameSet(existing.offers, offers);
|
|
278
|
+
const sameFrozen = !frozen || existing.frozen === true;
|
|
279
|
+
if (sameRemote && sameOffers && sameFrozen && (folder === null || folders[id] === folder)) {
|
|
280
|
+
skipped.push({ name: id, reason: "already-registered" });
|
|
281
|
+
return { productsDirty: false, localDirty: false, warnings, errors };
|
|
282
|
+
}
|
|
283
|
+
errors.push(
|
|
284
|
+
errDiag(
|
|
285
|
+
SYSTEM_PRODUCTS_FILE,
|
|
286
|
+
`product "${id}" is already registered — re-run with --update to modify it`,
|
|
287
|
+
`Edit ${SYSTEM_PRODUCTS_FILE} by hand or pass --update with the new field values.`,
|
|
288
|
+
),
|
|
289
|
+
);
|
|
290
|
+
return { productsDirty: false, localDirty: false, warnings, errors };
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
if (existing === undefined && remote === null) {
|
|
294
|
+
errors.push(
|
|
295
|
+
errDiag(
|
|
296
|
+
SYSTEM_PRODUCTS_FILE,
|
|
297
|
+
`new product "${id}" needs --remote <url>`,
|
|
298
|
+
"The roster requires a remote on first registration.",
|
|
299
|
+
),
|
|
300
|
+
);
|
|
301
|
+
return { productsDirty: false, localDirty: false, warnings, errors };
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
if (folder !== null) {
|
|
305
|
+
const holder = Object.entries(folders).find(([otherId, f]) => otherId !== id && f === folder);
|
|
306
|
+
if (holder !== undefined) {
|
|
307
|
+
errors.push(
|
|
308
|
+
errDiag(
|
|
309
|
+
SYSTEM_LOCAL_FILE,
|
|
310
|
+
`folder "${folder}" is already mapped to product "${holder[0]}"`,
|
|
311
|
+
`Fix ${SYSTEM_LOCAL_FILE} — two products may not share one checkout folder.`,
|
|
312
|
+
),
|
|
313
|
+
);
|
|
314
|
+
return { productsDirty: false, localDirty: false, warnings, errors };
|
|
315
|
+
}
|
|
316
|
+
if (!(await dirExists(io, resolveFolder(root, folder)))) {
|
|
317
|
+
warnings.push(
|
|
318
|
+
warnDiag(
|
|
319
|
+
SYSTEM_LOCAL_FILE,
|
|
320
|
+
`folder "${folder}" does not exist on disk — recorded anyway`,
|
|
321
|
+
`Check out ${id} at ${folder} or fix the mapping later.`,
|
|
322
|
+
),
|
|
323
|
+
);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
let productsDirty = false;
|
|
328
|
+
if (existing === undefined) {
|
|
329
|
+
products.push({
|
|
330
|
+
id,
|
|
331
|
+
remote: remote!,
|
|
332
|
+
offers,
|
|
333
|
+
...(frozen ? { frozen: true } : {}),
|
|
334
|
+
});
|
|
335
|
+
registered.push({ id, folder, updated: false });
|
|
336
|
+
productsDirty = true;
|
|
337
|
+
} else {
|
|
338
|
+
if (remote !== null && existing.remote !== remote) {
|
|
339
|
+
existing.remote = remote;
|
|
340
|
+
productsDirty = true;
|
|
341
|
+
}
|
|
342
|
+
if (offers.length > 0 && !sameSet(existing.offers, offers)) {
|
|
343
|
+
existing.offers = offers;
|
|
344
|
+
productsDirty = true;
|
|
345
|
+
}
|
|
346
|
+
if (frozen && existing.frozen !== true) {
|
|
347
|
+
existing.frozen = true;
|
|
348
|
+
productsDirty = true;
|
|
349
|
+
}
|
|
350
|
+
registered.push({ id, folder, updated: true });
|
|
351
|
+
}
|
|
352
|
+
let localDirty = false;
|
|
353
|
+
if (folder !== null && folders[id] !== folder) {
|
|
354
|
+
folders[id] = folder;
|
|
355
|
+
localDirty = true;
|
|
356
|
+
}
|
|
357
|
+
return { productsDirty, localDirty, warnings, errors };
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
function sameSet(a: string[], b: string[]): boolean {
|
|
361
|
+
return a.length === b.length && a.every((x) => b.includes(x));
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/** `--discover` sibling scan — registers every unregistered forge sibling. */
|
|
365
|
+
async function runDiscover(
|
|
366
|
+
map: SystemMap,
|
|
367
|
+
root: string,
|
|
368
|
+
products: SystemProduct[],
|
|
369
|
+
folders: Record<string, string>,
|
|
370
|
+
registered: RegisteredEntry[],
|
|
371
|
+
skipped: SkippedEntry[],
|
|
372
|
+
io: WorkspaceIO,
|
|
373
|
+
): Promise<PathOutcome> {
|
|
374
|
+
const warnings: Diagnostic[] = [];
|
|
375
|
+
const errors: Diagnostic[] = [];
|
|
376
|
+
const ignored = new Set((map.products.ignored ?? []).map((i) => i.id));
|
|
377
|
+
const knownIds = new Set(products.map((p) => p.id));
|
|
378
|
+
const parent = path.dirname(root);
|
|
379
|
+
|
|
380
|
+
let children;
|
|
381
|
+
try {
|
|
382
|
+
children = await io.readdir(parent);
|
|
383
|
+
} catch {
|
|
384
|
+
errors.push(
|
|
385
|
+
errDiag(
|
|
386
|
+
parent,
|
|
387
|
+
"could not enumerate the hub's parent directory — discover aborted",
|
|
388
|
+
"Check read permissions on the parent directory.",
|
|
389
|
+
),
|
|
390
|
+
);
|
|
391
|
+
return { productsDirty: false, localDirty: false, warnings, errors };
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
let productsDirty = false;
|
|
395
|
+
let localDirty = false;
|
|
396
|
+
for (const child of children) {
|
|
397
|
+
const name = child.name;
|
|
398
|
+
if (!child.isDirectory || name.startsWith(".") || name.includes("@")) continue;
|
|
399
|
+
const childAbs = path.join(parent, name);
|
|
400
|
+
if (childAbs === root) continue;
|
|
401
|
+
if (ignored.has(name)) {
|
|
402
|
+
skipped.push({ name, reason: "ignored[]" });
|
|
403
|
+
continue;
|
|
404
|
+
}
|
|
405
|
+
if (!(await io.exists(path.join(childAbs, FORGE_CONFIG_FILE)))) continue;
|
|
406
|
+
if (!SYSTEM_ID_PATTERN.test(name)) {
|
|
407
|
+
skipped.push({ name, reason: "name is not kebab-case — register manually with --id" });
|
|
408
|
+
warnings.push(
|
|
409
|
+
warnDiag(
|
|
410
|
+
name,
|
|
411
|
+
`sibling "${name}" carries forge.yaml but its name is not a kebab-case product id`,
|
|
412
|
+
`Register it manually: system.product.register --id <kebab-id> --remote <url> --folder ../${name}`,
|
|
413
|
+
),
|
|
414
|
+
);
|
|
415
|
+
continue;
|
|
416
|
+
}
|
|
417
|
+
if (knownIds.has(name)) {
|
|
418
|
+
skipped.push({ name, reason: "already-registered" });
|
|
419
|
+
continue;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
const remote = await git(childAbs, io, ["remote", "get-url", "origin"]);
|
|
423
|
+
const remoteUrl = remote.exitCode === 0 ? remote.stdout.trim() : "";
|
|
424
|
+
if (remoteUrl.length === 0) {
|
|
425
|
+
skipped.push({ name, reason: "no origin remote — register manually with --remote" });
|
|
426
|
+
warnings.push(
|
|
427
|
+
warnDiag(
|
|
428
|
+
name,
|
|
429
|
+
`sibling "${name}" carries forge.yaml but has no readable git origin remote`,
|
|
430
|
+
`Register it manually: system.product.register --id ${name} --remote <url> --folder ../${name}`,
|
|
431
|
+
),
|
|
432
|
+
);
|
|
433
|
+
continue;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
const folder = `../${name}`;
|
|
437
|
+
products.push({ id: name, remote: remoteUrl, offers: [] });
|
|
438
|
+
knownIds.add(name);
|
|
439
|
+
folders[name] = folder;
|
|
440
|
+
productsDirty = true;
|
|
441
|
+
localDirty = true;
|
|
442
|
+
registered.push({ id: name, folder, updated: false });
|
|
443
|
+
}
|
|
444
|
+
return { productsDirty, localDirty, warnings, errors };
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
function finish(
|
|
448
|
+
mode: "explicit" | "discover",
|
|
449
|
+
dryRun: boolean,
|
|
450
|
+
registered: RegisteredEntry[],
|
|
451
|
+
skipped: SkippedEntry[],
|
|
452
|
+
written: string[],
|
|
453
|
+
warnings: Diagnostic[],
|
|
454
|
+
errors: Diagnostic[],
|
|
455
|
+
context: ForgeRuntimeContext,
|
|
456
|
+
): ForgeCommandResult<SystemProductRegisterResult> {
|
|
457
|
+
const status = errors.length > 0 ? "fail" : warnings.length > 0 ? "warn" : "ok";
|
|
458
|
+
if (context.outputFormat === "pretty") {
|
|
459
|
+
for (const r of registered) {
|
|
460
|
+
context.logger.info(
|
|
461
|
+
` ${r.updated ? "updated" : "registered"}: ${r.id} ${r.folder ?? ""}`.trimEnd(),
|
|
462
|
+
);
|
|
463
|
+
}
|
|
464
|
+
for (const s of skipped) context.logger.info(` skipped: ${s.name} — ${s.reason}`);
|
|
465
|
+
for (const d of errors) context.logger.error(`${d.ruleId} · ${d.message}`);
|
|
466
|
+
for (const d of warnings) context.logger.warn(`${d.ruleId} · ${d.message}`);
|
|
467
|
+
}
|
|
468
|
+
return {
|
|
469
|
+
data: {
|
|
470
|
+
command: "system.product.register",
|
|
471
|
+
status,
|
|
472
|
+
mode,
|
|
473
|
+
dryRun,
|
|
474
|
+
registered,
|
|
475
|
+
skipped,
|
|
476
|
+
written,
|
|
477
|
+
warnings,
|
|
478
|
+
errors,
|
|
479
|
+
},
|
|
480
|
+
exitCode: errors.length > 0 ? 1 : 0,
|
|
481
|
+
summary: `system.product.register: ${status} — ${registered.length} registered, ${skipped.length} skipped, ${errors.length} error(s)`,
|
|
482
|
+
nextSteps:
|
|
483
|
+
errors.length > 0
|
|
484
|
+
? [{ action: "Fix the error-severity registration diagnostics above", kind: "required" }]
|
|
485
|
+
: [
|
|
486
|
+
{
|
|
487
|
+
action: "Commit system/products.yaml and products.local.yaml in this session",
|
|
488
|
+
kind: "optional",
|
|
489
|
+
},
|
|
490
|
+
],
|
|
491
|
+
};
|
|
492
|
+
}
|