trajectories 0.0.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -0
- package/LICENSE +201 -0
- package/README.md +288 -2
- package/dist/cli.js +30210 -0
- package/dist/convert.d.ts +31 -0
- package/dist/convert.js +431 -0
- package/dist/deepagents_checkpoint.py +362 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +8402 -0
- package/dist/log-baseline.d.ts +26 -0
- package/dist/log-baseline.js +104 -0
- package/dist/log-content.d.ts +16 -0
- package/dist/log-content.js +80 -0
- package/dist/log-io.d.ts +10 -0
- package/dist/log-io.js +121 -0
- package/dist/log-read.d.ts +24 -0
- package/dist/log-read.js +117 -0
- package/dist/log-reconcile.d.ts +5 -0
- package/dist/log-reconcile.js +38 -0
- package/dist/log-records.d.ts +35 -0
- package/dist/log-records.js +85 -0
- package/dist/log-recovery.d.ts +18 -0
- package/dist/log-recovery.js +123 -0
- package/dist/log-stage.d.ts +14 -0
- package/dist/log-stage.js +138 -0
- package/dist/log-state.d.ts +89 -0
- package/dist/log-state.js +92 -0
- package/dist/log-switch.d.ts +3 -0
- package/dist/log-switch.js +98 -0
- package/dist/log-types.d.ts +129 -0
- package/dist/log-types.js +8 -0
- package/dist/log.d.ts +8 -0
- package/dist/log.js +62 -0
- package/dist/migrate.d.ts +29 -0
- package/dist/migrate.js +173 -0
- package/dist/normalization-runtime.d.ts +1 -0
- package/dist/normalization-runtime.js +3150 -0
- package/dist/portable.d.ts +9 -0
- package/dist/portable.js +26 -0
- package/dist/readers/canonical.d.ts +13 -0
- package/dist/readers/canonical.js +54 -0
- package/dist/readers/cline.d.ts +10 -0
- package/dist/readers/cline.js +107 -0
- package/dist/readers/cursor.d.ts +20 -0
- package/dist/readers/cursor.js +374 -0
- package/dist/readers/deepagents.d.ts +41 -0
- package/dist/readers/deepagents.js +163 -0
- package/dist/readers/fx.d.ts +11 -0
- package/dist/readers/fx.js +573 -0
- package/dist/readers/github-copilot.d.ts +8 -0
- package/dist/readers/github-copilot.js +216 -0
- package/dist/readers/grok-build.d.ts +12 -0
- package/dist/readers/grok-build.js +391 -0
- package/dist/readers/guards.d.ts +4 -0
- package/dist/readers/guards.js +121 -0
- package/dist/readers/pi-compaction.d.ts +7 -0
- package/dist/readers/pi-compaction.js +112 -0
- package/dist/readers/pi-context.d.ts +13 -0
- package/dist/readers/pi-context.js +64 -0
- package/dist/store.d.ts +25 -0
- package/dist/store.js +218 -0
- package/dist/types.d.ts +91 -0
- package/dist/types.js +1 -0
- package/dist/writers/claude-code.d.ts +5 -0
- package/dist/writers/claude-code.js +51 -0
- package/dist/writers/cline.d.ts +3 -0
- package/dist/writers/cline.js +77 -0
- package/dist/writers/codex.d.ts +3 -0
- package/dist/writers/codex.js +32 -0
- package/dist/writers/cursor.d.ts +3 -0
- package/dist/writers/cursor.js +197 -0
- package/dist/writers/deepagents.d.ts +3 -0
- package/dist/writers/deepagents.js +116 -0
- package/dist/writers/entropy.d.ts +5 -0
- package/dist/writers/entropy.js +33 -0
- package/dist/writers/fx.d.ts +3 -0
- package/dist/writers/fx.js +135 -0
- package/dist/writers/github-copilot.d.ts +3 -0
- package/dist/writers/github-copilot.js +71 -0
- package/dist/writers/grok-build.d.ts +3 -0
- package/dist/writers/grok-build.js +43 -0
- package/dist/writers/helpers.d.ts +17 -0
- package/dist/writers/helpers.js +75 -0
- package/dist/writers/omp.d.ts +3 -0
- package/dist/writers/omp.js +7 -0
- package/dist/writers/opencode.d.ts +3 -0
- package/dist/writers/opencode.js +65 -0
- package/dist/writers/pi.d.ts +3 -0
- package/dist/writers/pi.js +45 -0
- package/docs/cline-native-format.md +43 -0
- package/docs/copilot-native-format.md +78 -0
- package/docs/cursor-native-format.md +103 -0
- package/docs/deepagents-native-format.md +98 -0
- package/docs/evidence-api.md +170 -0
- package/docs/fx-native-format.md +87 -0
- package/docs/harness-parity-bootstrap.md +78 -0
- package/docs/harness-support-parity.md +107 -0
- package/docs/inspirations.md +103 -0
- package/docs/ledger-migration.md +141 -0
- package/docs/pi-compaction-context.md +75 -0
- package/docs/pi-provider-context.md +76 -0
- package/docs/research/2026-10-06-huihua-and-oar.md +176 -0
- package/docs/research/ledger/README.md +96 -0
- package/docs/research/ledger/confer/2026-09-13-round-10/README.md +61 -0
- package/docs/research/ledger/confer/2026-09-13-round-2/cass.md +72 -0
- package/docs/research/ledger/confer/2026-09-13-round-3/README.md +70 -0
- package/docs/research/ledger/confer/2026-09-13-round-5/README.md +61 -0
- package/docs/research/ledger/confer/2026-09-13-round-6/README.md +68 -0
- package/docs/research/ledger/confer/2026-09-13-round-7/README.md +64 -0
- package/docs/research/ledger/confer/2026-09-13-round-9/README.md +59 -0
- package/docs/research/ledger/confer/2026-09-14-wake/wake.md +146 -0
- package/docs/research/ledger/docs/inspirations.md +320 -0
- package/docs/research/ledger/docs/pr2-pr6-integration.md +53 -0
- package/docs/research/ledger/docs/research/2026-09-07-confer-inspirations.md +163 -0
- package/docs/research/ledger/docs/research/2026-09-07-letta-continuous-service.md +104 -0
- package/docs/research/ledger/docs/research/2026-09-08-claude-history-retrieval.md +117 -0
- package/docs/research/ledger/docs/research/2026-09-09-agentsview-native-discovery.md +87 -0
- package/docs/research/ledger/docs/research/2026-09-09-daemon-observation.md +231 -0
- package/docs/research/ledger/docs/research/2026-09-09-discovery-pagination.md +114 -0
- package/docs/research/ledger/docs/research/2026-09-09-harness-transcript-contract.md +145 -0
- package/docs/research/ledger/docs/research/2026-09-09-native-history-discovery.md +180 -0
- package/docs/research/ledger/docs/research/2026-09-09-native-history-implementation.md +137 -0
- package/docs/research/ledger/docs/research/2026-09-09-other-inspirations.md +279 -0
- package/docs/research/ledger/docs/research/2026-09-09-trajectory-and-letta-code.md +128 -0
- package/docs/research/ledger/docs/research/2026-09-13-diagnostics-coverage.md +116 -0
- package/docs/research/ledger/docs/research/2026-09-13-fts-rebuild.md +83 -0
- package/docs/research/ledger/docs/research/2026-09-13-read-path-split.md +74 -0
- package/docs/research/ledger/docs/research/2026-09-13-runtime-rollout.md +102 -0
- package/docs/research/ledger/docs/research/2026-09-13-scan-outcomes.md +80 -0
- package/docs/research/ledger/docs/research/2026-09-13-search-quality.md +105 -0
- package/docs/research/ledger/docs/research/2026-09-13-source-coverage.md +64 -0
- package/docs/research/ledger/docs/research/2026-09-13-sync-wall-budget.md +82 -0
- package/docs/research/ledger/docs/research/2026-09-13-typed-read-gate.md +81 -0
- package/docs/research/ledger/docs/research/2026-09-13-writer-lease.md +84 -0
- package/docs/research/ledger/docs/research/2026-09-16-c1-copy-fallback.md +227 -0
- package/docs/research/ledger/docs/research/2026-09-16-c10-kimi.md +414 -0
- package/docs/research/ledger/docs/research/2026-09-16-c2-derive-counter.md +216 -0
- package/docs/research/ledger/docs/research/2026-09-16-c3-echo-filter.md +305 -0
- package/docs/research/ledger/docs/research/2026-09-16-c4-title-index.md +349 -0
- package/docs/research/ledger/docs/research/2026-09-16-c5-trigram.md +268 -0
- package/docs/research/ledger/docs/research/2026-09-16-c6-recency-prior.md +438 -0
- package/docs/research/ledger/docs/research/2026-09-16-c7-tombstones.md +467 -0
- package/docs/research/ledger/docs/research/2026-09-16-c8-remote-truth.md +390 -0
- package/docs/research/ledger/docs/research/2026-09-16-c9-grok.md +380 -0
- package/docs/research/ledger/docs/research/2026-09-16-wake-port-program.md +38 -0
- package/docs/research/ledger/docs/research/2026-09-17-cursor-blobstore.md +157 -0
- package/docs/research/ledger/manifest.json +540 -0
- package/legacy/NOTICE.md +50 -0
- package/legacy/bin/ledger-core.ts +7 -0
- package/legacy/bin/ledger.ts +7 -0
- package/legacy/bin/traj-bridge.ts +7 -0
- package/legacy/scripts/import-claude-history.ts +130 -0
- package/legacy/scripts/native-history-smoke.ts +52 -0
- package/legacy/scripts/observe-daemon.ts +570 -0
- package/legacy/scripts/retitle-sessions.md +19 -0
- package/legacy/scripts/verify-runtime-rollout.ts +151 -0
- package/legacy/src/canonical.ts +108 -0
- package/legacy/src/cli.ts +1293 -0
- package/legacy/src/db.ts +2254 -0
- package/legacy/src/diagnostics.ts +87 -0
- package/legacy/src/discovery.ts +56 -0
- package/legacy/src/embeddings.ts +382 -0
- package/legacy/src/filter.ts +602 -0
- package/legacy/src/gemini_embeddings.ts +103 -0
- package/legacy/src/identity.ts +9 -0
- package/legacy/src/index.ts +10 -0
- package/legacy/src/ingest.ts +791 -0
- package/legacy/src/managed.ts +178 -0
- package/legacy/src/native/common.ts +68 -0
- package/legacy/src/native/cursor.ts +647 -0
- package/legacy/src/native/grok.ts +540 -0
- package/legacy/src/native/kimi.ts +706 -0
- package/legacy/src/native/opencode.ts +470 -0
- package/legacy/src/native/sqlite-ro.ts +281 -0
- package/legacy/src/native.ts +97 -0
- package/legacy/src/normalizer.ts +457 -0
- package/legacy/src/parentage.ts +562 -0
- package/legacy/src/pressure.ts +162 -0
- package/legacy/src/private-storage.ts +74 -0
- package/legacy/src/reader.ts +1255 -0
- package/legacy/src/scanner.ts +591 -0
- package/legacy/src/schema-gate.ts +263 -0
- package/legacy/src/schema.ts +829 -0
- package/legacy/src/semantic-top-k.ts +71 -0
- package/legacy/src/session-hash.ts +49 -0
- package/legacy/src/store-status.ts +218 -0
- package/legacy/src/sync-preparation.ts +45 -0
- package/legacy/src/sync-truth.ts +843 -0
- package/legacy/src/sync.ts +1233 -0
- package/legacy/src/types.ts +436 -0
- package/legacy/src/vocab.txt +30522 -0
- package/legacy/src/watch.ts +673 -0
- package/legacy/src/writer-lease.ts +310 -0
- package/ops/README.md +150 -0
- package/ops/install-cli.sh +63 -0
- package/ops/install-native.sh +35 -0
- package/ops/install-release.sh +49 -0
- package/ops/linux/install-systemd-user.sh +103 -0
- package/ops/macos/install-launchd.sh +72 -0
- package/ops/sync-settings.sh +37 -0
- package/package.json +21 -5
- package/skills/trajectories/SKILL.md +138 -0
- package/skills/trajectories/scripts/trajectories_recent.sh +26 -0
- package/skills/trajectories/scripts/trajectories_search.sh +26 -0
- package/index.js +0 -1
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
umask 077
|
|
4
|
+
WRITE_ONLY=0
|
|
5
|
+
ENABLE_NOW=0
|
|
6
|
+
usage() { echo 'Usage: install-systemd-user.sh [--write-only | --enable-now] (default: --write-only)'; }
|
|
7
|
+
for arg in "$@"; do
|
|
8
|
+
case "$arg" in
|
|
9
|
+
--write-only) WRITE_ONLY=1 ;;
|
|
10
|
+
--enable-now) ENABLE_NOW=1 ;;
|
|
11
|
+
--help|-h) usage; exit 0 ;;
|
|
12
|
+
*) echo "Unknown option: $arg" >&2; usage >&2; exit 2 ;;
|
|
13
|
+
esac
|
|
14
|
+
done
|
|
15
|
+
[[ "$WRITE_ONLY" != 1 || "$ENABLE_NOW" != 1 ]] || { echo 'Use --write-only or --enable-now, not both.' >&2; exit 2; }
|
|
16
|
+
PACKAGE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
17
|
+
ENV_FILE="${TRAJECTORIES_ENV_FILE:-${LEDGER_ENV_FILE:-${XDG_CONFIG_HOME:-$HOME/.config}/ledger/daemon.env}}"
|
|
18
|
+
if [[ -f "$ENV_FILE" ]]; then
|
|
19
|
+
set -a
|
|
20
|
+
# shellcheck disable=SC1090
|
|
21
|
+
source "$ENV_FILE"
|
|
22
|
+
set +a
|
|
23
|
+
fi
|
|
24
|
+
DEFAULT_WORKERS=2
|
|
25
|
+
source "$PACKAGE_DIR/ops/sync-settings.sh"
|
|
26
|
+
UNIT_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user"
|
|
27
|
+
UNIT="$UNIT_DIR/archeism-trajectories.service"
|
|
28
|
+
TIMER="$UNIT_DIR/archeism-trajectories.timer"
|
|
29
|
+
mkdir -p "$UNIT_DIR" "$DATA_DIR"
|
|
30
|
+
# Operate only on the Trajectories units. An existing Ledger writer must be
|
|
31
|
+
# stopped explicitly by its owner before enabling a replacement on the same DB.
|
|
32
|
+
systemctl --user disable --now archeism-trajectories.service >/dev/null 2>&1 || true
|
|
33
|
+
systemctl --user disable --now archeism-trajectories.timer >/dev/null 2>&1 || true
|
|
34
|
+
systemd_quote() {
|
|
35
|
+
local value="${1//\\/\\\\}"
|
|
36
|
+
value="${value//\"/\\\"}"
|
|
37
|
+
value="${value//%/%%}"
|
|
38
|
+
printf '"%s"' "$value"
|
|
39
|
+
}
|
|
40
|
+
{
|
|
41
|
+
cat <<EOF
|
|
42
|
+
[Unit]
|
|
43
|
+
Description=Trajectories bounded local history sync
|
|
44
|
+
After=default.target
|
|
45
|
+
|
|
46
|
+
[Service]
|
|
47
|
+
Type=oneshot
|
|
48
|
+
EOF
|
|
49
|
+
# WorkingDirectory consumes a path value, not ExecStart's quoted argv syntax.
|
|
50
|
+
printf 'WorkingDirectory=%s\n' "${PACKAGE_DIR//%/%%}"
|
|
51
|
+
printf 'Environment=%s\n' "$(systemd_quote "PATH=$(dirname "$BUN_BIN"):/usr/local/bin:/usr/bin:/bin")"
|
|
52
|
+
# The retained sync engine reads this compatibility marker.
|
|
53
|
+
echo 'Environment=LEDGER_SCHEDULER=1'
|
|
54
|
+
printf 'ExecStart='
|
|
55
|
+
for value in "$BUN_BIN" run "$CLI_PATH" "${SYNC_ARGS[@]}"; do
|
|
56
|
+
systemd_quote "${value//\$/\$\$}"; printf ' '
|
|
57
|
+
done
|
|
58
|
+
cat <<'EOF'
|
|
59
|
+
|
|
60
|
+
Restart=no
|
|
61
|
+
TimeoutStartSec=150
|
|
62
|
+
TimeoutStopSec=5
|
|
63
|
+
MemoryHigh=768M
|
|
64
|
+
MemoryMax=1G
|
|
65
|
+
MemorySwapMax=256M
|
|
66
|
+
CPUQuota=50%
|
|
67
|
+
CPUWeight=10
|
|
68
|
+
TasksMax=16
|
|
69
|
+
Nice=10
|
|
70
|
+
IOSchedulingClass=idle
|
|
71
|
+
NoNewPrivileges=true
|
|
72
|
+
PrivateTmp=true
|
|
73
|
+
OOMPolicy=stop
|
|
74
|
+
EOF
|
|
75
|
+
} > "$UNIT"
|
|
76
|
+
cat > "$TIMER" <<'EOF'
|
|
77
|
+
[Unit]
|
|
78
|
+
Description=Run Trajectories bounded sync periodically
|
|
79
|
+
|
|
80
|
+
[Timer]
|
|
81
|
+
OnBootSec=5min
|
|
82
|
+
OnUnitInactiveSec=15min
|
|
83
|
+
RandomizedDelaySec=60
|
|
84
|
+
Persistent=true
|
|
85
|
+
Unit=archeism-trajectories.service
|
|
86
|
+
|
|
87
|
+
[Install]
|
|
88
|
+
WantedBy=timers.target
|
|
89
|
+
EOF
|
|
90
|
+
chmod 600 "$UNIT" "$TIMER"
|
|
91
|
+
systemctl --user daemon-reload
|
|
92
|
+
if [[ "$ENABLE_NOW" == 1 ]]; then
|
|
93
|
+
systemctl --user enable --now archeism-trajectories.timer
|
|
94
|
+
echo 'Trajectories timer installed: archeism-trajectories.timer'
|
|
95
|
+
else
|
|
96
|
+
echo "Trajectories unit and timer written (not enabled): $TIMER"
|
|
97
|
+
echo 'Inspect the units, run one manual bounded sync, then enable the timer:'
|
|
98
|
+
echo ' systemctl --user cat archeism-trajectories.service archeism-trajectories.timer'
|
|
99
|
+
printf ' %q run %q' "$BUN_BIN" "$CLI_PATH"
|
|
100
|
+
printf ' %q' "${SYNC_ARGS[@]}"; printf '\n'
|
|
101
|
+
echo ' systemctl --user enable --now archeism-trajectories.timer'
|
|
102
|
+
fi
|
|
103
|
+
echo "Database: $DB_PATH"
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
umask 077
|
|
4
|
+
if [[ $# -gt 0 ]]; then
|
|
5
|
+
[[ $# == 1 && ( "$1" == --help || "$1" == -h ) ]] || { echo 'Usage: install-launchd.sh' >&2; exit 2; }
|
|
6
|
+
echo 'Usage: install-launchd.sh (writes and enables the bounded 15-minute job)'
|
|
7
|
+
exit 0
|
|
8
|
+
fi
|
|
9
|
+
PACKAGE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
10
|
+
DEFAULT_WORKERS=1
|
|
11
|
+
source "$PACKAGE_DIR/ops/sync-settings.sh"
|
|
12
|
+
LOG_DIR="${TRAJECTORIES_LOG_DIR:-${LEDGER_LOG_DIR:-$DATA_DIR/logs}}"
|
|
13
|
+
LABEL='com.archeism.trajectories'
|
|
14
|
+
PLIST="$HOME/Library/LaunchAgents/$LABEL.plist"
|
|
15
|
+
case "$PACKAGE_DIR" in
|
|
16
|
+
"$HOME"/Documents|"$HOME"/Documents/*|"$HOME"/Desktop|"$HOME"/Desktop/*|"$HOME"/Downloads|"$HOME"/Downloads/*)
|
|
17
|
+
echo "Warning: macOS privacy controls may block launchd access to $PACKAGE_DIR." >&2
|
|
18
|
+
echo 'Install from a stable checkout outside Documents, Desktop, or Downloads (for example ~/workspace/oh-my-ai); do not change privacy policy.' >&2 ;;
|
|
19
|
+
esac
|
|
20
|
+
mkdir -p "$(dirname "$PLIST")" "$DATA_DIR" "$LOG_DIR"
|
|
21
|
+
chmod 700 "$DATA_DIR" "$LOG_DIR"
|
|
22
|
+
for LOG_FILE in "$LOG_DIR/trajectories.stdout.log" "$LOG_DIR/trajectories.stderr.log"; do
|
|
23
|
+
[[ ! -L "$LOG_FILE" && ( ! -e "$LOG_FILE" || -f "$LOG_FILE" ) ]] || { echo "Refusing non-regular or symlink log file: $LOG_FILE" >&2; exit 1; }
|
|
24
|
+
[[ ! -f "$LOG_FILE" ]] || chmod 600 "$LOG_FILE"
|
|
25
|
+
: >> "$LOG_FILE"
|
|
26
|
+
done
|
|
27
|
+
xml() {
|
|
28
|
+
local value="${1//&/\&}"
|
|
29
|
+
value="${value//</\<}"
|
|
30
|
+
value="${value//>/\>}"
|
|
31
|
+
printf '%s' "$value"
|
|
32
|
+
}
|
|
33
|
+
{
|
|
34
|
+
cat <<EOF
|
|
35
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
36
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
37
|
+
<plist version="1.0"><dict>
|
|
38
|
+
<key>Label</key><string>$LABEL</string>
|
|
39
|
+
<key>ProgramArguments</key><array>
|
|
40
|
+
EOF
|
|
41
|
+
for value in "$BUN_BIN" run "$CLI_PATH" "${SYNC_ARGS[@]}"; do printf ' <string>%s</string>\n' "$(xml "$value")"; done
|
|
42
|
+
cat <<EOF
|
|
43
|
+
</array>
|
|
44
|
+
<key>EnvironmentVariables</key><dict><key>LEDGER_SCHEDULER</key><string>1</string></dict>
|
|
45
|
+
<key>WorkingDirectory</key><string>$(xml "$PACKAGE_DIR")</string>
|
|
46
|
+
<key>RunAtLoad</key><true/>
|
|
47
|
+
<key>StartInterval</key><integer>900</integer>
|
|
48
|
+
<key>Umask</key><integer>63</integer>
|
|
49
|
+
<key>ProcessType</key><string>Background</string>
|
|
50
|
+
<key>LowPriorityIO</key><true/>
|
|
51
|
+
<key>Nice</key><integer>10</integer>
|
|
52
|
+
<key>ThrottleInterval</key><integer>60</integer>
|
|
53
|
+
<key>ExitTimeOut</key><integer>5</integer>
|
|
54
|
+
<key>HardResourceLimits</key><dict>
|
|
55
|
+
<key>CPU</key><integer>150</integer>
|
|
56
|
+
<key>NumberOfProcesses</key><integer>256</integer>
|
|
57
|
+
<key>ResidentSetSize</key><integer>1073741824</integer>
|
|
58
|
+
</dict>
|
|
59
|
+
<key>StandardOutPath</key><string>$(xml "$LOG_DIR/trajectories.stdout.log")</string>
|
|
60
|
+
<key>StandardErrorPath</key><string>$(xml "$LOG_DIR/trajectories.stderr.log")</string>
|
|
61
|
+
</dict></plist>
|
|
62
|
+
EOF
|
|
63
|
+
} > "$PLIST"
|
|
64
|
+
chmod 600 "$PLIST"
|
|
65
|
+
plutil -lint "$PLIST" >/dev/null
|
|
66
|
+
DOMAIN="gui/$(id -u)"
|
|
67
|
+
launchctl bootout "$DOMAIN/$LABEL" 2>/dev/null || true
|
|
68
|
+
launchctl enable "$DOMAIN/$LABEL"
|
|
69
|
+
# RunAtLoad starts once; a kickstart -k would kill that first bounded pass.
|
|
70
|
+
launchctl bootstrap "$DOMAIN" "$PLIST"
|
|
71
|
+
echo "Trajectories service installed: $LABEL"
|
|
72
|
+
echo "Database: $DB_PATH"
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Shared settings for OS-supervised bounded lexical sync. Source from installers.
|
|
2
|
+
# The search DB keeps Ledger's existing default; it is separate from managed
|
|
3
|
+
# session snapshots. New environment names win; old names remain compatible.
|
|
4
|
+
BUN_BIN="${TRAJECTORIES_BUN:-${LEDGER_BUN:-$(command -v bun)}}"
|
|
5
|
+
[[ -x "$BUN_BIN" ]] || { echo 'Bun executable not found; set TRAJECTORIES_BUN.' >&2; exit 1; }
|
|
6
|
+
CLI_PATH="$PACKAGE_DIR/src/cli.ts"
|
|
7
|
+
[[ -f "$CLI_PATH" ]] || CLI_PATH="$PACKAGE_DIR/dist/cli.js"
|
|
8
|
+
[[ -f "$CLI_PATH" ]] || { echo "Trajectories CLI not found: $CLI_PATH" >&2; exit 1; }
|
|
9
|
+
[[ -f "$PACKAGE_DIR/dist/index.js" ]] || {
|
|
10
|
+
printf 'Build Trajectories before installation: bun run --cwd %q build\n' "$PACKAGE_DIR" >&2
|
|
11
|
+
exit 1
|
|
12
|
+
}
|
|
13
|
+
DATA_DIR="${TRAJECTORIES_DATA_DIR:-${LEDGER_DATA_DIR:-${XDG_DATA_HOME:-$HOME/.local/share}/ledger}}"
|
|
14
|
+
DB_PATH="${TRAJECTORIES_DB:-${LEDGER_DB:-$DATA_DIR/ledger.sqlite}}"
|
|
15
|
+
SOURCES="${TRAJECTORIES_SOURCES:-${LEDGER_SOURCES:-claude-code,codex,cursor,pi,omp,hermes,openclaw,letta-code,opencode,droid,deepagents,openhands,gemini-cli,copilot-cli,grok,kimi,cline,fx}}"
|
|
16
|
+
LIMIT="${TRAJECTORIES_LIMIT:-${LEDGER_LIMIT:-1000}}"
|
|
17
|
+
SESSION_BUDGET="${TRAJECTORIES_SESSION_BUDGET:-${LEDGER_SESSION_BUDGET:-25}}"
|
|
18
|
+
SOURCE_BYTE_BUDGET="${TRAJECTORIES_SOURCE_BYTE_BUDGET:-${LEDGER_SOURCE_BYTE_BUDGET:-67108864}}"
|
|
19
|
+
WALL_MS="${TRAJECTORIES_WALL_MS:-${LEDGER_WALL_MS:-120000}}"
|
|
20
|
+
RETRY_BUDGET="${TRAJECTORIES_RETRY_BUDGET:-${LEDGER_RETRY_BUDGET:-3}}"
|
|
21
|
+
ATTEMPTS_PER_SESSION="${TRAJECTORIES_ATTEMPTS_PER_SESSION:-${LEDGER_ATTEMPTS_PER_SESSION:-8}}"
|
|
22
|
+
READ_BYTES_PER_SECOND="${TRAJECTORIES_READ_BYTES_PER_SECOND:-${LEDGER_READ_BYTES_PER_SECOND:-8388608}}"
|
|
23
|
+
WORKER_MS="${TRAJECTORIES_WORKER_MS:-${LEDGER_WORKER_MS:-30000}}"
|
|
24
|
+
WORKERS="${TRAJECTORIES_WORKERS:-${LEDGER_WORKERS:-$DEFAULT_WORKERS}}"
|
|
25
|
+
FRESH_SESSION_BUDGET="${TRAJECTORIES_FRESH_SESSION_BUDGET:-${LEDGER_FRESH_SESSION_BUDGET:-5}}"
|
|
26
|
+
FRESH_WINDOW_MS="${TRAJECTORIES_FRESH_WINDOW_MS:-${LEDGER_FRESH_WINDOW_MS:-3600000}}"
|
|
27
|
+
SYNC_CHUNK_BYTES="${TRAJECTORIES_SYNC_CHUNK_BYTES:-${LEDGER_SYNC_CHUNK_BYTES:-1048576}}"
|
|
28
|
+
PRESSURE_MODE="${TRAJECTORIES_PRESSURE_MODE:-${LEDGER_PRESSURE_MODE:-auto}}"
|
|
29
|
+
MAINTENANCE_MS="${TRAJECTORIES_MAINTENANCE_MS:-${LEDGER_MAINTENANCE_MS:-5000}}"
|
|
30
|
+
FTS_MERGE_PAGES="${TRAJECTORIES_FTS_MERGE_PAGES:-${LEDGER_FTS_MERGE_PAGES:-64}}"
|
|
31
|
+
SYNC_ARGS=(sync --db "$DB_PATH" --sources "$SOURCES" --limit "$LIMIT" --robot
|
|
32
|
+
--session-budget "$SESSION_BUDGET" --source-byte-budget "$SOURCE_BYTE_BUDGET"
|
|
33
|
+
--wall-ms "$WALL_MS" --retry-budget "$RETRY_BUDGET" --attempts-per-session "$ATTEMPTS_PER_SESSION"
|
|
34
|
+
--read-bytes-per-second "$READ_BYTES_PER_SECOND" --worker-ms "$WORKER_MS" --workers "$WORKERS"
|
|
35
|
+
--fresh-session-budget "$FRESH_SESSION_BUDGET" --fresh-window-ms "$FRESH_WINDOW_MS"
|
|
36
|
+
--sync-chunk-bytes "$SYNC_CHUNK_BYTES" --pressure "$PRESSURE_MODE"
|
|
37
|
+
--maintenance-ms "$MAINTENANCE_MS" --fts-merge-pages "$FTS_MERGE_PAGES")
|
package/package.json
CHANGED
|
@@ -1,8 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "trajectories",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Portable coding-agent sessions: read, search, convert, and continue across harnesses.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"engines": { "node": ">=22.13.0", "bun": ">=1.4.2" },
|
|
8
|
+
"exports": { ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" } },
|
|
9
|
+
"bin": { "trajectories": "./dist/cli.js" },
|
|
10
|
+
"files": ["dist", "docs", "legacy/src", "legacy/bin", "legacy/scripts", "legacy/NOTICE.md", "ops", "skills", "README.md", "CHANGELOG.md", "LICENSE"],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc -p tsconfig.build.json && bun build src/index.ts --target node --format esm --outfile dist/index.js && bun build src/normalization-runtime.ts --target bun --format esm --outfile dist/normalization-runtime.js && bun build src/cli.ts --target bun --format esm --external onnxruntime-node --define TRAJECTORIES_BUNDLED_CLI=true --outfile dist/cli.js && bun scripts/build-assets.ts",
|
|
13
|
+
"build:native": "bun run build && bun scripts/build-native.ts",
|
|
14
|
+
"test": "bun test ./test/*.test.ts",
|
|
15
|
+
"verify": "bun run build && tsc -p tsconfig.legacy.json && bun run test && bun test ./legacy/tests",
|
|
16
|
+
"test:native": "bun scripts/check-native.ts",
|
|
17
|
+
"test:package": "bun run build && bun test ./smoke/package.test.ts && bun run test:native"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": { "@letta-ai/trajectory": "0.4.3" },
|
|
20
|
+
"optionalDependencies": { "onnxruntime-node": "^1.29.0" },
|
|
21
|
+
"devDependencies": { "@types/node": "^22.20.1", "@types/bun": "1.3.14", "typescript": "^5.9.3" },
|
|
22
|
+
"repository": { "type": "git", "url": "git+https://github.com/archeism/oh-my-ai.git", "directory": "packages/trajectories" },
|
|
23
|
+
"publishConfig": { "access": "public" }
|
|
8
24
|
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: trajectories
|
|
3
|
+
description: >-
|
|
4
|
+
Search and inspect coding-agent history across native harnesses, find past
|
|
5
|
+
conversations and tool calls, inspect recent activity, and prepare portable
|
|
6
|
+
session history with the Trajectories CLI. Successor to the Ledger agent skill.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Trajectories
|
|
10
|
+
|
|
11
|
+
Use the `trajectories` CLI for cross-harness history and portable sessions. The
|
|
12
|
+
conversion SDK works in Node; the CLI requires Bun. Native execution stays in the
|
|
13
|
+
harness. Conversion does not start an agent, execute tools, or move workspace files.
|
|
14
|
+
|
|
15
|
+
## Search and recent activity
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
trajectories search "database migration" --source codex --limit 5 --robot --output-version 2
|
|
19
|
+
trajectories recent --limit 5 --robot
|
|
20
|
+
trajectories show codex:NATIVE_SESSION_ID --robot
|
|
21
|
+
trajectories status --json
|
|
22
|
+
trajectories scan --sources codex,claude-code --robot
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The portable wrappers in `scripts/` prefer an installed `trajectories` command and
|
|
26
|
+
otherwise use `dist/cli.js` from the package containing this skill. They resolve
|
|
27
|
+
skill symlinks, work outside the checkout, and forward arguments without composing
|
|
28
|
+
a shell command. Copying the skill without its package requires an installed CLI.
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
bash scripts/trajectories_search.sh "database migration" --output-version 2 --json
|
|
32
|
+
bash scripts/trajectories_recent.sh --limit 5 --source codex
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Wrappers add `--robot`; they preserve the v1 search format unless the caller opts
|
|
36
|
+
into v2. Database precedence belongs to the CLI: explicit `--db PATH` or `--db=PATH`,
|
|
37
|
+
then nonempty `TRAJECTORIES_DB`, then `LEDGER_DB`, then the existing
|
|
38
|
+
`${XDG_DATA_HOME:-$HOME/.local/share}/ledger/ledger.sqlite`. This keeps the original
|
|
39
|
+
Ledger index. For an older Mac Application Support or checkout-local database,
|
|
40
|
+
select its absolute path explicitly and verify `status --json` before writing.
|
|
41
|
+
Neither the wrappers nor the read commands move or initialize an existing store.
|
|
42
|
+
|
|
43
|
+
### Read robot output accurately
|
|
44
|
+
|
|
45
|
+
- Keep stdout and stderr separate. Stdout is JSONL, or JSON with `--json`; human
|
|
46
|
+
progress and v1 fallback warnings use stderr. Nonzero exit means failure.
|
|
47
|
+
- New agents should use `search --robot --output-version 2`. Its first JSONL row is
|
|
48
|
+
`search_meta`, including when there are zero hits. With `--json`, the shape is
|
|
49
|
+
`{search_meta,hits}`. V1 emits hits only, a bare array with `--json`, or empty stdout
|
|
50
|
+
for zero hits; `recent --json` remains an array.
|
|
51
|
+
- `count_precision: "lower_bound"` means the result count is bounded by `--limit`.
|
|
52
|
+
Inspect `requested_search_mode`, `search_mode`, `fallback_reason`, and `widened`
|
|
53
|
+
before calling a result exact, semantic, or complete.
|
|
54
|
+
- Search snippets are excerpts with match markers, not complete transcripts.
|
|
55
|
+
Session fields include source, title, cwd, timestamps, model and record count.
|
|
56
|
+
Proven parentage appears as `parent_session_id`, `parent_title`, nickname and role;
|
|
57
|
+
null means unknown. Search v2 adds `match_type` for title/lexical/semantic/widened hits.
|
|
58
|
+
- Plain multiword lexical queries are contiguous phrases. Use explicit FTS
|
|
59
|
+
operators such as `eval AND practice` for terms anywhere in a record.
|
|
60
|
+
|
|
61
|
+
`--semantic` and `--hybrid` use stored embeddings. Missing vectors can fall back
|
|
62
|
+
to lexical search; check the reported mode. `models pull` downloads the optional
|
|
63
|
+
local model. Reads do not generate embeddings or migrate the database.
|
|
64
|
+
|
|
65
|
+
`status --json` reports schema and counts, tombstones, source coverage and
|
|
66
|
+
normalization diagnostics. Null coverage/diagnostics means an older store cannot
|
|
67
|
+
provide that evidence; an empty current array means no observations/findings.
|
|
68
|
+
`scan --robot` starts with `scan_outcomes`; missing, unreadable, wrong-shape or
|
|
69
|
+
failed source roots remain explicit instead of appearing as successful empty scans.
|
|
70
|
+
|
|
71
|
+
## Bounded indexing
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
trajectories sync --robot
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Use periodic bounded `sync` for unattended ingestion. It exposes fresh/backlog
|
|
78
|
+
lanes, configured/effective budgets, pressure, pending work and worker counts.
|
|
79
|
+
`pending_budget`, `pending_retry`, `pending_pressure` and `wall_budget_exceeded`
|
|
80
|
+
are resumable outcomes, not proof that ingestion finished. Do not disable pressure
|
|
81
|
+
control or replace scheduled sync with `build`/`watch` merely to speed up backfill.
|
|
82
|
+
|
|
83
|
+
`watch` is a foreground option with append checkpoints and periodic reconciliation;
|
|
84
|
+
it does not apply the same catch-up budgets as `sync`. Historical always-on watching
|
|
85
|
+
contributed to host I/O saturation. Install service definitions deliberately and
|
|
86
|
+
verify bounded progress and resource limits on the target host.
|
|
87
|
+
|
|
88
|
+
`delete ID --reason TEXT` records a tombstone, hides the session and refuses future
|
|
89
|
+
reimport. `--hard` also removes stored records; `delete --list` reads the audit rows.
|
|
90
|
+
Native files remain unchanged. Missing files and rescans do not imply deletion.
|
|
91
|
+
|
|
92
|
+
## Portable session history
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
trajectories read /absolute/native/session.jsonl --from cc
|
|
96
|
+
trajectories import /absolute/native/session.jsonl --from cc --session SESSION_ID --intent-id IMPORT_INTENT --cwd /absolute/workspace
|
|
97
|
+
trajectories sessions
|
|
98
|
+
trajectories session SESSION_ID
|
|
99
|
+
trajectories show SESSION_ID --store /absolute/session-store
|
|
100
|
+
trajectories index --store /absolute/session-store --robot
|
|
101
|
+
trajectories show managed:SESSION_ID --robot
|
|
102
|
+
trajectories switch SESSION_ID --to pi --out /absolute/new-directory --expected-head HEAD --intent-id PREPARE_INTENT
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Stop the source before starting the prepared target. Read the export's diagnostics
|
|
106
|
+
and native import/resume argument vectors; preserve each command's cwd. After the
|
|
107
|
+
target completes, import its full native history with `--session ID`, the returned
|
|
108
|
+
`--expected-head HEAD`, `--binding-id BINDING`, and a new `--intent-id IMPORT_INTENT`.
|
|
109
|
+
Reuse the exact session, intent, parent and input on retries. A prepared binding
|
|
110
|
+
advances the managed head; it never starts a harness. Stale or incomplete
|
|
111
|
+
transitions fail rather than replacing the latest history. Native runtime caches,
|
|
112
|
+
pending approvals, credentials, tools,
|
|
113
|
+
filesystem state and opaque reasoning state are not portable through transcripts.
|
|
114
|
+
|
|
115
|
+
Managed-session storage is selected by `--store`, `TRAJECTORIES_HOME`, or XDG data
|
|
116
|
+
home/trajectories. `TRAJECTORIES_HOME` is a session-store path, not a package checkout
|
|
117
|
+
or search database. Original native transcripts and conversion diagnostics remain
|
|
118
|
+
evidence; normalized records do not provide raw archival retention for every
|
|
119
|
+
historical session merely because `source_path` still points at it.
|
|
120
|
+
|
|
121
|
+
`sessions` returns an ID-ordered page; continue with `--cursor` and choose the
|
|
122
|
+
page size with `--limit`. For version 1 managed stores, stop native and Workflow
|
|
123
|
+
writers, then use `trajectories migrate OLD_STORE --out NEW_STORE --writers-stopped`.
|
|
124
|
+
The destination must be fresh; successful migration retains `migration.json` with
|
|
125
|
+
session, head, capture and prepared binding mappings. Apply those mappings to
|
|
126
|
+
caller state before resuming against the new store. Preserve the old source and
|
|
127
|
+
any failed partial destination.
|
|
128
|
+
|
|
129
|
+
`index --store` adds only each managed session's accepted complete history to the
|
|
130
|
+
same lexical search DB, under a stable `managed:SESSION_ID`. Re-run after import;
|
|
131
|
+
scheduled native `sync` does not do this. A harness switch replaces that indexed
|
|
132
|
+
head. Each logical session has its own log; staged captures are not indexed.
|
|
133
|
+
`show --store` reads the complete accepted log without initializing a search DB; `show` with
|
|
134
|
+
an indexed id uses the read-only database. Managed search/recent rows use
|
|
135
|
+
`source: managed`; records keep their original `source_type`, native-session id
|
|
136
|
+
and prepared binding id. Indexed robot output labels its Ledger projection and
|
|
137
|
+
points to `managed_log_path`. Use `show --store` for central record ids, complete
|
|
138
|
+
payloads and origin. Search snippets are excerpts.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
# Prefer the installed command when this skill is copied outside the package.
|
|
5
|
+
# The CLI owns database resolution: --db > TRAJECTORIES_DB > LEDGER_DB >
|
|
6
|
+
# the existing XDG data home/ledger/ledger.sqlite. Do not resolve a second DB here.
|
|
7
|
+
if command -v trajectories >/dev/null 2>&1; then
|
|
8
|
+
exec trajectories recent "$@" --robot
|
|
9
|
+
fi
|
|
10
|
+
|
|
11
|
+
# Follow skill/script symlinks so the packaged fallback also works after deployment.
|
|
12
|
+
SCRIPT_SOURCE="${BASH_SOURCE[0]}"
|
|
13
|
+
while [ -h "$SCRIPT_SOURCE" ]; do
|
|
14
|
+
SCRIPT_DIRECTORY="$(cd -P "$(dirname "$SCRIPT_SOURCE")" && pwd)"
|
|
15
|
+
SCRIPT_SOURCE="$(readlink "$SCRIPT_SOURCE")"
|
|
16
|
+
[[ "$SCRIPT_SOURCE" != /* ]] && SCRIPT_SOURCE="$SCRIPT_DIRECTORY/$SCRIPT_SOURCE"
|
|
17
|
+
done
|
|
18
|
+
SCRIPT_DIRECTORY="$(cd -P "$(dirname "$SCRIPT_SOURCE")" && pwd)"
|
|
19
|
+
PACKAGE_ROOT="$(cd "$SCRIPT_DIRECTORY/../../.." && pwd)"
|
|
20
|
+
CLI_BIN="$PACKAGE_ROOT/dist/cli.js"
|
|
21
|
+
if [ ! -f "$CLI_BIN" ]; then
|
|
22
|
+
echo '{"error":{"code":"CLI_NOT_FOUND","message":"Install trajectories or build the package containing this skill."}}' >&2
|
|
23
|
+
exit 1
|
|
24
|
+
fi
|
|
25
|
+
|
|
26
|
+
exec bun "$CLI_BIN" recent "$@" --robot
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
# Prefer the installed command when this skill is copied outside the package.
|
|
5
|
+
# The CLI owns database resolution: --db > TRAJECTORIES_DB > LEDGER_DB >
|
|
6
|
+
# the existing XDG data home/ledger/ledger.sqlite. Do not resolve a second DB here.
|
|
7
|
+
if command -v trajectories >/dev/null 2>&1; then
|
|
8
|
+
exec trajectories search "$@" --robot
|
|
9
|
+
fi
|
|
10
|
+
|
|
11
|
+
# Follow skill/script symlinks so the packaged fallback also works after deployment.
|
|
12
|
+
SCRIPT_SOURCE="${BASH_SOURCE[0]}"
|
|
13
|
+
while [ -h "$SCRIPT_SOURCE" ]; do
|
|
14
|
+
SCRIPT_DIRECTORY="$(cd -P "$(dirname "$SCRIPT_SOURCE")" && pwd)"
|
|
15
|
+
SCRIPT_SOURCE="$(readlink "$SCRIPT_SOURCE")"
|
|
16
|
+
[[ "$SCRIPT_SOURCE" != /* ]] && SCRIPT_SOURCE="$SCRIPT_DIRECTORY/$SCRIPT_SOURCE"
|
|
17
|
+
done
|
|
18
|
+
SCRIPT_DIRECTORY="$(cd -P "$(dirname "$SCRIPT_SOURCE")" && pwd)"
|
|
19
|
+
PACKAGE_ROOT="$(cd "$SCRIPT_DIRECTORY/../../.." && pwd)"
|
|
20
|
+
CLI_BIN="$PACKAGE_ROOT/dist/cli.js"
|
|
21
|
+
if [ ! -f "$CLI_BIN" ]; then
|
|
22
|
+
echo '{"error":{"code":"CLI_NOT_FOUND","message":"Install trajectories or build the package containing this skill."}}' >&2
|
|
23
|
+
exit 1
|
|
24
|
+
fi
|
|
25
|
+
|
|
26
|
+
exec bun "$CLI_BIN" search "$@" --robot
|
package/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = {};
|