oh-my-copilot 5.18.2 → 5.19.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/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +206 -104
- package/bridge/__pycache__/gyoshu_bridge.cpython-314.pyc +0 -0
- package/bridge/claude-md-coordinator.cjs +2 -2
- package/bridge/cli.cjs +7155 -4471
- package/bridge/mcp-server.cjs +2470 -1027
- package/bridge/runtime-cli.cjs +102 -12
- package/bridge/team-mcp.cjs +100 -11
- package/bridge/team.js +100 -11
- package/dist/budget/ledger.d.ts +5 -0
- package/dist/budget/ledger.d.ts.map +1 -1
- package/dist/budget/ledger.js +2 -1
- package/dist/budget/ledger.js.map +1 -1
- package/dist/cli/commands/__tests__/factory-forge-cli.test.js +3 -3
- package/dist/cli/commands/__tests__/factory-forge-cli.test.js.map +1 -1
- package/dist/cli/commands/__tests__/factory-init.test.js +239 -17
- package/dist/cli/commands/__tests__/factory-init.test.js.map +1 -1
- package/dist/cli/commands/__tests__/factory-run-cli.test.js +103 -2
- package/dist/cli/commands/__tests__/factory-run-cli.test.js.map +1 -1
- package/dist/cli/commands/factory-board.d.ts +9 -0
- package/dist/cli/commands/factory-board.d.ts.map +1 -0
- package/dist/cli/commands/factory-board.js +34 -0
- package/dist/cli/commands/factory-board.js.map +1 -0
- package/dist/cli/commands/factory-check.d.ts +1 -0
- package/dist/cli/commands/factory-check.d.ts.map +1 -1
- package/dist/cli/commands/factory-check.js +2 -1
- package/dist/cli/commands/factory-check.js.map +1 -1
- package/dist/cli/commands/factory-poll.d.ts +9 -0
- package/dist/cli/commands/factory-poll.d.ts.map +1 -0
- package/dist/cli/commands/factory-poll.js +34 -0
- package/dist/cli/commands/factory-poll.js.map +1 -0
- package/dist/cli/commands/factory-setup.d.ts +2 -0
- package/dist/cli/commands/factory-setup.d.ts.map +1 -1
- package/dist/cli/commands/factory-setup.js +9 -3
- package/dist/cli/commands/factory-setup.js.map +1 -1
- package/dist/cli/commands/factory.d.ts +61 -18
- package/dist/cli/commands/factory.d.ts.map +1 -1
- package/dist/cli/commands/factory.js +325 -53
- package/dist/cli/commands/factory.js.map +1 -1
- package/dist/factory/__tests__/check-run.test.js +37 -96
- package/dist/factory/__tests__/check-run.test.js.map +1 -1
- package/dist/factory/__tests__/enqueue-ado.test.d.ts +2 -0
- package/dist/factory/__tests__/enqueue-ado.test.d.ts.map +1 -0
- package/dist/factory/__tests__/enqueue-ado.test.js +375 -0
- package/dist/factory/__tests__/enqueue-ado.test.js.map +1 -0
- package/dist/factory/__tests__/enqueue.test.d.ts +2 -0
- package/dist/factory/__tests__/enqueue.test.d.ts.map +1 -0
- package/dist/factory/__tests__/enqueue.test.js +470 -0
- package/dist/factory/__tests__/enqueue.test.js.map +1 -0
- package/dist/factory/__tests__/heal-ado.test.d.ts +2 -0
- package/dist/factory/__tests__/heal-ado.test.d.ts.map +1 -0
- package/dist/factory/__tests__/heal-ado.test.js +237 -0
- package/dist/factory/__tests__/heal-ado.test.js.map +1 -0
- package/dist/factory/__tests__/listener.test.js +27 -9
- package/dist/factory/__tests__/listener.test.js.map +1 -1
- package/dist/factory/__tests__/map-frontier.test.js +68 -0
- package/dist/factory/__tests__/map-frontier.test.js.map +1 -1
- package/dist/factory/__tests__/map-ingest.test.js +4 -3
- package/dist/factory/__tests__/map-ingest.test.js.map +1 -1
- package/dist/factory/__tests__/poll-ado.test.d.ts +2 -0
- package/dist/factory/__tests__/poll-ado.test.d.ts.map +1 -0
- package/dist/factory/__tests__/poll-ado.test.js +263 -0
- package/dist/factory/__tests__/poll-ado.test.js.map +1 -0
- package/dist/factory/__tests__/poll.test.d.ts +2 -0
- package/dist/factory/__tests__/poll.test.d.ts.map +1 -0
- package/dist/factory/__tests__/poll.test.js +748 -0
- package/dist/factory/__tests__/poll.test.js.map +1 -0
- package/dist/factory/board/__tests__/board-ado.test.d.ts +2 -0
- package/dist/factory/board/__tests__/board-ado.test.d.ts.map +1 -0
- package/dist/factory/board/__tests__/board-ado.test.js +194 -0
- package/dist/factory/board/__tests__/board-ado.test.js.map +1 -0
- package/dist/factory/board/__tests__/board.test.d.ts +2 -0
- package/dist/factory/board/__tests__/board.test.d.ts.map +1 -0
- package/dist/factory/board/__tests__/board.test.js +287 -0
- package/dist/factory/board/__tests__/board.test.js.map +1 -0
- package/dist/factory/board/collect.d.ts +145 -0
- package/dist/factory/board/collect.d.ts.map +1 -0
- package/dist/factory/board/collect.js +330 -0
- package/dist/factory/board/collect.js.map +1 -0
- package/dist/factory/board/render.d.ts +12 -0
- package/dist/factory/board/render.d.ts.map +1 -0
- package/dist/factory/board/render.js +93 -0
- package/dist/factory/board/render.js.map +1 -0
- package/dist/factory/check/__tests__/ado.test.js +14 -1
- package/dist/factory/check/__tests__/ado.test.js.map +1 -1
- package/dist/factory/check/__tests__/cli.test.js +38 -0
- package/dist/factory/check/__tests__/cli.test.js.map +1 -1
- package/dist/factory/check/__tests__/rules.test.js +72 -2
- package/dist/factory/check/__tests__/rules.test.js.map +1 -1
- package/dist/factory/check/cli.d.ts +34 -6
- package/dist/factory/check/cli.d.ts.map +1 -1
- package/dist/factory/check/cli.js +56 -34
- package/dist/factory/check/cli.js.map +1 -1
- package/dist/factory/check/rules.d.ts +11 -3
- package/dist/factory/check/rules.d.ts.map +1 -1
- package/dist/factory/check/rules.js +18 -5
- package/dist/factory/check/rules.js.map +1 -1
- package/dist/factory/check/score.d.ts +22 -2
- package/dist/factory/check/score.d.ts.map +1 -1
- package/dist/factory/check/score.js +55 -1
- package/dist/factory/check/score.js.map +1 -1
- package/dist/factory/enqueue.d.ts +195 -0
- package/dist/factory/enqueue.d.ts.map +1 -0
- package/dist/factory/enqueue.js +788 -0
- package/dist/factory/enqueue.js.map +1 -0
- package/dist/factory/heal/cli.d.ts +34 -2
- package/dist/factory/heal/cli.d.ts.map +1 -1
- package/dist/factory/heal/cli.js +88 -19
- package/dist/factory/heal/cli.js.map +1 -1
- package/dist/factory/heal/history.d.ts +12 -6
- package/dist/factory/heal/history.d.ts.map +1 -1
- package/dist/factory/heal/history.js +16 -6
- package/dist/factory/heal/history.js.map +1 -1
- package/dist/factory/heal/implement.d.ts +3 -1
- package/dist/factory/heal/implement.d.ts.map +1 -1
- package/dist/factory/heal/implement.js +1 -0
- package/dist/factory/heal/implement.js.map +1 -1
- package/dist/factory/heal/run.d.ts +3 -0
- package/dist/factory/heal/run.d.ts.map +1 -1
- package/dist/factory/heal/run.js +1 -1
- package/dist/factory/heal/run.js.map +1 -1
- package/dist/factory/listener.d.ts +13 -17
- package/dist/factory/listener.d.ts.map +1 -1
- package/dist/factory/listener.js +37 -63
- package/dist/factory/listener.js.map +1 -1
- package/dist/factory/map-frontier.d.ts +8 -1
- package/dist/factory/map-frontier.d.ts.map +1 -1
- package/dist/factory/map-frontier.js +65 -5
- package/dist/factory/map-frontier.js.map +1 -1
- package/dist/factory/map-ingest.d.ts.map +1 -1
- package/dist/factory/map-ingest.js +12 -1
- package/dist/factory/map-ingest.js.map +1 -1
- package/dist/factory/poll.d.ts +308 -0
- package/dist/factory/poll.d.ts.map +1 -0
- package/dist/factory/poll.js +677 -0
- package/dist/factory/poll.js.map +1 -0
- package/dist/factory/run/__tests__/engine.ado.test.js +157 -8
- package/dist/factory/run/__tests__/engine.ado.test.js.map +1 -1
- package/dist/factory/run/__tests__/engine.outcome.test.d.ts +2 -0
- package/dist/factory/run/__tests__/engine.outcome.test.d.ts.map +1 -0
- package/dist/factory/run/__tests__/engine.outcome.test.js +223 -0
- package/dist/factory/run/__tests__/engine.outcome.test.js.map +1 -0
- package/dist/factory/run/__tests__/engine.test.js +91 -0
- package/dist/factory/run/__tests__/engine.test.js.map +1 -1
- package/dist/factory/run/__tests__/units.test.js +299 -2
- package/dist/factory/run/__tests__/units.test.js.map +1 -1
- package/dist/factory/run/engine.d.ts +11 -3
- package/dist/factory/run/engine.d.ts.map +1 -1
- package/dist/factory/run/engine.js +145 -22
- package/dist/factory/run/engine.js.map +1 -1
- package/dist/factory/run/exec.d.ts +32 -4
- package/dist/factory/run/exec.d.ts.map +1 -1
- package/dist/factory/run/exec.js +120 -15
- package/dist/factory/run/exec.js.map +1 -1
- package/dist/factory/run/outcome.d.ts +31 -0
- package/dist/factory/run/outcome.d.ts.map +1 -0
- package/dist/factory/run/outcome.js +70 -0
- package/dist/factory/run/outcome.js.map +1 -0
- package/dist/factory/run/review-output.d.ts +6 -1
- package/dist/factory/run/review-output.d.ts.map +1 -1
- package/dist/factory/run/review-output.js +13 -3
- package/dist/factory/run/review-output.js.map +1 -1
- package/dist/factory/run/state.d.ts +2 -0
- package/dist/factory/run/state.d.ts.map +1 -1
- package/dist/factory/run/state.js.map +1 -1
- package/dist/factory/setup/__tests__/pipeline-pick.test.d.ts +2 -0
- package/dist/factory/setup/__tests__/pipeline-pick.test.d.ts.map +1 -0
- package/dist/factory/setup/__tests__/pipeline-pick.test.js +84 -0
- package/dist/factory/setup/__tests__/pipeline-pick.test.js.map +1 -0
- package/dist/factory/setup/__tests__/setup.test.js +1 -0
- package/dist/factory/setup/__tests__/setup.test.js.map +1 -1
- package/dist/factory/setup/detect.js +1 -1
- package/dist/factory/setup/detect.js.map +1 -1
- package/dist/factory/setup/pipeline-pick.d.ts +25 -0
- package/dist/factory/setup/pipeline-pick.d.ts.map +1 -0
- package/dist/factory/setup/pipeline-pick.js +55 -0
- package/dist/factory/setup/pipeline-pick.js.map +1 -0
- package/dist/factory/setup/write.d.ts +6 -0
- package/dist/factory/setup/write.d.ts.map +1 -1
- package/dist/factory/setup/write.js +3 -1
- package/dist/factory/setup/write.js.map +1 -1
- package/dist/factory/watchdog.d.ts +3 -2
- package/dist/factory/watchdog.d.ts.map +1 -1
- package/dist/factory/watchdog.js +5 -4
- package/dist/factory/watchdog.js.map +1 -1
- package/dist/factory/watchdog.test.js +19 -4
- package/dist/factory/watchdog.test.js.map +1 -1
- package/dist/forge/__tests__/config.test.js +51 -0
- package/dist/forge/__tests__/config.test.js.map +1 -1
- package/dist/forge/__tests__/gh-argv-baseline.chain.test.js +2 -2
- package/dist/forge/__tests__/gh-argv-baseline.chain.test.js.map +1 -1
- package/dist/forge/__tests__/gh-argv-baseline.factory.test.js +6 -4
- package/dist/forge/__tests__/gh-argv-baseline.factory.test.js.map +1 -1
- package/dist/forge/__tests__/gh-argv-baseline.tracker-writes.test.d.ts +2 -0
- package/dist/forge/__tests__/gh-argv-baseline.tracker-writes.test.d.ts.map +1 -0
- package/dist/forge/__tests__/gh-argv-baseline.tracker-writes.test.js +100 -0
- package/dist/forge/__tests__/gh-argv-baseline.tracker-writes.test.js.map +1 -0
- package/dist/forge/ado/__tests__/acceptance-scripts.test.js +360 -30
- package/dist/forge/ado/__tests__/acceptance-scripts.test.js.map +1 -1
- package/dist/forge/ado/__tests__/adapter.test.js +18 -3
- package/dist/forge/ado/__tests__/adapter.test.js.map +1 -1
- package/dist/forge/ado/__tests__/ci.test.d.ts +2 -0
- package/dist/forge/ado/__tests__/ci.test.d.ts.map +1 -0
- package/dist/forge/ado/__tests__/ci.test.js +271 -0
- package/dist/forge/ado/__tests__/ci.test.js.map +1 -0
- package/dist/forge/ado/__tests__/routes.test.js +24 -5
- package/dist/forge/ado/__tests__/routes.test.js.map +1 -1
- package/dist/forge/ado/__tests__/tracker-writes.test.d.ts +8 -0
- package/dist/forge/ado/__tests__/tracker-writes.test.d.ts.map +1 -0
- package/dist/forge/ado/__tests__/tracker-writes.test.js +377 -0
- package/dist/forge/ado/__tests__/tracker-writes.test.js.map +1 -0
- package/dist/forge/ado/__tests__/world.d.ts +4 -0
- package/dist/forge/ado/__tests__/world.d.ts.map +1 -1
- package/dist/forge/ado/__tests__/world.js +3 -2
- package/dist/forge/ado/__tests__/world.js.map +1 -1
- package/dist/forge/ado/checks.d.ts +25 -2
- package/dist/forge/ado/checks.d.ts.map +1 -1
- package/dist/forge/ado/checks.js +47 -23
- package/dist/forge/ado/checks.js.map +1 -1
- package/dist/forge/ado/ci.d.ts +13 -0
- package/dist/forge/ado/ci.d.ts.map +1 -0
- package/dist/forge/ado/ci.js +134 -0
- package/dist/forge/ado/ci.js.map +1 -0
- package/dist/forge/ado/guard.d.ts +19 -6
- package/dist/forge/ado/guard.d.ts.map +1 -1
- package/dist/forge/ado/guard.js +52 -11
- package/dist/forge/ado/guard.js.map +1 -1
- package/dist/forge/ado/index.d.ts +7 -1
- package/dist/forge/ado/index.d.ts.map +1 -1
- package/dist/forge/ado/index.js +16 -3
- package/dist/forge/ado/index.js.map +1 -1
- package/dist/forge/ado/reviews.d.ts +9 -1
- package/dist/forge/ado/reviews.d.ts.map +1 -1
- package/dist/forge/ado/reviews.js +45 -1
- package/dist/forge/ado/reviews.js.map +1 -1
- package/dist/forge/ado/routes.d.ts +35 -5
- package/dist/forge/ado/routes.d.ts.map +1 -1
- package/dist/forge/ado/routes.js +181 -9
- package/dist/forge/ado/routes.js.map +1 -1
- package/dist/forge/ado/tracker.d.ts +13 -2
- package/dist/forge/ado/tracker.d.ts.map +1 -1
- package/dist/forge/ado/tracker.js +139 -3
- package/dist/forge/ado/tracker.js.map +1 -1
- package/dist/forge/ado/wiql.d.ts +2 -0
- package/dist/forge/ado/wiql.d.ts.map +1 -1
- package/dist/forge/ado/wiql.js +6 -0
- package/dist/forge/ado/wiql.js.map +1 -1
- package/dist/forge/body-file.d.ts +17 -0
- package/dist/forge/body-file.d.ts.map +1 -0
- package/dist/forge/body-file.js +59 -0
- package/dist/forge/body-file.js.map +1 -0
- package/dist/forge/config.d.ts +3 -1
- package/dist/forge/config.d.ts.map +1 -1
- package/dist/forge/config.js +37 -2
- package/dist/forge/config.js.map +1 -1
- package/dist/forge/github/__tests__/argv-parity.test.js +17 -1
- package/dist/forge/github/__tests__/argv-parity.test.js.map +1 -1
- package/dist/forge/github/gh.d.ts +6 -0
- package/dist/forge/github/gh.d.ts.map +1 -1
- package/dist/forge/github/gh.js +2 -0
- package/dist/forge/github/gh.js.map +1 -1
- package/dist/forge/github/reviews.d.ts +2 -0
- package/dist/forge/github/reviews.d.ts.map +1 -1
- package/dist/forge/github/reviews.js +6 -0
- package/dist/forge/github/reviews.js.map +1 -1
- package/dist/forge/github/tracker.d.ts +20 -4
- package/dist/forge/github/tracker.d.ts.map +1 -1
- package/dist/forge/github/tracker.js +59 -5
- package/dist/forge/github/tracker.js.map +1 -1
- package/dist/forge/types.d.ts +108 -2
- package/dist/forge/types.d.ts.map +1 -1
- package/dist/forge/types.js +8 -0
- package/dist/forge/types.js.map +1 -1
- package/dist/graph/schema.d.ts +10 -10
- package/dist/hooks/session-end/__tests__/chain-enqueuer.test.js +156 -35
- package/dist/hooks/session-end/__tests__/chain-enqueuer.test.js.map +1 -1
- package/dist/hooks/session-end/__tests__/check-evidence.test.js +4 -4
- package/dist/hooks/session-end/__tests__/check-evidence.test.js.map +1 -1
- package/dist/hooks/session-end/__tests__/copilot-liveness.test.js +3 -3
- package/dist/hooks/session-end/__tests__/copilot-liveness.test.js.map +1 -1
- package/dist/hooks/session-end/__tests__/foreground-bootstrap.test.js +3 -3
- package/dist/hooks/session-end/__tests__/foreground-bootstrap.test.js.map +1 -1
- package/dist/hooks/session-end/__tests__/routing.test.js +36 -1
- package/dist/hooks/session-end/__tests__/routing.test.js.map +1 -1
- package/dist/hooks/session-end/__tests__/spawn-next.test.js +96 -5
- package/dist/hooks/session-end/__tests__/spawn-next.test.js.map +1 -1
- package/dist/hooks/session-end/__tests__/worker.test.js +38 -2
- package/dist/hooks/session-end/__tests__/worker.test.js.map +1 -1
- package/dist/hooks/session-end/chain-enqueuer.d.ts.map +1 -1
- package/dist/hooks/session-end/chain-enqueuer.js +22 -2
- package/dist/hooks/session-end/chain-enqueuer.js.map +1 -1
- package/dist/hooks/session-end/routing.d.ts +14 -0
- package/dist/hooks/session-end/routing.d.ts.map +1 -1
- package/dist/hooks/session-end/routing.js +25 -0
- package/dist/hooks/session-end/routing.js.map +1 -1
- package/dist/hooks/session-end/spawn-next.d.ts +20 -2
- package/dist/hooks/session-end/spawn-next.d.ts.map +1 -1
- package/dist/hooks/session-end/spawn-next.js +72 -5
- package/dist/hooks/session-end/spawn-next.js.map +1 -1
- package/dist/smoke/__tests__/copilot-chain-scenario.test.js +2 -1
- package/dist/smoke/__tests__/copilot-chain-scenario.test.js.map +1 -1
- package/dist/smoke/copilot-chain-scenario.d.ts.map +1 -1
- package/dist/smoke/copilot-chain-scenario.js +5 -1
- package/dist/smoke/copilot-chain-scenario.js.map +1 -1
- package/dist/team/__tests__/worker-launch-ack.test.js +134 -5
- package/dist/team/__tests__/worker-launch-ack.test.js.map +1 -1
- package/dist/team/worker-launch-ack.d.ts.map +1 -1
- package/dist/team/worker-launch-ack.js +19 -4
- package/dist/team/worker-launch-ack.js.map +1 -1
- package/docs/CLAUDE.md +1 -1
- package/docs/MIGRATION.md +26 -0
- package/docs/REFERENCE.md +187 -20
- package/docs/design/FACTORY-FINAL-DESIGN.md +1 -1
- package/docs/shipyard.md +17 -1
- package/package.json +2 -2
- package/plugin.json +1 -1
- package/scripts/ado-acceptance.mjs +309 -70
- package/scripts/lib/backlog-to-workitems.mjs +24 -21
- package/skills/ask-navigator/SKILL.md +5 -2
- package/skills/drydock/SKILL.md +2 -1
- package/skills/harbor/SKILL.md +17 -2
- package/skills/intent/SKILL.md +4 -0
- package/skills/launch/SKILL.md +35 -2
- package/skills/map/SKILL.md +2 -1
- package/skills/refit/SKILL.md +1 -0
|
@@ -5,12 +5,15 @@
|
|
|
5
5
|
* (smee.io / cloudflared / direct) live outside the OMC boundary: the daemon
|
|
6
6
|
* only receives already-unpacked webhook events as POSTs and does the OMC-side
|
|
7
7
|
* work itself (HMAC verification, repo whitelist, intake label gate, routing
|
|
8
|
-
* through the shared pure function, headless
|
|
8
|
+
* through the shared pure function, headless harbor session spawn).
|
|
9
9
|
*
|
|
10
10
|
* `omg factoryinit` — seeds the project route table (`.omg/factory-routes.json`,
|
|
11
11
|
* the single source of truth the SessionEnd chain enqueuer reads) and validates
|
|
12
|
-
* the factory prerequisites.
|
|
13
|
-
*
|
|
12
|
+
* the factory prerequisites. It seeds the narrow starter loop; --no-narrow is
|
|
13
|
+
* retired and refuses. Never overwrites without --force. `--check` audits an
|
|
14
|
+
* existing table; `--migrate` rewrites an old one (backup first).
|
|
15
|
+
*
|
|
16
|
+
* `omg factory chain status` (alias `omg factory status`) — the chain audit.
|
|
14
17
|
*
|
|
15
18
|
* Liveness: pid file at <omc root>/state/factory-listener.json (SessionStart
|
|
16
19
|
* supervision reads it) plus a GET /status endpoint on the listening port.
|
|
@@ -18,10 +21,12 @@
|
|
|
18
21
|
import { Command } from 'commander';
|
|
19
22
|
import { integerOption } from '../utils/integer-option.js';
|
|
20
23
|
import chalk from 'chalk';
|
|
21
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
|
|
24
|
+
import { existsSync, lstatSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from 'fs';
|
|
22
25
|
import { join, resolve } from 'path';
|
|
23
26
|
import { INTAKE_ROUTE_TABLE, startListener, stopListener } from '../../factory/listener.js';
|
|
24
27
|
import { readChainStatus } from '../../factory/status.js';
|
|
28
|
+
import { canonicalChainSkill, chainSkillStatus } from '../../hooks/session-end/routing.js';
|
|
29
|
+
import { LABEL_PATTERN, resolveChainSkill } from '../../hooks/session-end/spawn-next.js';
|
|
25
30
|
import { getOmcRoot } from '../../lib/worktree-paths.js';
|
|
26
31
|
import { resolveProjectConfigPath } from '../../config/project-config-path.js';
|
|
27
32
|
import { CopilotRunManager, defaultCopilotRunDeps } from '../../copilot-run/job.js';
|
|
@@ -36,11 +41,19 @@ import { resolveShipConfig, userConfigLayers } from '../../ship/config.js';
|
|
|
36
41
|
import { defaultExec } from '../../ship/exec.js';
|
|
37
42
|
import { parseJsonc } from '../../utils/jsonc.js';
|
|
38
43
|
import { healCommand } from '../../factory/heal/cli.js';
|
|
39
|
-
import { defaultFactoryCheckDeps, factoryCheckCommand } from './factory-check.js';
|
|
44
|
+
import { defaultFactoryCheckDeps, factoryCheckCommand, ttyConfirm } from './factory-check.js';
|
|
45
|
+
import { CheckIncompatibleError, CheckUsageError, EXIT_CHECK_FAILED, EXIT_CHECK_INCOMPATIBLE, EXIT_CHECK_USAGE } from '../../factory/check/cli.js';
|
|
46
|
+
import { runFactoryEnqueue } from '../../factory/enqueue.js';
|
|
40
47
|
import { resolveHealConfig } from '../../factory/heal/config.js';
|
|
41
48
|
import { defaultLedgerDir } from '../../factory/run/ledger.js';
|
|
42
49
|
import { listenForgeRefusal } from '../../factory/setup/detect.js';
|
|
43
50
|
import { factorySetupCommand } from './factory-setup.js';
|
|
51
|
+
import { factoryBoardCommand } from './factory-board.js';
|
|
52
|
+
import { factoryPollCommand } from './factory-poll.js';
|
|
53
|
+
import { defaultPollHealScan } from '../../factory/poll.js';
|
|
54
|
+
import { checkEnvFor, fetchBase, forgeReadExec, parseItemId } from '../../factory/check/cli.js';
|
|
55
|
+
import { BUCKET_ORDER, checkItems, plainText } from '../../factory/check/score.js';
|
|
56
|
+
import { createForge } from '../../forge/index.js';
|
|
44
57
|
export function renderChainStatus(status) {
|
|
45
58
|
const lines = [];
|
|
46
59
|
lines.push(`链状态 ${status.directory}`);
|
|
@@ -104,6 +117,16 @@ function factoryRoot(exec) {
|
|
|
104
117
|
throw new FactoryUsageError('omg factory run must run inside a git repository');
|
|
105
118
|
return r.stdout.trim();
|
|
106
119
|
}
|
|
120
|
+
/**
|
|
121
|
+
* The `omg factory run --json` documents on stdout. `omg factory poll`'s
|
|
122
|
+
* auto-start parses them (parseRunNextOutcome; its contract test builds its
|
|
123
|
+
* fixtures from these writers).
|
|
124
|
+
*/
|
|
125
|
+
export const factoryRunJson = {
|
|
126
|
+
nothingRunnable: (counts) => JSON.stringify({ ok: true, next: null, message: 'nothing runnable', counts }, null, 2),
|
|
127
|
+
outcome: (outcome, next) => JSON.stringify({ ok: outcome.exitCode === 0, ...(next !== undefined ? { next } : {}), ...outcome }, null, 2),
|
|
128
|
+
error: (message) => JSON.stringify({ ok: false, error: message }, null, 2),
|
|
129
|
+
};
|
|
107
130
|
async function factoryGuarded(json, fn) {
|
|
108
131
|
try {
|
|
109
132
|
process.exitCode = await fn();
|
|
@@ -111,7 +134,7 @@ async function factoryGuarded(json, fn) {
|
|
|
111
134
|
catch (error) {
|
|
112
135
|
const message = error instanceof Error ? error.message : String(error);
|
|
113
136
|
if (json)
|
|
114
|
-
console.log(
|
|
137
|
+
console.log(factoryRunJson.error(message));
|
|
115
138
|
else
|
|
116
139
|
console.error(chalk.red(`Error: ${message}`));
|
|
117
140
|
process.exitCode = error instanceof FactoryUsageError ? 2 : 1;
|
|
@@ -134,9 +157,31 @@ export function renderFactoryRunState(state) {
|
|
|
134
157
|
lines.push(chalk.gray(` ${h.at} ${h.from ?? '-'} -> ${h.to}: ${h.note}`));
|
|
135
158
|
return lines.join('\n');
|
|
136
159
|
}
|
|
137
|
-
|
|
160
|
+
/**
|
|
161
|
+
* `run --next`: the first runnable item in `omg factory check` order
|
|
162
|
+
* (priority, then id) among the spec's children (`--parent`) or the intake
|
|
163
|
+
* source, read through check's read-only guard. A merged, cancelled, failed
|
|
164
|
+
* or active run, an own factory PR open or merged, or an unsatisfied
|
|
165
|
+
* dependency is never runnable (check/rules.ts), so --next never re-runs a
|
|
166
|
+
* finished item. Null with the checked rows when nothing is runnable.
|
|
167
|
+
*/
|
|
168
|
+
function pickNext(deps, root, base, loaded, parent) {
|
|
169
|
+
const { config } = loaded;
|
|
170
|
+
const source = config.intake.source;
|
|
171
|
+
if (parent === undefined && !source)
|
|
172
|
+
throw new FactoryUsageError('--next needs --parent <spec> or factory.intake.source');
|
|
173
|
+
const read = forgeReadExec(deps.exec, config, root);
|
|
174
|
+
const forge = createForge(read.exec, root, config, read.options);
|
|
175
|
+
const warnings = [];
|
|
176
|
+
const baseSha = fetchBase(read.exec, root, base, warnings);
|
|
177
|
+
const ids = parent !== undefined ? forge.tracker.viewItem(parent).children : forge.tracker.queryItems(source, config.intake.limit);
|
|
178
|
+
const items = checkItems(forge, ids, checkEnvFor(read.exec, root, config, base, baseSha));
|
|
179
|
+
return { next: items.find((r) => r.bucket === 'runnable') ?? null, items, warnings };
|
|
180
|
+
}
|
|
181
|
+
const bucketCounts = (items) => Object.fromEntries(BUCKET_ORDER.map((b) => [b, items.filter((r) => r.bucket === b).length]));
|
|
182
|
+
function printOutcome(json, outcome, next) {
|
|
138
183
|
if (json) {
|
|
139
|
-
console.log(
|
|
184
|
+
console.log(factoryRunJson.outcome(outcome, next));
|
|
140
185
|
return;
|
|
141
186
|
}
|
|
142
187
|
if (outcome.state)
|
|
@@ -151,10 +196,22 @@ export function factoryRunCommand(deps = defaultFactoryRunDeps) {
|
|
|
151
196
|
run
|
|
152
197
|
.description('Experimental: drive one issue through implement -> draft PR -> independent review / fix rounds -> prepare -> CI gates, then park for the human merge')
|
|
153
198
|
.argument('[issue]', 'GitHub issue or Azure DevOps work item number')
|
|
199
|
+
.option('--next', 'Run the next runnable item (omg factory check order: priority, then id); exit 0 when nothing is runnable')
|
|
200
|
+
.option('--parent <spec>', 'With --next: pick among the children of this spec item instead of factory.intake.source')
|
|
154
201
|
.option('--dry-run', 'Resolve the issue and plan and print the next step; no state, lanes or pushes')
|
|
155
202
|
.option('--json', 'JSON output')
|
|
156
203
|
.action((issueRaw, o) => factoryGuarded(Boolean(o.json), async () => {
|
|
157
|
-
|
|
204
|
+
if (o.next && issueRaw !== undefined)
|
|
205
|
+
throw new FactoryUsageError('--next takes no issue: it picks the next runnable item');
|
|
206
|
+
if (o.parent !== undefined && !o.next)
|
|
207
|
+
throw new FactoryUsageError('--parent applies to --next');
|
|
208
|
+
let parent;
|
|
209
|
+
try {
|
|
210
|
+
parent = o.parent === undefined ? undefined : parseItemId(o.parent);
|
|
211
|
+
}
|
|
212
|
+
catch (error) {
|
|
213
|
+
throw new FactoryUsageError(error instanceof Error ? error.message : String(error));
|
|
214
|
+
}
|
|
158
215
|
const root = factoryRoot(exec);
|
|
159
216
|
const { limits, warnings } = deps.limits(root);
|
|
160
217
|
for (const w of warnings)
|
|
@@ -163,6 +220,29 @@ export function factoryRunCommand(deps = defaultFactoryRunDeps) {
|
|
|
163
220
|
const loaded = deps.forge?.(root, base);
|
|
164
221
|
for (const w of loaded?.warnings ?? [])
|
|
165
222
|
console.error(chalk.yellow(w));
|
|
223
|
+
let issue;
|
|
224
|
+
let picked;
|
|
225
|
+
if (o.next) {
|
|
226
|
+
if (!loaded)
|
|
227
|
+
throw new FactoryUsageError('--next needs the forge config (omg factory setup)');
|
|
228
|
+
const { next, items, warnings: pickWarnings } = pickNext(deps, root, base, loaded, parent);
|
|
229
|
+
for (const w of pickWarnings)
|
|
230
|
+
console.error(chalk.yellow(plainText(w)));
|
|
231
|
+
const counts = bucketCounts(items);
|
|
232
|
+
if (!next) {
|
|
233
|
+
if (o.json)
|
|
234
|
+
console.log(factoryRunJson.nothingRunnable(counts));
|
|
235
|
+
else
|
|
236
|
+
console.log(`nothing runnable (${BUCKET_ORDER.map((b) => `${counts[b]} ${b}`).join(', ')})`);
|
|
237
|
+
return 0;
|
|
238
|
+
}
|
|
239
|
+
issue = picked = next.id;
|
|
240
|
+
if (!o.json)
|
|
241
|
+
console.log(chalk.cyan(`next runnable: #${next.id} ${next.title}`));
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
issue = parseIssue(issueRaw);
|
|
245
|
+
}
|
|
166
246
|
// The full untrusted roots, never a partial list (critic amendments §A.14; the engine re-checks).
|
|
167
247
|
const forge = loaded ? { config: loaded.config, options: factoryForgeOptions(root) } : undefined;
|
|
168
248
|
let signals = 0;
|
|
@@ -186,7 +266,7 @@ export function factoryRunCommand(deps = defaultFactoryRunDeps) {
|
|
|
186
266
|
interrupted: () => signals > 0,
|
|
187
267
|
warn: (m) => console.error(chalk.yellow(m)),
|
|
188
268
|
});
|
|
189
|
-
printOutcome(Boolean(o.json), outcome);
|
|
269
|
+
printOutcome(Boolean(o.json), outcome, picked);
|
|
190
270
|
return outcome.exitCode;
|
|
191
271
|
}
|
|
192
272
|
finally {
|
|
@@ -249,11 +329,50 @@ export function factoryRunCommand(deps = defaultFactoryRunDeps) {
|
|
|
249
329
|
}));
|
|
250
330
|
return run;
|
|
251
331
|
}
|
|
332
|
+
/** `omg factory enqueue` (shipyard ↔ factory design §3.2-§3.4); the command lives in src/factory/enqueue.ts. */
|
|
333
|
+
export function factoryEnqueueCommand(deps) {
|
|
334
|
+
return new Command('enqueue')
|
|
335
|
+
.description('Push launch\'s approved tickets to the tracker as children of a spec (GitHub or Azure DevOps; idempotent by shipyard-key)')
|
|
336
|
+
.requiredOption('--spec <id>', 'the parent spec issue')
|
|
337
|
+
.requiredOption('--file <path>', 'the ticket file launch wrote (schemaVersion 1)')
|
|
338
|
+
.option('--dry-run', 'print the exact writes and write nothing')
|
|
339
|
+
.option('--json', 'JSON output (schemaVersion 1)')
|
|
340
|
+
.addHelpText('after', [
|
|
341
|
+
'',
|
|
342
|
+
'Without --dry-run, enqueue creates or updates the items (with the intake label and a priority label),',
|
|
343
|
+
'rewrites the spec\'s task list, then runs the mark step `omg factory check <ids> --mark --yes` over',
|
|
344
|
+
'this file\'s created, updated and unchanged items (never orphans), which adds factory.intake.marker',
|
|
345
|
+
'to the runnable ones. The launch C3 signature is the confirmation',
|
|
346
|
+
'for all of it: run --dry-run first and show its output at C3. Items already claimed by a factory run',
|
|
347
|
+
'are never edited, and items whose key left the file are reported as orphaned, never closed.',
|
|
348
|
+
'On Azure DevOps the items are work items of factory.intake.itemTypes[0] with the AC and priority fields,',
|
|
349
|
+
'linked to the spec (parent) and their predecessors; the spec itself is not edited.',
|
|
350
|
+
].join('\n'))
|
|
351
|
+
.action(async (o) => {
|
|
352
|
+
try {
|
|
353
|
+
process.exitCode = await runFactoryEnqueue(o, deps);
|
|
354
|
+
}
|
|
355
|
+
catch (error) {
|
|
356
|
+
const message = plainText(error instanceof Error ? error.message : String(error));
|
|
357
|
+
if (o.json)
|
|
358
|
+
deps.out(JSON.stringify({ ok: false, error: message }, null, 2));
|
|
359
|
+
else
|
|
360
|
+
deps.err(chalk.red(`Error: ${message}`));
|
|
361
|
+
process.exitCode = error instanceof CheckUsageError ? EXIT_CHECK_USAGE : error instanceof CheckIncompatibleError ? EXIT_CHECK_INCOMPATIBLE : EXIT_CHECK_FAILED;
|
|
362
|
+
}
|
|
363
|
+
});
|
|
364
|
+
}
|
|
252
365
|
export function factoryCommand() {
|
|
253
366
|
const cmd = new Command('factory');
|
|
254
367
|
cmd.description('Software factory automation (chain trigger + intake listener)');
|
|
255
368
|
cmd.addCommand(factoryRunCommand());
|
|
256
369
|
cmd.addCommand(factoryCheckCommand(defaultFactoryCheckDeps(defaultFactoryRunDeps.base)));
|
|
370
|
+
cmd.addCommand(factoryEnqueueCommand(defaultFactoryCheckDeps(defaultFactoryRunDeps.base)));
|
|
371
|
+
cmd.addCommand(factoryBoardCommand(defaultFactoryCheckDeps(defaultFactoryRunDeps.base)));
|
|
372
|
+
cmd.addCommand(factoryPollCommand({
|
|
373
|
+
...defaultFactoryCheckDeps(defaultFactoryRunDeps.base),
|
|
374
|
+
healScan: defaultPollHealScan(defaultExec, (root) => resolveHealConfig(userConfigLayers().trustedUser, projectConfig(root)), defaultLedgerDir()),
|
|
375
|
+
}));
|
|
257
376
|
cmd.addCommand(healCommand({
|
|
258
377
|
exec: defaultExec,
|
|
259
378
|
base: defaultFactoryRunDeps.base,
|
|
@@ -265,11 +384,13 @@ export function factoryCommand() {
|
|
|
265
384
|
ledgerDir: defaultLedgerDir(),
|
|
266
385
|
runLimits: defaultFactoryRunDeps.limits,
|
|
267
386
|
forgeKind: (root) => originForgeKind(factoryGuardExec(defaultExec), root),
|
|
387
|
+
// Azure DevOps only: the trusted forge config naming factory.heal.pipeline (GitHub never loads it).
|
|
388
|
+
forge: defaultFactoryRunDeps.forge,
|
|
268
389
|
}));
|
|
269
390
|
cmd.addCommand(factorySetupCommand());
|
|
270
391
|
cmd
|
|
271
392
|
.command('listen')
|
|
272
|
-
.description('Run the intake listener daemon: HMAC-verified webhook events -> intake label gate -> headless
|
|
393
|
+
.description('Run the intake listener daemon: HMAC-verified webhook events -> intake label gate -> headless harbor sessions')
|
|
273
394
|
.option('--port <n>', 'port to listen on (transport adapters forward here)', integerOption(0, 65535), 7788)
|
|
274
395
|
.option('--host <addr>', 'host to bind to (default: 127.0.0.1 for localhost only; set to 0.0.0.0 only when transport adapter runs on another machine)', '127.0.0.1')
|
|
275
396
|
.requiredOption('--repo <names>', 'repository whitelist, comma-separated owner/name')
|
|
@@ -311,88 +432,97 @@ export function factoryCommand() {
|
|
|
311
432
|
cmd
|
|
312
433
|
.command('init')
|
|
313
434
|
.description('Seed the project route table .omg/factory-routes.json (the chain-routing source of truth) and validate factory prerequisites')
|
|
314
|
-
// Negatable option: Commander defaults `narrow` to true
|
|
315
|
-
//
|
|
316
|
-
.option('--no-narrow', '
|
|
435
|
+
// Negatable option: Commander defaults `narrow` to true. --no-narrow is
|
|
436
|
+
// kept only so that it refuses with a pointer instead of "unknown option".
|
|
437
|
+
.option('--no-narrow', 'retired: the full-pipeline template (intake -> intent -> launch -> diagnose) now refuses')
|
|
317
438
|
.option('--cwd <dir>', 'project directory to seed (defaults to the working directory)', process.cwd())
|
|
318
439
|
.option('--force', 'replace an existing route table (read it first — it is the routing source of truth)', false)
|
|
319
|
-
.
|
|
320
|
-
|
|
440
|
+
.option('--check', 'print every route of the existing table with its status and replacement (read-only; exit 1 when a route needs --migrate)')
|
|
441
|
+
.option('--migrate', 'rewrite an old table to the narrow one: captain/retired routes removed, intake -> harbor; writes a .bak first')
|
|
442
|
+
.option('--yes', 'confirm --migrate without a prompt (required without an interactive terminal)')
|
|
443
|
+
.action(async (options) => {
|
|
444
|
+
let result;
|
|
445
|
+
if (options.check && options.migrate)
|
|
446
|
+
result = { exitCode: 2, message: 'factory init: --check and --migrate are mutually exclusive' };
|
|
447
|
+
else if (options.check)
|
|
448
|
+
result = checkFactoryRoutes(options.cwd);
|
|
449
|
+
else if (options.migrate) {
|
|
450
|
+
result = await migrateFactoryRoutes({ cwd: options.cwd, yes: options.yes, isTTY: Boolean(process.stdin.isTTY), confirm: ttyConfirm });
|
|
451
|
+
}
|
|
452
|
+
else
|
|
453
|
+
result = runFactoryInit({ narrow: options.narrow, cwd: options.cwd, force: options.force });
|
|
321
454
|
if (result.exitCode === 0) {
|
|
322
|
-
console.log(chalk.green(result.message));
|
|
455
|
+
console.log(options.check ? result.message : chalk.green(result.message));
|
|
323
456
|
}
|
|
324
457
|
else {
|
|
325
|
-
console.error(chalk.red(result.message));
|
|
458
|
+
console.error(options.check ? result.message : chalk.red(result.message));
|
|
326
459
|
process.exitCode = result.exitCode;
|
|
327
460
|
}
|
|
328
461
|
});
|
|
329
462
|
// Read-only audit view of this project's chain: decision trail, stop
|
|
330
463
|
// markers, live ledgers, stalled links (D2). Never writes.
|
|
331
|
-
|
|
464
|
+
const chainStatus = (options) => {
|
|
465
|
+
const status = readChainStatus(process.cwd());
|
|
466
|
+
console.log(options.json ? JSON.stringify(status, null, 2) : renderChainStatus(status));
|
|
467
|
+
};
|
|
468
|
+
const chain = cmd.command('chain').description('Legacy SessionEnd chain (frozen: single intake -> harbor hop)');
|
|
469
|
+
chain
|
|
332
470
|
.command('status')
|
|
333
471
|
.description('Summarize this project\'s chain decisions, stop markers, and stalled links (read-only)')
|
|
334
472
|
.option('--json', 'Output as JSON')
|
|
335
|
-
.action(
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
});
|
|
473
|
+
.action(chainStatus);
|
|
474
|
+
// Kept so existing scripts work; `omg factory run status <issue>` is the engine's.
|
|
475
|
+
cmd
|
|
476
|
+
.command('status')
|
|
477
|
+
.description('Alias of omg factory chain status (legacy chain audit, read-only)')
|
|
478
|
+
.option('--json', 'Output as JSON')
|
|
479
|
+
.action(chainStatus);
|
|
343
480
|
return cmd;
|
|
344
481
|
}
|
|
345
482
|
/**
|
|
346
483
|
* Narrow starter route table: exactly the listener's INTAKE_ROUTE_TABLE — the
|
|
347
|
-
* single intake ->
|
|
484
|
+
* single intake -> harbor hop. Everything after a completed harbor session
|
|
348
485
|
* halts (`no-route`) until the project deliberately widens the table.
|
|
349
486
|
*/
|
|
350
487
|
export function buildRouteTableNarrow() {
|
|
351
488
|
return { ...INTAKE_ROUTE_TABLE };
|
|
352
489
|
}
|
|
353
|
-
/**
|
|
354
|
-
* Full-pipeline widening template: a documented example widening the starter
|
|
355
|
-
* loop into the intent -> launch -> diagnose progression. Keys are
|
|
356
|
-
* `outcome:reason` pairs (the listener's intake label event, or the ending
|
|
357
|
-
* session's outcome + hook reason); values name the next stage/skill. This is
|
|
358
|
-
* a starting point to edit per project — a missing route halts the chain, and
|
|
359
|
-
* `skill: "stop"` declares a terminal stage.
|
|
360
|
-
*/
|
|
361
|
-
export function buildRouteTableFull() {
|
|
362
|
-
return {
|
|
363
|
-
'success:intake': { stage: 'intent', skill: 'intent' },
|
|
364
|
-
'success:intent': { stage: 'launch', skill: 'launch' },
|
|
365
|
-
'success:launch': { stage: 'diagnose', skill: 'diagnose' },
|
|
366
|
-
};
|
|
367
|
-
}
|
|
368
490
|
/**
|
|
369
491
|
* Factory prerequisites, checked loudly before anything is written:
|
|
370
|
-
* harbor needs the OMC state root (`.omg/state/`) and the
|
|
371
|
-
*
|
|
492
|
+
* harbor needs the OMC state root (`.omg/state/`) and the yard's two day-one
|
|
493
|
+
* faces drydock seeds (`CLAUDE.md` + `GLOSSARY.md`).
|
|
372
494
|
*/
|
|
373
495
|
export function validateFactoryPrerequisites(cwd) {
|
|
374
496
|
const missing = [];
|
|
375
497
|
if (!existsSync(join(getOmcRoot(cwd), 'state')))
|
|
376
498
|
missing.push('.omg/state/');
|
|
377
|
-
|
|
378
|
-
|
|
499
|
+
for (const face of ['CLAUDE.md', 'GLOSSARY.md']) {
|
|
500
|
+
if (!existsSync(join(cwd, face)))
|
|
501
|
+
missing.push(face);
|
|
502
|
+
}
|
|
379
503
|
return { ok: missing.length === 0, missing };
|
|
380
504
|
}
|
|
381
505
|
/**
|
|
382
|
-
* `omg factoryinit`: seed `.omg/factory-routes.json`
|
|
383
|
-
*
|
|
506
|
+
* `omg factoryinit`: seed `.omg/factory-routes.json` with the narrow starter
|
|
507
|
+
* table. narrow:false (the retired full template) refuses. Refuses loudly when
|
|
384
508
|
* prerequisites are missing and never overwrites an existing table without
|
|
385
509
|
* force (the SessionEnd chain enqueuer reads that file as the single source
|
|
386
510
|
* of truth).
|
|
387
511
|
*/
|
|
388
512
|
export function runFactoryInit(options = {}) {
|
|
513
|
+
if (options.narrow === false) {
|
|
514
|
+
return {
|
|
515
|
+
exitCode: 1,
|
|
516
|
+
message: 'factory init refused: --no-narrow is retired. Its full template (intake -> intent -> launch -> diagnose) chained launch, which needs a live captain, into a diagnose skill that does not exist. Run launch in a session and deliver each issue with omg factory run <issue>; CI: failed push runs of ci.yml on the dev branch are queued by the listener (workflow_run) and processed by the next omg factory heal scan; failures on other branches or workflows are no longer acted on by the listener (run omg factory heal scan manually). See the factory section of docs/REFERENCE.md.',
|
|
517
|
+
};
|
|
518
|
+
}
|
|
389
519
|
const cwd = resolve(options.cwd ?? process.cwd());
|
|
390
520
|
const routesPath = join(getOmcRoot(cwd), 'factory-routes.json');
|
|
391
521
|
const prerequisites = validateFactoryPrerequisites(cwd);
|
|
392
522
|
if (!prerequisites.ok) {
|
|
393
523
|
return {
|
|
394
524
|
exitCode: 1,
|
|
395
|
-
message: `factory init refused: missing prerequisites (${prerequisites.missing.join(', ')}). Harbor needs .omg/state/ (run an OMC session or omg setup first); the
|
|
525
|
+
message: `factory init refused: missing prerequisites (${prerequisites.missing.join(', ')}). Harbor needs .omg/state/ (run an OMC session or omg setup first); the yard faces CLAUDE.md and GLOSSARY.md come from /oh-my-copilot:drydock. Point --cwd at the project root.`,
|
|
396
526
|
};
|
|
397
527
|
}
|
|
398
528
|
if (existsSync(routesPath) && !options.force) {
|
|
@@ -401,7 +531,7 @@ export function runFactoryInit(options = {}) {
|
|
|
401
531
|
message: `factory init refused: ${routesPath} already exists and the project route table is never overwritten. Read it first, then pass --force to replace it.`,
|
|
402
532
|
};
|
|
403
533
|
}
|
|
404
|
-
const table =
|
|
534
|
+
const table = buildRouteTableNarrow();
|
|
405
535
|
try {
|
|
406
536
|
mkdirSync(join(routesPath, '..'), { recursive: true });
|
|
407
537
|
writeFileSync(routesPath, `${JSON.stringify(table, null, 2)}\n`, 'utf8');
|
|
@@ -409,11 +539,153 @@ export function runFactoryInit(options = {}) {
|
|
|
409
539
|
catch (error) {
|
|
410
540
|
return { exitCode: 1, message: `factory init failed: cannot write ${routesPath}: ${error.message}` };
|
|
411
541
|
}
|
|
412
|
-
const mode = options.narrow === false ? 'full-pipeline widening template' : 'narrow starter table';
|
|
413
542
|
const routes = Object.entries(table).map(([key, directive]) => `${key} -> ${directive.stage}/${directive.skill}`).join('; ');
|
|
414
543
|
return {
|
|
415
544
|
exitCode: 0,
|
|
416
|
-
message: `factory init wrote ${routesPath} (
|
|
545
|
+
message: `factory init wrote ${routesPath} (narrow starter table): ${routes}. The SessionEnd chain enqueuer reads this file as the single source of truth — a missing route halts the chain, and skill "stop" marks a terminal stage.`,
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
function readRawRoutes(routesPath) {
|
|
549
|
+
if (!existsSync(routesPath))
|
|
550
|
+
return null;
|
|
551
|
+
const raw = readFileSync(routesPath, 'utf8');
|
|
552
|
+
try {
|
|
553
|
+
const parsed = JSON.parse(raw);
|
|
554
|
+
if (parsed && typeof parsed === 'object' && !Array.isArray(parsed))
|
|
555
|
+
return { ok: true, raw, table: parsed };
|
|
556
|
+
}
|
|
557
|
+
catch {
|
|
558
|
+
// reported below
|
|
559
|
+
}
|
|
560
|
+
return { ok: false, message: `${routesPath} is not a JSON object; fix it by hand or re-run omg factory init --force` };
|
|
561
|
+
}
|
|
562
|
+
function classifyRoute(cwd, key, value) {
|
|
563
|
+
const entry = value && typeof value === 'object' && !Array.isArray(value) ? value : {};
|
|
564
|
+
const stage = typeof entry.stage === 'string' ? entry.stage : '';
|
|
565
|
+
const skill = typeof entry.skill === 'string' ? entry.skill : '';
|
|
566
|
+
const row = (status, replacement) => ({ key, stage, skill, status, replacement });
|
|
567
|
+
if (!key.includes(':') || typeof entry.stage !== 'string' || typeof entry.skill !== 'string') {
|
|
568
|
+
return row('invalid', 'ignored by the chain: not an outcome:reason route with a stage and a skill');
|
|
569
|
+
}
|
|
570
|
+
const name = canonicalChainSkill(skill);
|
|
571
|
+
const status = chainSkillStatus(skill);
|
|
572
|
+
if (status === 'retired')
|
|
573
|
+
return row(status, 'none: omg factory heal scan handles CI failures');
|
|
574
|
+
if (status === 'captain') {
|
|
575
|
+
return row(status, name === 'launch'
|
|
576
|
+
? 'none: run /oh-my-copilot:launch with the accepted intent'
|
|
577
|
+
: `none: run /oh-my-copilot:${name} in a session (it needs a live captain)`);
|
|
578
|
+
}
|
|
579
|
+
if (!LABEL_PATTERN.test(stage) || !LABEL_PATTERN.test(skill))
|
|
580
|
+
return row('invalid', 'ignored by the chain: stage or skill has characters outside [A-Za-z0-9_.-]');
|
|
581
|
+
if (name === 'stop')
|
|
582
|
+
return row('terminal', '');
|
|
583
|
+
if (status === 'deprecated') {
|
|
584
|
+
return row(status, key === 'success:intake' ? 'success:intake -> harbor' : 'still spawns; tracker intake belongs to harbor');
|
|
585
|
+
}
|
|
586
|
+
const resolved = resolveChainSkill(cwd, skill);
|
|
587
|
+
if (resolved.ok)
|
|
588
|
+
return row('ok', '');
|
|
589
|
+
return row('unknown', resolved.hint
|
|
590
|
+
? `halts the chain (route-unknown): ${resolved.hint}`
|
|
591
|
+
: 'halts the chain (route-unknown): no bundled or project skill of this name');
|
|
592
|
+
}
|
|
593
|
+
function renderRouteRows(rows) {
|
|
594
|
+
const cells = [['route', 'skill', 'status', 'replacement'], ...rows.map((r) => [r.key, r.skill, r.status, r.replacement])];
|
|
595
|
+
const widths = [0, 1, 2].map((i) => Math.max(...cells.map((c) => c[i].length)));
|
|
596
|
+
return cells.map((c) => c.map((cell, i) => (i < 3 ? cell.padEnd(widths[i]) : cell)).join(' ').trimEnd()).join('\n');
|
|
597
|
+
}
|
|
598
|
+
/** Routes `--migrate` rewrites: refused skills drop out, the old intake -> intent hop becomes intake -> harbor. */
|
|
599
|
+
function needsMigration(row) {
|
|
600
|
+
return row.status === 'captain' || row.status === 'retired' || (row.status === 'deprecated' && row.key === 'success:intake');
|
|
601
|
+
}
|
|
602
|
+
/**
|
|
603
|
+
* `omg factory init --check`: classify every route of the project table
|
|
604
|
+
* (read-only). Exit 1 when a route halts at runtime (captain or retired
|
|
605
|
+
* skill) or the table is malformed, so `--migrate` is due; else 0.
|
|
606
|
+
*/
|
|
607
|
+
export function checkFactoryRoutes(cwd = process.cwd()) {
|
|
608
|
+
const root = resolve(cwd);
|
|
609
|
+
const routesPath = join(getOmcRoot(root), 'factory-routes.json');
|
|
610
|
+
const read = readRawRoutes(routesPath);
|
|
611
|
+
if (!read)
|
|
612
|
+
return { exitCode: 0, rows: [], message: `no route table at ${routesPath}; nothing to check` };
|
|
613
|
+
if (!read.ok)
|
|
614
|
+
return { exitCode: 1, rows: [], message: `factory init --check: ${read.message}` };
|
|
615
|
+
const rows = Object.entries(read.table).map(([key, value]) => classifyRoute(root, key, value));
|
|
616
|
+
const due = rows.filter(needsMigration);
|
|
617
|
+
const summary = due.some((r) => r.status === 'captain' || r.status === 'retired')
|
|
618
|
+
? `${due.length} route(s) need migration: captain and retired routes halt the chain (route-retired:<skill>). Run omg factory init --migrate.`
|
|
619
|
+
: due.length > 0
|
|
620
|
+
? `${due.length} route(s) can be migrated (omg factory init --migrate).`
|
|
621
|
+
: 'no route needs migration.';
|
|
622
|
+
return {
|
|
623
|
+
exitCode: rows.some((r) => r.status === 'captain' || r.status === 'retired') ? 1 : 0,
|
|
624
|
+
rows,
|
|
625
|
+
message: `${routesPath}\n${rows.length > 0 ? renderRouteRows(rows) : '(empty table)'}\n${summary}`,
|
|
417
626
|
};
|
|
418
627
|
}
|
|
628
|
+
/**
|
|
629
|
+
* `omg factory init --migrate`: back the table up to
|
|
630
|
+
* `factory-routes.json.bak-<timestamp>` (never overwriting a backup), then
|
|
631
|
+
* drop the captain/retired routes and turn `success:intake -> intent` into
|
|
632
|
+
* `-> harbor`. Every other entry stays byte-for-byte. Asks on a TTY; needs
|
|
633
|
+
* `--yes` otherwise.
|
|
634
|
+
*/
|
|
635
|
+
export async function migrateFactoryRoutes(options = {}) {
|
|
636
|
+
const root = resolve(options.cwd ?? process.cwd());
|
|
637
|
+
const routesPath = join(getOmcRoot(root), 'factory-routes.json');
|
|
638
|
+
const read = readRawRoutes(routesPath);
|
|
639
|
+
if (!read)
|
|
640
|
+
return { exitCode: 0, message: `no route table at ${routesPath}; nothing to migrate` };
|
|
641
|
+
if (!read.ok)
|
|
642
|
+
return { exitCode: 1, message: `factory init --migrate refused: ${read.message}` };
|
|
643
|
+
// The rename below would replace the link with a regular file and silently
|
|
644
|
+
// detach the table from its real target.
|
|
645
|
+
if (lstatSync(routesPath).isSymbolicLink()) {
|
|
646
|
+
return { exitCode: 1, message: `factory init --migrate refused: ${routesPath} is a symlink; migrate its target by hand (omg factory init --check shows the routes)` };
|
|
647
|
+
}
|
|
648
|
+
const rows = Object.entries(read.table).map(([key, value]) => classifyRoute(root, key, value));
|
|
649
|
+
const due = rows.filter(needsMigration);
|
|
650
|
+
if (due.length === 0)
|
|
651
|
+
return { exitCode: 0, message: `${routesPath}: nothing to migrate` };
|
|
652
|
+
const plan = due.map((r) => ` ${r.key} -> ${r.skill}: ${r.status === 'deprecated' ? 'becomes success:intake -> harbor' : 'removed'}`).join('\n');
|
|
653
|
+
if (!options.yes) {
|
|
654
|
+
if (!options.isTTY || !options.confirm) {
|
|
655
|
+
return { exitCode: 2, message: `factory init --migrate needs --yes without an interactive terminal. It would rewrite ${routesPath}:\n${plan}` };
|
|
656
|
+
}
|
|
657
|
+
if (!await options.confirm(`Rewrite ${routesPath}?\n${plan}\nA backup is written first.`)) {
|
|
658
|
+
return { exitCode: 1, message: 'factory init --migrate cancelled; nothing written' };
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
const migrated = {};
|
|
662
|
+
for (const [key, value] of Object.entries(read.table)) {
|
|
663
|
+
const row = rows.find((r) => r.key === key);
|
|
664
|
+
if (!needsMigration(row))
|
|
665
|
+
migrated[key] = value;
|
|
666
|
+
else if (row.status === 'deprecated')
|
|
667
|
+
migrated[key] = { ...value, stage: 'harbor', skill: 'harbor' };
|
|
668
|
+
}
|
|
669
|
+
const stamp = (options.now ?? new Date()).toISOString().replace(/\.\d{3}Z$/, 'Z').replace(/:/g, '-');
|
|
670
|
+
const backupPath = `${routesPath}.bak-${stamp}`;
|
|
671
|
+
try {
|
|
672
|
+
writeFileSync(backupPath, read.raw, { encoding: 'utf8', flag: 'wx' });
|
|
673
|
+
}
|
|
674
|
+
catch (error) {
|
|
675
|
+
return { exitCode: 1, message: `factory init --migrate refused: cannot write the backup ${backupPath} (${error.message}); nothing changed` };
|
|
676
|
+
}
|
|
677
|
+
const tmp = `${routesPath}.${process.pid}.tmp`;
|
|
678
|
+
try {
|
|
679
|
+
writeFileSync(tmp, `${JSON.stringify(migrated, null, 2)}\n`, 'utf8');
|
|
680
|
+
renameSync(tmp, routesPath);
|
|
681
|
+
}
|
|
682
|
+
catch (error) {
|
|
683
|
+
try {
|
|
684
|
+
unlinkSync(tmp);
|
|
685
|
+
}
|
|
686
|
+
catch { /* never written */ }
|
|
687
|
+
return { exitCode: 1, message: `factory init --migrate failed: cannot write ${routesPath} (${error.message}); the backup is ${backupPath}` };
|
|
688
|
+
}
|
|
689
|
+
return { exitCode: 0, message: `factory init --migrate rewrote ${routesPath} (backup: ${backupPath}):\n${plan}` };
|
|
690
|
+
}
|
|
419
691
|
//# sourceMappingURL=factory.js.map
|