@inixiative/foundry-core 0.5.8 → 0.5.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inixiative/foundry-core",
3
- "version": "0.5.8",
3
+ "version": "0.5.9",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -6,15 +6,31 @@ import type { TranscriptTurn } from './correction';
6
6
  // `foundry repeats` and Oracle's session miner; its own export, so the core root never loads Archive.
7
7
 
8
8
  const INTERRUPTED = /^\s*\[Request interrupted by user/;
9
- const COMMIT_BRACKET = /\[[^[\]\n]+\s([0-9a-f]{7,40})\]/g;
9
+ const COMMIT_BRACKET = /\[([^[\]\n]+?)\s([0-9a-f]{7,40})\]/g;
10
+ /** `git commit` adds this to the branch on a repository's first commit. */
11
+ const ROOT_COMMIT = /\s+\(root-commit\)$/;
10
12
  const COMMIT_LINE = /^commit ([0-9a-f]{40})/gm;
11
13
 
12
- /** Commits a tool result says were made: `git commit`'s `[branch sha]` line only. */
13
- export const commitsMade = (text: string) => [...text.matchAll(COMMIT_BRACKET)].map((m) => m[1]!);
14
+ /** A commit a session made, as `git commit` printed it: the branch it was on, and its short SHA. */
15
+ export interface MadeCommit {
16
+ /** As git printed it: `main`, `feat/x`, `detached HEAD`; `(root-commit)` dropped. */
17
+ readonly branch: string;
18
+ readonly sha: string;
19
+ }
20
+
21
+ /**
22
+ * Commits a tool result says were made: `git commit`'s `[branch sha]` line only, with the branch,
23
+ * so a reader can tell work on a PR's own branch (amended or rebased away later) from other work.
24
+ */
25
+ export const commitsMade = (text: string): MadeCommit[] =>
26
+ [...text.matchAll(COMMIT_BRACKET)].map((m) => ({
27
+ branch: m[1]!.replace(ROOT_COMMIT, ''),
28
+ sha: m[2]!,
29
+ }));
14
30
 
15
31
  /** Commit SHAs a tool result printed: `git commit`'s `[branch sha]` line, `git log`'s `commit <sha>`. */
16
32
  export const commitsIn = (text: string) => [
17
- ...commitsMade(text),
33
+ ...commitsMade(text).map((made) => made.sha),
18
34
  ...[...text.matchAll(COMMIT_LINE)].map((m) => m[1]!),
19
35
  ];
20
36