@phren/cli 0.1.20 → 0.1.22

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.
@@ -22,6 +22,21 @@ export declare function runBestEffortGit(args: string[], cwd: string): Promise<{
22
22
  output?: string;
23
23
  error?: string;
24
24
  }>;
25
+ /**
26
+ * Files phren is allowed to auto-stage in a team store. Anything not in this
27
+ * list (notably `.runtime/`, secrets, build output) is skipped on session-stop
28
+ * and `push_changes`.
29
+ */
30
+ export declare const TEAM_STORE_PATHSPECS: readonly ["*/journal/*", "*/tasks.md", "*/truths.md", "*/FINDINGS.md", "*/FINDINGS.md.bak", "*/summary.md", "*/review.md", "*/CLAUDE.md", "*/topic-config.json", "*/phren.project.yaml", "*/reference/**", "*/skills/**", ".phren-team.yaml"];
31
+ /**
32
+ * Stage each team pathspec individually so a single no-match (e.g. a store
33
+ * with no `truths.md` anywhere) doesn't abort the entire `git add` and strand
34
+ * every other change. Errors are swallowed by `runBestEffortGit` already.
35
+ *
36
+ * Returns the number of pathspecs that staged successfully — useful for
37
+ * telemetry, not gating.
38
+ */
39
+ export declare function addTeamPathspecs(cwd: string): Promise<number>;
25
40
  export declare function countUnsyncedCommits(cwd: string): Promise<number>;
26
41
  export declare function isMergeableMarkdown(relPath: string): boolean;
27
42
  export declare function snapshotLocalMergeableFiles(cwd: string): Promise<Map<string, string>>;
@@ -121,6 +121,43 @@ export async function runBestEffortGit(args, cwd) {
121
121
  }
122
122
  return { ok: false, error: "git command failed" };
123
123
  }
124
+ /**
125
+ * Files phren is allowed to auto-stage in a team store. Anything not in this
126
+ * list (notably `.runtime/`, secrets, build output) is skipped on session-stop
127
+ * and `push_changes`.
128
+ */
129
+ export const TEAM_STORE_PATHSPECS = [
130
+ "*/journal/*",
131
+ "*/tasks.md",
132
+ "*/truths.md",
133
+ "*/FINDINGS.md",
134
+ "*/FINDINGS.md.bak",
135
+ "*/summary.md",
136
+ "*/review.md",
137
+ "*/CLAUDE.md",
138
+ "*/topic-config.json",
139
+ "*/phren.project.yaml",
140
+ "*/reference/**",
141
+ "*/skills/**",
142
+ ".phren-team.yaml",
143
+ ];
144
+ /**
145
+ * Stage each team pathspec individually so a single no-match (e.g. a store
146
+ * with no `truths.md` anywhere) doesn't abort the entire `git add` and strand
147
+ * every other change. Errors are swallowed by `runBestEffortGit` already.
148
+ *
149
+ * Returns the number of pathspecs that staged successfully — useful for
150
+ * telemetry, not gating.
151
+ */
152
+ export async function addTeamPathspecs(cwd) {
153
+ let staged = 0;
154
+ for (const spec of TEAM_STORE_PATHSPECS) {
155
+ const result = await runBestEffortGit(["add", "--sparse", "--", spec], cwd);
156
+ if (result.ok)
157
+ staged++;
158
+ }
159
+ return staged;
160
+ }
124
161
  export async function countUnsyncedCommits(cwd) {
125
162
  const upstream = await runBestEffortGit(["rev-parse", "--abbrev-ref", "@{upstream}"], cwd);
126
163
  if (!upstream.ok || !upstream.output) {
@@ -7,7 +7,7 @@ import * as fs from "fs";
7
7
  import * as path from "path";
8
8
  import * as os from "os";
9
9
  import { spawnDetachedChild } from "./shared/process.js";
10
- import { resolveSubprocessArgs as _resolveSubprocessArgs, runBestEffortGit, countUnsyncedCommits, recoverPushConflict, } from "./cli-hooks-git.js";
10
+ import { resolveSubprocessArgs as _resolveSubprocessArgs, runBestEffortGit, countUnsyncedCommits, recoverPushConflict, addTeamPathspecs, } from "./cli-hooks-git.js";
11
11
  import { logger } from "./logger.js";
12
12
  const SYNC_LOCK_STALE_MS = 10 * 60 * 1000; // 10 minutes
13
13
  /** Read JSON from stdin if it's not a TTY. Returns null if stdin is a TTY or parsing fails. */
@@ -485,8 +485,9 @@ export async function handleHookStop() {
485
485
  try {
486
486
  const storeStatus = await runBestEffortGit(["status", "--porcelain"], store.path);
487
487
  if (storeStatus.ok && storeStatus.output) {
488
- // Only stage journal/, tasks.md, truths.md, FINDINGS.md, summary.md — NOT .runtime/
489
- await runBestEffortGit(["add", "--sparse", "--", "*/journal/*", "*/tasks.md", "*/truths.md", "*/FINDINGS.md", "*/FINDINGS.md.bak", "*/summary.md", "*/review.md", "*/CLAUDE.md", "*/topic-config.json", "*/phren.project.yaml", "*/reference/**", "*/skills/**", ".phren-team.yaml"], store.path);
488
+ // Stage each team-safe pathspec individually — a single no-match
489
+ // (e.g. no */truths.md in this store) used to abort the whole add.
490
+ await addTeamPathspecs(store.path);
490
491
  const actor = process.env.PHREN_ACTOR || process.env.USER || "unknown";
491
492
  const teamCommit = await runBestEffortGit(["commit", "-m", `phren: ${actor} team sync`], store.path);
492
493
  if (teamCommit.ok) {