@torrent-tv/proxy 2.89.17 → 2.89.19
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/README.md +14 -3
- package/package.json +10 -2
- package/server.js +0 -11
- package/utils/client-log-file.js +147 -42
- package/.claude/commands/opsx/apply.md +0 -155
- package/.claude/commands/opsx/archive.md +0 -160
- package/.claude/commands/opsx/explore.md +0 -174
- package/.claude/commands/opsx/propose.md +0 -109
- package/.claude/commands/opsx/sync.md +0 -143
- package/.claude/skills/openspec-apply-change/SKILL.md +0 -159
- package/.claude/skills/openspec-archive-change/SKILL.md +0 -117
- package/.claude/skills/openspec-explore/SKILL.md +0 -289
- package/.claude/skills/openspec-propose/SKILL.md +0 -113
- package/.claude/skills/openspec-sync-specs/SKILL.md +0 -147
- package/.dockerignore +0 -5
- package/AGENTS.md +0 -363
- package/CHANGELOG.md +0 -2377
- package/Dockerfile +0 -30
- package/biome.json +0 -412
- package/corpus.tmp.json +0 -1
- package/docs/browser-proxy-contract.md +0 -155
- package/docs/container-architecture.md +0 -273
- package/docs/download-architecture.md +0 -261
- package/docs/encode-architecture.md +0 -765
- package/docs/encode-run-state.md +0 -96
- package/docs/logs.md +0 -151
- package/docs/playback-start-forecast.md +0 -113
- package/docs/socks5-egress-research.md +0 -114
- package/docs/storage-architecture.md +0 -273
- package/knip.json +0 -14
- package/main2.cpuprofile +0 -1
- package/openspec/changes/adaptive-bitrate/.openspec.yaml +0 -0
- package/openspec/changes/adaptive-bitrate/design.md +0 -92
- package/openspec/changes/adaptive-bitrate/proposal.md +0 -56
- package/openspec/changes/adaptive-bitrate/specs/adaptive-bitrate/spec.md +0 -51
- package/openspec/changes/adaptive-bitrate/tasks.md +0 -40
- package/openspec/changes/binary-distribution/.openspec.yaml +0 -2
- package/openspec/changes/binary-distribution/proposal.md +0 -53
- package/openspec/changes/chunked-request-bodies/design.md +0 -81
- package/openspec/changes/chunked-request-bodies/proposal.md +0 -53
- package/openspec/changes/chunked-request-bodies/specs/chunked-request-bodies/spec.md +0 -30
- package/openspec/changes/chunked-request-bodies/tasks.md +0 -40
- package/openspec/changes/cold-start/design.md +0 -98
- package/openspec/changes/cold-start/proposal.md +0 -62
- package/openspec/changes/cold-start/specs/cold-start/spec.md +0 -47
- package/openspec/changes/cold-start/tasks.md +0 -48
- package/openspec/changes/disk-cap/.openspec.yaml +0 -2
- package/openspec/changes/disk-cap/proposal.md +0 -37
- package/openspec/changes/disk-cap/specs/disk-cap/spec.md +0 -25
- package/openspec/changes/disk-cap/tasks.md +0 -19
- package/openspec/changes/proxy-observability/.openspec.yaml +0 -2
- package/openspec/changes/proxy-observability/design.md +0 -38
- package/openspec/changes/proxy-observability/proposal.md +0 -49
- package/openspec/changes/proxy-observability/specs/observability/spec.md +0 -33
- package/openspec/changes/proxy-observability/tasks.md +0 -21
- package/openspec/changes/seek-debounce/.openspec.yaml +0 -0
- package/openspec/changes/seek-debounce/design.md +0 -118
- package/openspec/changes/seek-debounce/proposal.md +0 -59
- package/openspec/changes/seek-debounce/specs/seek-debounce/spec.md +0 -41
- package/openspec/changes/seek-debounce/tasks.md +0 -33
- package/openspec/changes/subtitle-language/.openspec.yaml +0 -2
- package/openspec/changes/subtitle-language/proposal.md +0 -50
- package/openspec/changes/subtitle-language/specs/subtitle-language/spec.md +0 -34
- package/openspec/changes/subtitle-language/tasks.md +0 -26
- package/openspec/changes/track-selection/.openspec.yaml +0 -2
- package/openspec/changes/track-selection/design.md +0 -47
- package/openspec/changes/track-selection/proposal.md +0 -45
- package/openspec/changes/track-selection/specs/track-selection/spec.md +0 -41
- package/openspec/changes/track-selection/tasks.md +0 -20
- package/openspec/changes/transcode-quality/.openspec.yaml +0 -2
- package/openspec/changes/transcode-quality/proposal.md +0 -51
- package/openspec/changes/transcode-quality/specs/transcode-quality/spec.md +0 -139
- package/openspec/changes/transcode-quality/tasks.md +0 -63
- package/openspec/config.yaml +0 -38
- package/public/.well-known/appspecific/com.chrome.devtools.json +0 -1
- package/research/delivery-wedge-stand-ladder-2026-09-13.md +0 -329
- package/research/double-spawn-2026-09-10.md +0 -171
- package/research/handover-2026-09-13.md +0 -209
- package/research/handover-reader-claims-removal-2026-09-12.md +0 -166
- package/research/piece-withdrawn-but-still-claimed-2026-09-12.md +0 -175
- package/research/preset-benchmark-size-scaling-2026-08-22.md +0 -55
- package/research/priority-map-is-the-truth-2026-09-12.md +0 -225
- package/research/valgrind-replica-2026-08-27/logs.tar.gz +0 -0
- package/scripts/build-audio-samples.mjs +0 -31
- package/scripts/render-run-graph.js +0 -173
- package/test/asset-paths.test.js +0 -28
- package/test/audio-buffer-continuity.test.js +0 -77
- package/test/audio-calibration.test.js +0 -23
- package/test/audio-inventory.test.js +0 -212
- package/test/audio-track-bitrate.test.js +0 -40
- package/test/audio-warm-recorded.test.js +0 -63
- package/test/auto-quality-step.test.js +0 -762
- package/test/available-share.test.js +0 -76
- package/test/background-fill.test.js +0 -190
- package/test/client-log-file.test.js +0 -126
- package/test/client-logs-route.test.js +0 -34
- package/test/coalesce.test.js +0 -39
- package/test/completed-files.test.js +0 -115
- package/test/concurrent-cost.test.js +0 -148
- package/test/container-media-info.test.js +0 -228
- package/test/contention.test.js +0 -76
- package/test/core-dumps.test.js +0 -57
- package/test/coverage-follows-the-disk.test.js +0 -233
- package/test/coverage-map.test.js +0 -195
- package/test/cue-push-carries-what-the-walk-found.test.js +0 -58
- package/test/cut-times-timeline.test.js +0 -65
- package/test/cuts-follow-published-grid.test.js +0 -109
- package/test/data-channel-frame.test.js +0 -63
- package/test/data-channel-viewer-lifecycle.test.js +0 -193
- package/test/dead-torrent-handle.test.js +0 -52
- package/test/declared-rates.test.js +0 -116
- package/test/declared-tracks.test.js +0 -43
- package/test/decode-cost-fit.test.js +0 -202
- package/test/decode-cost.test.js +0 -475
- package/test/delivery-probe-field.test.js +0 -173
- package/test/delivery-probe.test.js +0 -382
- package/test/demand-register.test.js +0 -206
- package/test/dht-bootstrap.test.js +0 -72
- package/test/drain-threat.test.js +0 -65
- package/test/duplicate-add.test.js +0 -48
- package/test/encode-admission.test.js +0 -170
- package/test/encode-cost.test.js +0 -275
- package/test/encode-exit.test.js +0 -111
- package/test/encode-orchestrator.test.js +0 -426
- package/test/encode-plan-viewers.test.js +0 -725
- package/test/encode-plan.test.js +0 -545
- package/test/encode-run-state.test.js +0 -314
- package/test/encode-run.test.js +0 -248
- package/test/encode-slope.test.js +0 -46
- package/test/encoded-output.test.js +0 -39
- package/test/encoder-kinds.test.js +0 -122
- package/test/encoder-readings.test.js +0 -68
- package/test/episode-naming.test.js +0 -131
- package/test/every-claimant-is-told-its-share.test.js +0 -152
- package/test/failed-encoder-still-serves-what-exists.test.js +0 -354
- package/test/failed-start-breaker.test.js +0 -202
- package/test/fastest-wires.test.js +0 -143
- package/test/ffmpeg-stream-counts.test.js +0 -101
- package/test/file-edges.test.js +0 -191
- package/test/files-in-use.test.js +0 -34
- package/test/fixtures/audio-frame-boundary.json +0 -1
- package/test/fixtures/refused-audio-20261002.json +0 -10
- package/test/fmp4-presentation-clock.test.js +0 -148
- package/test/fmp4-self-contained.test.js +0 -80
- package/test/fmp4-timestamps.test.js +0 -140
- package/test/fmp4-track-completeness.test.js +0 -41
- package/test/format-keyed-outputs.test.js +0 -78
- package/test/health-metrics.test.js +0 -36
- package/test/held-read-ownership.test.js +0 -77
- package/test/held-request-width.test.js +0 -157
- package/test/helpers/encode-run.js +0 -248
- package/test/helpers/held-file.js +0 -77
- package/test/helpers/manager.js +0 -62
- package/test/helpers/matroska-file.js +0 -296
- package/test/helpers/output-spec.js +0 -63
- package/test/host-load.test.js +0 -68
- package/test/index-accuracy-is-about-the-file.test.js +0 -128
- package/test/init-compat.test.js +0 -219
- package/test/input-lost-quiets-the-plan.test.js +0 -261
- package/test/input-unavailable.test.js +0 -48
- package/test/installation-id.test.js +0 -39
- package/test/keeping-period.test.js +0 -83
- package/test/keyframe-index-accuracy.test.js +0 -188
- package/test/keyframe-table-budget.test.js +0 -123
- package/test/keyframes-belong-to-the-file.test.js +0 -249
- package/test/learned-median.test.js +0 -37
- package/test/letting-go-asks-who-is-watching.test.js +0 -191
- package/test/limit-row-by-area.test.js +0 -60
- package/test/link-budget.test.js +0 -111
- package/test/link-probe.test.js +0 -56
- package/test/local-encoding-data.test.js +0 -273
- package/test/logger-repeats.test.js +0 -134
- package/test/look-ahead-coverage.test.js +0 -56
- package/test/manager-surface.test.js +0 -291
- package/test/matroska-blocks.test.js +0 -0
- package/test/matroska-cluster-discovery.test.js +0 -323
- package/test/matroska-cues-track.test.js +0 -192
- package/test/media-time.test.js +0 -62
- package/test/memory-budget.test.js +0 -390
- package/test/move-cost.test.js +0 -216
- package/test/mp4-composition-times.test.js +0 -0
- package/test/mp4-subtitles.test.js +0 -173
- package/test/one-authority.test.js +0 -285
- package/test/one-budget.test.js +0 -149
- package/test/one-output-one-session.test.js +0 -273
- package/test/one-resource-divided.test.js +0 -185
- package/test/one-serving-output-per-height.test.js +0 -458
- package/test/orchestrator-wired.test.js +0 -207
- package/test/output-catalog.test.js +0 -39
- package/test/output-shape.test.js +0 -21
- package/test/output-spec.test.js +0 -251
- package/test/output-speed.test.js +0 -92
- package/test/outputs-being-prepared.test.js +0 -40
- package/test/packet-witness-ring.test.js +0 -236
- package/test/packet-witness.test.js +0 -148
- package/test/piece-completeness.test.js +0 -78
- package/test/piece-disk-store.test.js +0 -401
- package/test/piece-from-whole-file.test.js +0 -129
- package/test/piece-lru.test.js +0 -319
- package/test/piece-reader.test.js +0 -162
- package/test/piece-selection-offset.test.js +0 -85
- package/test/piece-store-eviction.test.js +0 -595
- package/test/piece-store-never-refuses.test.js +0 -153
- package/test/piece-store-reservations.test.js +0 -403
- package/test/piece-store-slow-disk.test.js +0 -159
- package/test/piece-tail.test.js +0 -97
- package/test/plan-host-timings.test.js +0 -68
- package/test/plan-is-steady.test.js +0 -225
- package/test/playback-readiness.test.js +0 -518
- package/test/playback-start-regressions.test.js +0 -101
- package/test/priority-map-download.test.js +0 -174
- package/test/priority-map-emptied.test.js +0 -204
- package/test/priority-map-per-output.test.js +0 -215
- package/test/priority-map.test.js +0 -163
- package/test/probe-wedge-certainty.test.js +0 -60
- package/test/produced-copy-choice.test.js +0 -213
- package/test/published-timeline.test.js +0 -83
- package/test/quality-offer.test.js +0 -160
- package/test/quality-variants.test.js +0 -1274
- package/test/rate-control-in-the-output.test.js +0 -181
- package/test/read-survives-withdrawal.test.js +0 -164
- package/test/read-window.test.js +0 -365
- package/test/reads-not-yet-arrived.test.js +0 -218
- package/test/resume-warm.test.js +0 -39
- package/test/run-graph-drift.test.js +0 -37
- package/test/run-inputs.test.js +0 -80
- package/test/run-intervals.test.js +0 -100
- package/test/run-position-follows-published-grid.test.js +0 -89
- package/test/run-progress.test.js +0 -64
- package/test/same-height-switch.test.js +0 -663
- package/test/seek-frees-the-viewers-requests.test.js +0 -217
- package/test/seek-landing.test.js +0 -109
- package/test/seek-target-not-superseded.test.js +0 -195
- package/test/segment-closed-on-both-branches.test.js +0 -114
- package/test/segment-cut-times.test.js +0 -63
- package/test/segment-demand.test.js +0 -80
- package/test/segment-hold-supersede.test.js +0 -91
- package/test/segment-judged-by-its-own-header.test.js +0 -222
- package/test/segment-serve-wiring.test.js +0 -481
- package/test/segment-store-eviction.test.js +0 -247
- package/test/segment-store.test.js +0 -352
- package/test/segment-true-start.test.js +0 -86
- package/test/segments-are-shared.test.js +0 -176
- package/test/send-chunk-bytes.test.js +0 -86
- package/test/serving-existing-output.test.js +0 -111
- package/test/serving-output.test.js +0 -102
- package/test/shared-piece-store.test.js +0 -310
- package/test/sidecar-naming.test.js +0 -142
- package/test/soundtrack-rate-bound.test.js +0 -289
- package/test/source-file.test.js +0 -133
- package/test/source-files-route.test.js +0 -113
- package/test/source-registry.test.js +0 -18
- package/test/split-a-stretch.test.js +0 -139
- package/test/stale-request-after-seek.test.js +0 -158
- package/test/startup-readings.test.js +0 -124
- package/test/stream-route.test.js +0 -237
- package/test/subtitle-cue-framing.test.js +0 -200
- package/test/subtitle-cue-source.test.js +0 -102
- package/test/subtitle-cue-walk.test.js +0 -385
- package/test/subtitle-cursor.test.js +0 -63
- package/test/subtitle-defaults.test.js +0 -118
- package/test/subtitle-language.test.js +0 -252
- package/test/subtitle-metadata.test.js +0 -15
- package/test/subtitle-plan-waits.test.js +0 -125
- package/test/subtitle-track-numbering.test.js +0 -391
- package/test/supply-margin.test.js +0 -190
- package/test/swarm-follows-readers.test.js +0 -174
- package/test/swarm-reach.test.js +0 -130
- package/test/swarm-selection.test.js +0 -220
- package/test/tail-duplication.test.js +0 -167
- package/test/the-channel-has-both-ends.test.js +0 -91
- package/test/the-torrent-thread-serves-bytes.test.js +0 -107
- package/test/thread-pool.test.js +0 -53
- package/test/timeline.test.js +0 -84
- package/test/torrent-contents.test.js +0 -235
- package/test/torrent-cost.test.js +0 -71
- package/test/torrent-files.test.js +0 -221
- package/test/torrent-naming.test.js +0 -255
- package/test/tracks-begin-together.test.js +0 -209
- package/test/tunnel-renewal.test.js +0 -167
- package/test/two-viewers-one-picture.test.js +0 -508
- package/test/upload-hurry.test.js +0 -186
- package/test/usrsctp-state.test.js +0 -131
- package/test/video-facts.test.js +0 -102
- package/test/viewer-assignments.test.js +0 -143
- package/test/viewer-outputs.test.js +0 -285
- package/test/viewer-presence.test.js +0 -116
- package/test/viewer-requests-admission.test.js +0 -92
- package/test/viewer-starts-on-map.test.js +0 -27
- package/test/viewer-states.test.js +0 -192
- package/test/viewer-subtitle-subscription.test.js +0 -96
- package/test/viewer.test.js +0 -139
- package/test/viewing-generations.test.js +0 -390
- package/test/visible-rung.test.js +0 -37
- package/test/wait-ledger.test.js +0 -100
- package/test/webrtc-shim.test.js +0 -149
- package/test/wedge-certainty.test.js +0 -131
- package/test/whole-file-held-read.test.js +0 -30
- package/test/withdraw-piece-claim.test.js +0 -212
- package/test/worker-channel.test.js +0 -158
package/README.md
CHANGED
|
@@ -309,18 +309,29 @@ npm start -- --server-url http://localhost:3000
|
|
|
309
309
|
|
|
310
310
|
## Docker
|
|
311
311
|
|
|
312
|
+
The image holds the npm package (built from `npm pack`, so `files` in
|
|
313
|
+
`package.json` decides its contents), its production dependencies, node and
|
|
314
|
+
ffmpeg. It starts the proxy on port 9090 with the image's ffmpeg and keeps its
|
|
315
|
+
state in `/data`; arguments after the image name are passed to the proxy.
|
|
316
|
+
|
|
312
317
|
```bash
|
|
313
318
|
docker build -t torrent-tv-proxy .
|
|
314
|
-
docker run torrent-tv-proxy --server-url
|
|
319
|
+
docker run --network host -v ttv-proxy:/data torrent-tv-proxy --server-url https://webauth.courses
|
|
315
320
|
```
|
|
316
321
|
|
|
322
|
+
WebRTC uses UDP port 9090 beside the HTTP API on TCP 9090, and UPnP mapping
|
|
323
|
+
needs the host's own address, so host networking is the supported setup.
|
|
324
|
+
|
|
317
325
|
Without `--log-file` the log is only in `docker logs`, which recreating the
|
|
318
|
-
container deletes. To keep it,
|
|
326
|
+
container deletes. To keep it, write it to the volume:
|
|
319
327
|
|
|
320
328
|
```bash
|
|
321
|
-
docker run -v ttv-proxy
|
|
329
|
+
docker run --network host -v ttv-proxy:/data torrent-tv-proxy --server-url https://webauth.courses --log-file /data/proxy.log
|
|
322
330
|
```
|
|
323
331
|
|
|
332
|
+
The image has no tcpdump and no gdb, and it runs as an unprivileged user, so
|
|
333
|
+
packet captures and `--usrsctp-state` readings are not taken there.
|
|
334
|
+
|
|
324
335
|
## Full End-to-End Flow
|
|
325
336
|
|
|
326
337
|
```mermaid
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@torrent-tv/proxy",
|
|
3
|
-
"version": "2.89.
|
|
3
|
+
"version": "2.89.19",
|
|
4
4
|
"description": "Torrent proxy client that exposes webseed-like HTTP stream endpoint.",
|
|
5
5
|
"license": "GPL-3.0-or-later",
|
|
6
6
|
"repository": {
|
|
@@ -17,6 +17,15 @@
|
|
|
17
17
|
"bin": {
|
|
18
18
|
"torrent-tv-proxy": "bin/cli.js"
|
|
19
19
|
},
|
|
20
|
+
"files": [
|
|
21
|
+
"assets/",
|
|
22
|
+
"bin/",
|
|
23
|
+
"routes/",
|
|
24
|
+
"services/",
|
|
25
|
+
"store/",
|
|
26
|
+
"utils/",
|
|
27
|
+
"server.js"
|
|
28
|
+
],
|
|
20
29
|
"scripts": {
|
|
21
30
|
"start": "node ./bin/cli.js",
|
|
22
31
|
"dev": "node --inspect=0 --experimental-network-inspection ./bin/cli.js",
|
|
@@ -27,7 +36,6 @@
|
|
|
27
36
|
"dependencies": {
|
|
28
37
|
"@fastify/cors": "^11.2.0",
|
|
29
38
|
"@fastify/helmet": "^13.0.2",
|
|
30
|
-
"@fastify/static": "^10.1.2",
|
|
31
39
|
"@silentbot1/nat-api": "^0.4.9",
|
|
32
40
|
"chalk": "^5.4.1",
|
|
33
41
|
"commander": "^12.1.0",
|
package/server.js
CHANGED
|
@@ -9,11 +9,8 @@
|
|
|
9
9
|
import Fastify from "fastify";
|
|
10
10
|
import fastifyCors from "@fastify/cors";
|
|
11
11
|
import fastifyHelmet from "@fastify/helmet";
|
|
12
|
-
import fastifyStatic from "@fastify/static";
|
|
13
12
|
import getPort from "get-port";
|
|
14
|
-
import path from "node:path";
|
|
15
13
|
import { createRequire } from "node:module";
|
|
16
|
-
import { fileURLToPath } from "node:url";
|
|
17
14
|
import { handleHealthGet } from "./routes/health/get.js";
|
|
18
15
|
import { handleHealthzGet } from "./routes/healthz/get.js";
|
|
19
16
|
import { handleApiDeliverySinkGet } from "./routes/api/delivery-sink/get.js";
|
|
@@ -64,11 +61,8 @@ import { benchmarkAudio } from "./services/encode/audio-calibration.js";
|
|
|
64
61
|
import { logger } from "./utils/logger.js";
|
|
65
62
|
import { completedFilesRoot } from "./services/storage/files/CompletedFiles.js";
|
|
66
63
|
|
|
67
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
68
|
-
const __dirname = path.dirname(__filename);
|
|
69
64
|
const require = createRequire(import.meta.url);
|
|
70
65
|
const { version } = require("./package.json");
|
|
71
|
-
const publicRoot = path.resolve(__dirname, "./public");
|
|
72
66
|
|
|
73
67
|
/**
|
|
74
68
|
* Build a list of candidate port numbers starting at `startPort`.
|
|
@@ -714,11 +708,6 @@ export async function startProxyServer({
|
|
|
714
708
|
app.get("/transcode/:sessionId/v/:height/:fileName", async (req, reply) =>
|
|
715
709
|
handleTranscodeVariantFileGet(req, reply, { renditions: outputParts.renditions, serving: outputParts.serving, viewerRequests: outputParts.viewerRequests })
|
|
716
710
|
);
|
|
717
|
-
await app.register(fastifyStatic, {
|
|
718
|
-
root: publicRoot,
|
|
719
|
-
prefix: "/",
|
|
720
|
-
serveDotFiles: true
|
|
721
|
-
});
|
|
722
711
|
|
|
723
712
|
app.addHook("onClose", async () => {
|
|
724
713
|
// Order matters: stop the ffmpeg readers (HLS sessions) before destroying
|
package/utils/client-log-file.js
CHANGED
|
@@ -9,11 +9,12 @@
|
|
|
9
9
|
* the evidence for exactly this reason.
|
|
10
10
|
*
|
|
11
11
|
* Written here instead, next to the proxy's own log, on the same durable
|
|
12
|
-
* directory (`/data` on the addon host). One file per viewing session
|
|
13
|
-
* the two halves join without guessing: the session's start,
|
|
12
|
+
* directory (`/data` on the addon host). One file per viewing session and
|
|
13
|
+
* torrent, named so the two halves join without guessing: the session's start,
|
|
14
|
+
* then the torrent.
|
|
14
15
|
*/
|
|
15
16
|
|
|
16
|
-
import { createWriteStream, mkdirSync,
|
|
17
|
+
import { createWriteStream, fstatSync, mkdirSync, openSync, renameSync } from "node:fs";
|
|
17
18
|
import { dirname, join } from "node:path";
|
|
18
19
|
|
|
19
20
|
/**
|
|
@@ -82,45 +83,106 @@ function stamp(iso) {
|
|
|
82
83
|
*
|
|
83
84
|
* @param {string} proxyLogPath - The proxy's own log file; its directory is
|
|
84
85
|
* used, so the two halves are always side by side.
|
|
85
|
-
* @returns {{ write: (session: object, lines: string[]) => void, close: () => void }}
|
|
86
|
+
* @returns {{ write: (session: object, lines: string[]) => void, close: () => Promise<void> }}
|
|
86
87
|
*/
|
|
87
88
|
export function createClientLogFiles(proxyLogPath) {
|
|
88
89
|
const directory = typeof proxyLogPath === "string" && proxyLogPath.length > 0
|
|
89
90
|
? dirname(proxyLogPath)
|
|
90
91
|
: "";
|
|
91
|
-
/**
|
|
92
|
+
/**
|
|
93
|
+
* @typedef {object} OpenFile
|
|
94
|
+
* @property {import("node:fs").WriteStream} stream
|
|
95
|
+
* @property {string} path
|
|
96
|
+
* @property {number} bytes
|
|
97
|
+
* @property {string} prefix - `client-<start>-<session>`, the part every file
|
|
98
|
+
* of one session shares, so they are found together.
|
|
99
|
+
* @property {string} film - Which torrent the name carries; empty while it
|
|
100
|
+
* still says `no-torrent-yet`.
|
|
101
|
+
*/
|
|
102
|
+
/** @type {Map<string, OpenFile>} */
|
|
92
103
|
const open = new Map();
|
|
104
|
+
/**
|
|
105
|
+
* Files taken out of `open` whose last lines are still being flushed: a
|
|
106
|
+
* rotated file, and the file of a film the session has moved away from.
|
|
107
|
+
*
|
|
108
|
+
* @type {Set<Promise<void>>}
|
|
109
|
+
*/
|
|
110
|
+
const ending = new Set();
|
|
93
111
|
|
|
94
112
|
/**
|
|
95
|
-
*
|
|
113
|
+
* Finish a file that is no longer written to, and remember the wait so that
|
|
114
|
+
* `close()` does not return before its last lines are on disk.
|
|
96
115
|
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
|
|
100
|
-
|
|
116
|
+
* @param {OpenFile} record
|
|
117
|
+
* @returns {void}
|
|
118
|
+
*/
|
|
119
|
+
function finish(record) {
|
|
120
|
+
const done = new Promise((resolve) => {
|
|
121
|
+
try {
|
|
122
|
+
record.stream.end(() => resolve(undefined));
|
|
123
|
+
} catch {
|
|
124
|
+
// A stream that cannot be ended has nothing left to flush.
|
|
125
|
+
resolve(undefined);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
ending.add(done);
|
|
129
|
+
void done.then(() => ending.delete(done));
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Which torrent a batch names, or empty when none is chosen yet.
|
|
101
134
|
*
|
|
102
|
-
* @param {{
|
|
103
|
-
* @returns {
|
|
135
|
+
* @param {{ torrentName: string, infoHash: string }} session
|
|
136
|
+
* @returns {string}
|
|
104
137
|
*/
|
|
105
|
-
function
|
|
106
|
-
if (!
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
138
|
+
function filmOf(session) {
|
|
139
|
+
if (!session.torrentName) return "";
|
|
140
|
+
return session.infoHash || session.torrentName;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* @param {string} prefix
|
|
145
|
+
* @param {{ torrentName: string, infoHash: string }} session
|
|
146
|
+
* @returns {string}
|
|
147
|
+
*/
|
|
148
|
+
function pathFor(prefix, session) {
|
|
110
149
|
const film = session.torrentName
|
|
111
150
|
? `${safeName(session.torrentName, 60)}-${safeName(session.infoHash, 8)}`
|
|
112
151
|
: "no-torrent-yet";
|
|
113
|
-
|
|
152
|
+
return join(directory, `${prefix}-${film}.log`);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Open a file for appending.
|
|
157
|
+
*
|
|
158
|
+
* The descriptor is opened synchronously and handed to the stream, so the
|
|
159
|
+
* file exists under its path before this returns. A stream that opens its
|
|
160
|
+
* own file does so later, and a rename made in between would leave the
|
|
161
|
+
* stream creating a second file under the old name.
|
|
162
|
+
*
|
|
163
|
+
* @param {string} key
|
|
164
|
+
* @param {string} prefix
|
|
165
|
+
* @param {{ torrentName: string, infoHash: string }} session
|
|
166
|
+
* @returns {OpenFile | null}
|
|
167
|
+
*/
|
|
168
|
+
function openFile(key, prefix, session) {
|
|
169
|
+
const path = pathFor(prefix, session);
|
|
114
170
|
try {
|
|
115
171
|
mkdirSync(directory, { recursive: true });
|
|
172
|
+
const fd = openSync(path, "a");
|
|
173
|
+
/** @type {OpenFile} */
|
|
116
174
|
const record = {
|
|
117
|
-
stream: createWriteStream(path, {
|
|
175
|
+
stream: createWriteStream(path, { fd }),
|
|
118
176
|
path,
|
|
119
|
-
bytes:
|
|
177
|
+
bytes: fstatSync(fd).size,
|
|
178
|
+
prefix,
|
|
179
|
+
film: filmOf(session)
|
|
120
180
|
};
|
|
121
181
|
// A file that stops being writable must not take the proxy down with it,
|
|
122
182
|
// and must not be retried on every line.
|
|
123
|
-
record.stream.on("error", () =>
|
|
183
|
+
record.stream.on("error", () => {
|
|
184
|
+
if (open.get(key) === record) open.delete(key);
|
|
185
|
+
});
|
|
124
186
|
open.set(key, record);
|
|
125
187
|
return record;
|
|
126
188
|
} catch {
|
|
@@ -128,6 +190,51 @@ export function createClientLogFiles(proxyLogPath) {
|
|
|
128
190
|
}
|
|
129
191
|
}
|
|
130
192
|
|
|
193
|
+
/**
|
|
194
|
+
* The file for this session, opened on first use.
|
|
195
|
+
*
|
|
196
|
+
* Keyed by the session's own id rather than by the name. The first batch
|
|
197
|
+
* always arrives before a torrent is chosen, and the lines it carries — the
|
|
198
|
+
* page opening, the proxy being chosen, a connection failing — belong to the
|
|
199
|
+
* film the session goes on to play. So the file is RENAMED when the first
|
|
200
|
+
* torrent arrives, and those lines stay in it.
|
|
201
|
+
*
|
|
202
|
+
* A different torrent chosen later in the same page starts a file of its
|
|
203
|
+
* own under the same prefix: renaming again would leave the first film's
|
|
204
|
+
* lines under the second film's name, where nobody looking for the first
|
|
205
|
+
* film finds them.
|
|
206
|
+
*
|
|
207
|
+
* @param {{ sessionId: string, startedAt: string, torrentName: string, infoHash: string }} session
|
|
208
|
+
* @returns {OpenFile | null}
|
|
209
|
+
*/
|
|
210
|
+
function fileFor(session) {
|
|
211
|
+
if (!directory) return null;
|
|
212
|
+
const key = session.sessionId;
|
|
213
|
+
const film = filmOf(session);
|
|
214
|
+
const existing = open.get(key);
|
|
215
|
+
if (!existing) {
|
|
216
|
+
const prefix = `client-${stamp(session.startedAt)}-${safeName(session.sessionId, 8)}`;
|
|
217
|
+
return openFile(key, prefix, session);
|
|
218
|
+
}
|
|
219
|
+
if (film === "" || film === existing.film) return existing;
|
|
220
|
+
if (existing.film === "") {
|
|
221
|
+
const path = pathFor(existing.prefix, session);
|
|
222
|
+
try {
|
|
223
|
+
renameSync(existing.path, path);
|
|
224
|
+
existing.path = path;
|
|
225
|
+
} catch {
|
|
226
|
+
// The lines keep going to the file under its old name; a name that
|
|
227
|
+
// cannot change is better than a session's log lost to an exception.
|
|
228
|
+
}
|
|
229
|
+
// Set even when the rename failed, so it is not retried on every batch.
|
|
230
|
+
existing.film = film;
|
|
231
|
+
return existing;
|
|
232
|
+
}
|
|
233
|
+
open.delete(key);
|
|
234
|
+
finish(existing);
|
|
235
|
+
return openFile(key, existing.prefix, session);
|
|
236
|
+
}
|
|
237
|
+
|
|
131
238
|
return {
|
|
132
239
|
write(session, lines) {
|
|
133
240
|
const record = fileFor(session);
|
|
@@ -138,40 +245,38 @@ export function createClientLogFiles(proxyLogPath) {
|
|
|
138
245
|
record.stream.write(text);
|
|
139
246
|
}
|
|
140
247
|
if (record.bytes >= MAX_BYTES) {
|
|
248
|
+
// Renamed before it is ended: the stream writes through its own
|
|
249
|
+
// descriptor, so the lines still in flight follow the file to its new
|
|
250
|
+
// name, and the next batch opens a fresh file under the old one
|
|
251
|
+
// instead of appending to the file that is about to be moved.
|
|
141
252
|
try {
|
|
142
|
-
record.
|
|
143
|
-
try {
|
|
144
|
-
renameSync(record.path, `${record.path}.1`);
|
|
145
|
-
} catch {
|
|
146
|
-
// Renaming a file that has gone leaves nothing to do.
|
|
147
|
-
}
|
|
148
|
-
});
|
|
253
|
+
renameSync(record.path, `${record.path}.1`);
|
|
149
254
|
} catch {
|
|
150
|
-
// A rotation that cannot happen leaves the file growing
|
|
151
|
-
// better than losing the session's log
|
|
255
|
+
// A rotation that cannot happen leaves the file growing under its
|
|
256
|
+
// name, which is better than losing the session's log. It is tried
|
|
257
|
+
// again after as much again, not on every batch.
|
|
258
|
+
record.bytes = 0;
|
|
259
|
+
return;
|
|
152
260
|
}
|
|
153
|
-
open.delete(session.sessionId);
|
|
261
|
+
if (open.get(session.sessionId) === record) open.delete(session.sessionId);
|
|
262
|
+
finish(record);
|
|
154
263
|
}
|
|
155
264
|
},
|
|
156
265
|
/**
|
|
157
266
|
* Finish every open file.
|
|
158
267
|
*
|
|
159
|
-
* Awaitable, and that is not a convenience: a write stream
|
|
160
|
-
*
|
|
161
|
-
*
|
|
268
|
+
* Awaitable, and that is not a convenience: a write stream flushes
|
|
269
|
+
* asynchronously, so a process that ends without waiting loses the last
|
|
270
|
+
* lines of every session — which are the ones a crash is explained by.
|
|
271
|
+
* That includes the files already set aside by a rotation or by a change
|
|
272
|
+
* of film.
|
|
162
273
|
*
|
|
163
274
|
* @returns {Promise<void>}
|
|
164
275
|
*/
|
|
165
276
|
async close() {
|
|
166
|
-
const
|
|
167
|
-
try {
|
|
168
|
-
record.stream.end(resolve);
|
|
169
|
-
} catch {
|
|
170
|
-
resolve(undefined);
|
|
171
|
-
}
|
|
172
|
-
}));
|
|
277
|
+
for (const record of open.values()) finish(record);
|
|
173
278
|
open.clear();
|
|
174
|
-
await Promise.all(ending);
|
|
279
|
+
await Promise.all([...ending]);
|
|
175
280
|
}
|
|
176
281
|
};
|
|
177
282
|
}
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: "OPSX: Apply"
|
|
3
|
-
description: Implement tasks from an OpenSpec change (Experimental)
|
|
4
|
-
category: Workflow
|
|
5
|
-
tags: [workflow, artifacts, experimental]
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
Implement tasks from an OpenSpec change.
|
|
9
|
-
|
|
10
|
-
**Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`). Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root.
|
|
11
|
-
|
|
12
|
-
**Input**: Optionally specify a change name (e.g., `/opsx:apply add-auth`). If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
|
|
13
|
-
|
|
14
|
-
**Steps**
|
|
15
|
-
|
|
16
|
-
1. **Select the change**
|
|
17
|
-
|
|
18
|
-
If a name is provided, use it. Otherwise:
|
|
19
|
-
- Infer from conversation context if the user mentioned a change
|
|
20
|
-
- Auto-select if only one active change exists
|
|
21
|
-
- If ambiguous, run `openspec list --json` to get available changes and use the **AskUserQuestion tool** to let the user select
|
|
22
|
-
|
|
23
|
-
Always announce: "Using change: <name>" and how to override (e.g., `/opsx:apply <other>`).
|
|
24
|
-
|
|
25
|
-
2. **Check status to understand the schema**
|
|
26
|
-
```bash
|
|
27
|
-
openspec status --change "<name>" --json
|
|
28
|
-
```
|
|
29
|
-
Parse the JSON to understand:
|
|
30
|
-
- `schemaName`: The workflow being used (e.g., "spec-driven")
|
|
31
|
-
- `planningHome`, `changeRoot`, and `actionContext`: planning scope and edit constraints
|
|
32
|
-
- Which artifact contains the tasks (typically "tasks" for spec-driven, check status for others)
|
|
33
|
-
|
|
34
|
-
3. **Get apply instructions**
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
openspec instructions apply --change "<name>" --json
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
This returns:
|
|
41
|
-
- `contextFiles`: artifact ID -> array of concrete file paths (varies by schema)
|
|
42
|
-
- Progress (total, complete, remaining)
|
|
43
|
-
- Task list with status
|
|
44
|
-
- Dynamic instruction based on current state
|
|
45
|
-
|
|
46
|
-
**Handle states:**
|
|
47
|
-
- If `state: "blocked"` (missing artifacts): show message, suggest using `/opsx:continue`
|
|
48
|
-
- If `state: "all_done"`: congratulate, suggest archive
|
|
49
|
-
- Otherwise: proceed to implementation
|
|
50
|
-
|
|
51
|
-
4. **Read context files**
|
|
52
|
-
|
|
53
|
-
Read every file path listed under `contextFiles` from the apply instructions output.
|
|
54
|
-
The files depend on the schema being used:
|
|
55
|
-
- **spec-driven**: proposal, specs, design, tasks
|
|
56
|
-
- Other schemas: follow the contextFiles from CLI output
|
|
57
|
-
|
|
58
|
-
5. **Show current progress**
|
|
59
|
-
|
|
60
|
-
Display:
|
|
61
|
-
- Schema being used
|
|
62
|
-
- Progress: "N/M tasks complete"
|
|
63
|
-
- Remaining tasks overview
|
|
64
|
-
- Dynamic instruction from CLI
|
|
65
|
-
|
|
66
|
-
6. **Implement tasks (loop until done or blocked)**
|
|
67
|
-
|
|
68
|
-
For each pending task:
|
|
69
|
-
- Show which task is being worked on
|
|
70
|
-
- Make the code changes required
|
|
71
|
-
- Keep changes minimal and focused
|
|
72
|
-
- Mark task complete in the tasks file: `- [ ]` → `- [x]`
|
|
73
|
-
- Continue to next task
|
|
74
|
-
|
|
75
|
-
**Pause if:**
|
|
76
|
-
- Task is unclear → ask for clarification
|
|
77
|
-
- Implementation reveals a design issue → suggest updating artifacts
|
|
78
|
-
- Error or blocker encountered → report and wait for guidance
|
|
79
|
-
- User interrupts
|
|
80
|
-
|
|
81
|
-
7. **On completion or pause, show status**
|
|
82
|
-
|
|
83
|
-
Display:
|
|
84
|
-
- Tasks completed this session
|
|
85
|
-
- Overall progress: "N/M tasks complete"
|
|
86
|
-
- If all done: suggest archive
|
|
87
|
-
- If paused: explain why and wait for guidance
|
|
88
|
-
|
|
89
|
-
**Output During Implementation**
|
|
90
|
-
|
|
91
|
-
```
|
|
92
|
-
## Implementing: <change-name> (schema: <schema-name>)
|
|
93
|
-
|
|
94
|
-
Working on task 3/7: <task description>
|
|
95
|
-
[...implementation happening...]
|
|
96
|
-
✓ Task complete
|
|
97
|
-
|
|
98
|
-
Working on task 4/7: <task description>
|
|
99
|
-
[...implementation happening...]
|
|
100
|
-
✓ Task complete
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
**Output On Completion**
|
|
104
|
-
|
|
105
|
-
```
|
|
106
|
-
## Implementation Complete
|
|
107
|
-
|
|
108
|
-
**Change:** <change-name>
|
|
109
|
-
**Schema:** <schema-name>
|
|
110
|
-
**Progress:** 7/7 tasks complete ✓
|
|
111
|
-
|
|
112
|
-
### Completed This Session
|
|
113
|
-
- [x] Task 1
|
|
114
|
-
- [x] Task 2
|
|
115
|
-
...
|
|
116
|
-
|
|
117
|
-
All tasks complete! You can archive this change with `/opsx:archive`.
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
**Output On Pause (Issue Encountered)**
|
|
121
|
-
|
|
122
|
-
```
|
|
123
|
-
## Implementation Paused
|
|
124
|
-
|
|
125
|
-
**Change:** <change-name>
|
|
126
|
-
**Schema:** <schema-name>
|
|
127
|
-
**Progress:** 4/7 tasks complete
|
|
128
|
-
|
|
129
|
-
### Issue Encountered
|
|
130
|
-
<description of the issue>
|
|
131
|
-
|
|
132
|
-
**Options:**
|
|
133
|
-
1. <option 1>
|
|
134
|
-
2. <option 2>
|
|
135
|
-
3. Other approach
|
|
136
|
-
|
|
137
|
-
What would you like to do?
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
**Guardrails**
|
|
141
|
-
- Keep going through tasks until done or blocked
|
|
142
|
-
- Always read context files before starting (from the apply instructions output)
|
|
143
|
-
- If task is ambiguous, pause and ask before implementing
|
|
144
|
-
- If implementation reveals issues, pause and suggest artifact updates
|
|
145
|
-
- Keep code changes minimal and scoped to each task
|
|
146
|
-
- Update task checkbox immediately after completing each task
|
|
147
|
-
- Pause on errors, blockers, or unclear requirements - don't guess
|
|
148
|
-
- Use contextFiles from CLI output, don't assume specific file names
|
|
149
|
-
|
|
150
|
-
**Fluid Workflow Integration**
|
|
151
|
-
|
|
152
|
-
This skill supports the "actions on a change" model:
|
|
153
|
-
|
|
154
|
-
- **Can be invoked anytime**: Before all artifacts are done (if tasks exist), after partial implementation, interleaved with other actions
|
|
155
|
-
- **Allows artifact updates**: If implementation reveals design issues, suggest updating artifacts - not phase-locked, work fluidly
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: "OPSX: Archive"
|
|
3
|
-
description: Archive a completed change in the experimental workflow
|
|
4
|
-
category: Workflow
|
|
5
|
-
tags: [workflow, archive, experimental]
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
Archive a completed change in the experimental workflow.
|
|
9
|
-
|
|
10
|
-
**Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`). Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root.
|
|
11
|
-
|
|
12
|
-
**Input**: Optionally specify a change name after `/opsx:archive` (e.g., `/opsx:archive add-auth`). If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
|
|
13
|
-
|
|
14
|
-
**Steps**
|
|
15
|
-
|
|
16
|
-
1. **If no change name provided, prompt for selection**
|
|
17
|
-
|
|
18
|
-
Run `openspec list --json` to get available changes. Use the **AskUserQuestion tool** to let the user select.
|
|
19
|
-
|
|
20
|
-
Show only active changes (not already archived).
|
|
21
|
-
Include the schema used for each change if available.
|
|
22
|
-
|
|
23
|
-
**IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose.
|
|
24
|
-
|
|
25
|
-
2. **Check artifact completion status**
|
|
26
|
-
|
|
27
|
-
Run `openspec status --change "<name>" --json` to check artifact completion.
|
|
28
|
-
|
|
29
|
-
Parse the JSON to understand:
|
|
30
|
-
- `schemaName`: The workflow being used
|
|
31
|
-
- `planningHome`, `changeRoot`, `artifactPaths`, and `actionContext`: path and scope context
|
|
32
|
-
- `artifacts`: List of artifacts with their status (`done` or other)
|
|
33
|
-
|
|
34
|
-
**If any artifacts are not `done`:**
|
|
35
|
-
- Display warning listing incomplete artifacts
|
|
36
|
-
- Prompt user for confirmation to continue
|
|
37
|
-
- Proceed if user confirms
|
|
38
|
-
|
|
39
|
-
3. **Check task completion status**
|
|
40
|
-
|
|
41
|
-
Read the tasks file (typically `tasks.md`) to check for incomplete tasks.
|
|
42
|
-
|
|
43
|
-
Count tasks marked with `- [ ]` (incomplete) vs `- [x]` (complete).
|
|
44
|
-
|
|
45
|
-
**If incomplete tasks found:**
|
|
46
|
-
- Display warning showing count of incomplete tasks
|
|
47
|
-
- Prompt user for confirmation to continue
|
|
48
|
-
- Proceed if user confirms
|
|
49
|
-
|
|
50
|
-
**If no tasks file exists:** Proceed without task-related warning.
|
|
51
|
-
|
|
52
|
-
4. **Assess delta spec sync state**
|
|
53
|
-
|
|
54
|
-
Use `artifactPaths.specs.existingOutputPaths` from status JSON to check for delta specs. If none exist, proceed without sync prompt.
|
|
55
|
-
|
|
56
|
-
**If delta specs exist:**
|
|
57
|
-
- Compare each delta spec with its corresponding main spec at `openspec/specs/<capability>/spec.md`
|
|
58
|
-
- Determine what changes would be applied (adds, modifications, removals, renames)
|
|
59
|
-
- Show a combined summary before prompting
|
|
60
|
-
|
|
61
|
-
**Prompt options:**
|
|
62
|
-
- If changes needed: "Sync now (recommended)", "Archive without syncing"
|
|
63
|
-
- If already synced: "Archive now", "Sync anyway", "Cancel"
|
|
64
|
-
|
|
65
|
-
If user chooses sync, use Task tool (subagent_type: "general-purpose", prompt: "Use Skill tool to invoke openspec-sync-specs for change '<name>'. Delta spec analysis: <include the analyzed delta spec summary>"). Proceed to archive regardless of choice.
|
|
66
|
-
|
|
67
|
-
5. **Perform the archive**
|
|
68
|
-
|
|
69
|
-
Create an `archive` directory under `planningHome.changesDir` if it doesn't exist:
|
|
70
|
-
```bash
|
|
71
|
-
mkdir -p "<planningHome.changesDir>/archive"
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
Generate target name using current date: `YYYY-MM-DD-<change-name>`
|
|
75
|
-
|
|
76
|
-
**Check if target already exists:**
|
|
77
|
-
- If yes: Fail with error, suggest renaming existing archive or using different date
|
|
78
|
-
- If no: Move `changeRoot` to the archive directory
|
|
79
|
-
|
|
80
|
-
```bash
|
|
81
|
-
mv "<changeRoot>" "<planningHome.changesDir>/archive/YYYY-MM-DD-<name>"
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
6. **Display summary**
|
|
85
|
-
|
|
86
|
-
Show archive completion summary including:
|
|
87
|
-
- Change name
|
|
88
|
-
- Schema that was used
|
|
89
|
-
- Archive location
|
|
90
|
-
- Spec sync status (synced / sync skipped / no delta specs)
|
|
91
|
-
- Note about any warnings (incomplete artifacts/tasks)
|
|
92
|
-
|
|
93
|
-
**Output On Success**
|
|
94
|
-
|
|
95
|
-
```
|
|
96
|
-
## Archive Complete
|
|
97
|
-
|
|
98
|
-
**Change:** <change-name>
|
|
99
|
-
**Schema:** <schema-name>
|
|
100
|
-
**Archived to:** the archive path derived from `planningHome.changesDir`/YYYY-MM-DD-<name>/
|
|
101
|
-
**Specs:** ✓ Synced to main specs
|
|
102
|
-
|
|
103
|
-
All artifacts complete. All tasks complete.
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
**Output On Success (No Delta Specs)**
|
|
107
|
-
|
|
108
|
-
```
|
|
109
|
-
## Archive Complete
|
|
110
|
-
|
|
111
|
-
**Change:** <change-name>
|
|
112
|
-
**Schema:** <schema-name>
|
|
113
|
-
**Archived to:** the archive path derived from `planningHome.changesDir`/YYYY-MM-DD-<name>/
|
|
114
|
-
**Specs:** No delta specs
|
|
115
|
-
|
|
116
|
-
All artifacts complete. All tasks complete.
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
**Output On Success With Warnings**
|
|
120
|
-
|
|
121
|
-
```
|
|
122
|
-
## Archive Complete (with warnings)
|
|
123
|
-
|
|
124
|
-
**Change:** <change-name>
|
|
125
|
-
**Schema:** <schema-name>
|
|
126
|
-
**Archived to:** the archive path derived from `planningHome.changesDir`/YYYY-MM-DD-<name>/
|
|
127
|
-
**Specs:** Sync skipped (user chose to skip)
|
|
128
|
-
|
|
129
|
-
**Warnings:**
|
|
130
|
-
- Archived with 2 incomplete artifacts
|
|
131
|
-
- Archived with 3 incomplete tasks
|
|
132
|
-
- Delta spec sync was skipped (user chose to skip)
|
|
133
|
-
|
|
134
|
-
Review the archive if this was not intentional.
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
**Output On Error (Archive Exists)**
|
|
138
|
-
|
|
139
|
-
```
|
|
140
|
-
## Archive Failed
|
|
141
|
-
|
|
142
|
-
**Change:** <change-name>
|
|
143
|
-
**Target:** the archive path derived from `planningHome.changesDir`/YYYY-MM-DD-<name>/
|
|
144
|
-
|
|
145
|
-
Target archive directory already exists.
|
|
146
|
-
|
|
147
|
-
**Options:**
|
|
148
|
-
1. Rename the existing archive
|
|
149
|
-
2. Delete the existing archive if it's a duplicate
|
|
150
|
-
3. Wait until a different date to archive
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
**Guardrails**
|
|
154
|
-
- Always prompt for change selection if not provided
|
|
155
|
-
- Use artifact graph (openspec status --json) for completion checking
|
|
156
|
-
- Don't block archive on warnings - just inform and confirm
|
|
157
|
-
- Preserve .openspec.yaml when moving to archive (it moves with the directory)
|
|
158
|
-
- Show clear summary of what happened
|
|
159
|
-
- If sync is requested, use the Skill tool to invoke `openspec-sync-specs` (agent-driven)
|
|
160
|
-
- If delta specs exist, always run the sync assessment and show the combined summary before prompting
|