@team-agent/installer 0.5.123 → 0.5.124

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.
@@ -3,7 +3,7 @@
3
3
  //! contract:
4
4
  //! provides:
5
5
  //! - name: scan_session_store
6
- //! what: 只读每个 JSONL 的首个完整 header,并按 id/cwd/spawned_at 返回候选
6
+ //! what: 只读每个 JSONL 的首个完整 header;有预期 id 时按 id/cwd/spawned_at,否则按 cwd/spawned_at 读取 Pi 自己的 id
7
7
  //! - name: validate_exact_backing
8
8
  //! what: restart 前重验 exact path 的 id/cwd header
9
9
  //! boundary:
@@ -49,13 +49,8 @@ fn read_header(path: &Path) -> Option<PiSessionHeader> {
49
49
  (header.record_type == "session" && header.version == 3).then_some(header)
50
50
  }
51
51
 
52
- fn header_matches(
53
- header: &PiSessionHeader,
54
- expected_session_id: &SessionId,
55
- spawn_cwd: &Path,
56
- spawned_at: Option<&str>,
57
- ) -> bool {
58
- if header.id != expected_session_id.as_str() || !paths_equal(&header.cwd, spawn_cwd) {
52
+ fn header_matches_spawn(header: &PiSessionHeader, spawn_cwd: &Path, spawned_at: Option<&str>) -> bool {
53
+ if !paths_equal(&header.cwd, spawn_cwd) {
59
54
  return false;
60
55
  }
61
56
  let Ok(header_timestamp) = chrono::DateTime::parse_from_rfc3339(&header.timestamp) else {
@@ -70,6 +65,16 @@ fn header_matches(
70
65
  header_timestamp >= spawned_at
71
66
  }
72
67
 
68
+ fn header_matches(
69
+ header: &PiSessionHeader,
70
+ expected_session_id: &SessionId,
71
+ spawn_cwd: &Path,
72
+ spawned_at: Option<&str>,
73
+ ) -> bool {
74
+ header.id == expected_session_id.as_str()
75
+ && header_matches_spawn(header, spawn_cwd, spawned_at)
76
+ }
77
+
73
78
  fn collect_jsonl(root: &Path, out: &mut Vec<PathBuf>) -> Result<(), ProviderError> {
74
79
  let entries = std::fs::read_dir(root)
75
80
  .map_err(|error| ProviderError::Io(format!("{}: {error}", root.display())))?;
@@ -125,15 +130,14 @@ pub(crate) fn validate_exact_backing(
125
130
 
126
131
  /// ---
127
132
  /// purpose: 仅在 recorded seat root 内递归捕获 Pi session header 候选
128
- /// returns: 每个 id/cwd/timestamp 精确匹配的 JSONL 各返回一个候选
133
+ /// returns: 有预期 id 时按 id/cwd/timestamp 匹配;否则读取 Pi header 自己的 id,并按 cwd/timestamp 匹配
129
134
  /// errors: root 内目录枚举失败时返回 ProviderError
130
135
  /// ---
131
136
  pub(super) fn scan_session_store(
132
137
  context: &CaptureSessionContext,
133
138
  ) -> Result<Vec<CapturedSessionCandidate>, ProviderError> {
134
- let (Some(root), Some(expected_session_id), Some(spawned_at)) = (
139
+ let (Some(root), Some(spawned_at)) = (
135
140
  context.provider_projects_root.as_deref(),
136
- context.expected_session_id.as_ref(),
137
141
  context.spawned_at.as_deref(),
138
142
  ) else {
139
143
  return Ok(Vec::new());
@@ -149,15 +153,24 @@ pub(super) fn scan_session_store(
149
153
  .into_iter()
150
154
  .filter_map(|path| {
151
155
  let header = read_header(&path)?;
152
- header_matches(
153
- &header,
154
- expected_session_id,
155
- &context.spawn_cwd,
156
- Some(spawned_at),
157
- )
158
- .then(|| CapturedSessionCandidate {
156
+ let session_id = if let Some(expected_session_id) = context.expected_session_id.as_ref() {
157
+ if !header_matches(
158
+ &header,
159
+ expected_session_id,
160
+ &context.spawn_cwd,
161
+ Some(spawned_at),
162
+ ) {
163
+ return None;
164
+ }
165
+ expected_session_id.clone()
166
+ } else if header_matches_spawn(&header, &context.spawn_cwd, Some(spawned_at)) {
167
+ SessionId::new(header.id)
168
+ } else {
169
+ return None;
170
+ };
171
+ Some(CapturedSessionCandidate {
159
172
  captured: CapturedSession {
160
- session_id: Some(expected_session_id.clone()),
173
+ session_id: Some(session_id),
161
174
  rollout_path: Some(RolloutPath::new(path)),
162
175
  captured_via: CaptureVia::FsWatch,
163
176
  attribution_confidence: Confidence::High,
@@ -36,8 +36,8 @@ fn command_helpers_keep_provider_argv_bytes_and_order() {
36
36
  extension: std::path::Path::new("extension.ts"), model: Some("vendor/model"),
37
37
  effort: Some(ProviderEffort::XHigh), system_prompt: raw,
38
38
  session_dir: Some(std::path::Path::new("sessions")),
39
- session: pi::PiSessionSelector::Fresh { session_id: "session-id" }, agent_id: "worker",
40
- }).expect("pi"), ["pi", "-e", "extension.ts", "--model", "vendor/model", "--thinking", "xhigh", "--append-system-prompt", raw, "--session-dir", "sessions", "--session-id", "session-id", "--name", "worker"]);
39
+ session: pi::PiSessionSelector::Fresh, agent_id: "worker",
40
+ }).expect("pi"), ["pi", "-e", "extension.ts", "--model", "vendor/model", "--thinking", "xhigh", "--append-system-prompt", raw, "--session-dir", "sessions", "--name", "worker"]);
41
41
  }
42
42
 
43
43
  #[test]
package/npm/install.mjs CHANGED
@@ -168,7 +168,12 @@ function install(argv) {
168
168
  if (pathCheck.status === "ready") {
169
169
  console.log("Ready in this terminal. Run: team-agent --help");
170
170
  } else {
171
- console.log("Open a new terminal, then run: team-agent --help");
171
+ console.log(pathActivationGuidance({
172
+ binDir,
173
+ teamAgent,
174
+ rc: installTarget.rc,
175
+ shell: path.basename(process.env.SHELL || ""),
176
+ }));
172
177
  }
173
178
  }
174
179
 
@@ -561,7 +566,9 @@ function ensureBinDirOnShellRc(binDir, options = {}) {
561
566
 
562
567
  function shellRcTargets(shell, home) {
563
568
  if (shell === "zsh") {
564
- return { files: [path.join(home, ".zshrc")], style: "posix" };
569
+ // Login shells, including ssh and macOS Terminal, read .zprofile and do
570
+ // not read .zshrc unless they are also interactive. Write both.
571
+ return { files: [path.join(home, ".zprofile"), path.join(home, ".zshrc")], style: "posix" };
565
572
  }
566
573
  if (shell === "bash") {
567
574
  return { files: [path.join(home, ".bashrc"), path.join(home, ".bash_profile")], style: "posix" };
@@ -571,13 +578,43 @@ function shellRcTargets(shell, home) {
571
578
  }
572
579
  if (!shell || shell === "sh") {
573
580
  return {
574
- files: [process.platform === "darwin" ? path.join(home, ".zshrc") : path.join(home, ".profile")],
581
+ files: process.platform === "darwin"
582
+ ? [path.join(home, ".zprofile"), path.join(home, ".zshrc")]
583
+ : [path.join(home, ".profile")],
575
584
  style: "posix",
576
585
  };
577
586
  }
578
587
  return null;
579
588
  }
580
589
 
590
+ export function pathActivationGuidance(options = {}) {
591
+ const binDir = options.binDir;
592
+ const teamAgent = options.teamAgent;
593
+ const rc = options.rc || { files: [], skipped: [] };
594
+ const refresh = options.shell === "zsh" ? "rehash" : "hash -r";
595
+ const lines = [
596
+ "This shell cannot see team-agent yet. A child installer cannot change the shell that launched it.",
597
+ "Run this in the current shell:",
598
+ ` export PATH="${binDir}:$PATH"`,
599
+ ` ${refresh}`,
600
+ " team-agent --help",
601
+ "Or run the installed command directly:",
602
+ ` ${teamAgent} --help`,
603
+ ];
604
+ const written = rc.files || [];
605
+ const skipped = rc.skipped || [];
606
+ if (written.length > 0) {
607
+ lines.push(`New shells read: ${written.join(", ")}`);
608
+ } else if (skipped.length > 0) {
609
+ lines.push(`Shell startup already contains the PATH entry: ${skipped.join(", ")}`);
610
+ } else if (rc.unsupported) {
611
+ lines.push("This shell has no supported startup file. Keep the export above.");
612
+ } else {
613
+ lines.push("Could not update a shell startup file. Keep the export above.");
614
+ }
615
+ return lines.join("\n");
616
+ }
617
+
581
618
  function installedBinDir(runtimeRoot, opts) {
582
619
  const manifest = readInstallManifest(runtimeRoot);
583
620
  if (typeof manifest?.binDir === "string" && manifest.binDir) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@team-agent/installer",
3
- "version": "0.5.123",
3
+ "version": "0.5.124",
4
4
  "description": "npx installer for Team Agent",
5
5
  "keywords": [
6
6
  "codex",
@@ -20,9 +20,9 @@
20
20
  "team-agent-installer": "npm/install.mjs"
21
21
  },
22
22
  "optionalDependencies": {
23
- "@team-agent/cli-darwin-arm64": "0.5.123",
24
- "@team-agent/cli-darwin-x64": "0.5.123",
25
- "@team-agent/cli-linux-x64": "0.5.123"
23
+ "@team-agent/cli-darwin-arm64": "0.5.124",
24
+ "@team-agent/cli-darwin-x64": "0.5.124",
25
+ "@team-agent/cli-linux-x64": "0.5.124"
26
26
  },
27
27
  "scripts": {
28
28
  "postinstall": "node npm/bincheck.mjs",