@bretwardjames/ghp-core 0.1.3 → 0.1.5

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 ADDED
@@ -0,0 +1,123 @@
1
+ # GHP Tools
2
+
3
+ A suite of tools for managing GitHub Projects from your terminal and editor.
4
+
5
+ ## What's Included
6
+
7
+ | Package | Description |
8
+ |---------|-------------|
9
+ | **[@bretwardjames/ghp-cli](https://github.com/bretwardjames/ghp-cli)** | Command-line interface for GitHub Projects |
10
+ | **[vscode-gh-projects](https://github.com/bretwardjames/vscode-gh-projects)** | VS Code / Cursor extension with visual boards |
11
+ | **@bretwardjames/ghp-core** | Shared library (this package) |
12
+
13
+ Both the CLI and extension share the same underlying library and are designed to work together.
14
+
15
+ ## Quick Install
16
+
17
+ Install both the CLI and VS Code/Cursor extension with a single command:
18
+
19
+ ```bash
20
+ curl -fsSL https://raw.githubusercontent.com/bretwardjames/ghp-core/main/install.sh | bash
21
+ ```
22
+
23
+ This will:
24
+ 1. Install the `ghp` CLI globally via npm
25
+ 2. Install the VS Code/Cursor extension from the latest release
26
+
27
+ ### Manual Installation
28
+
29
+ **CLI only:**
30
+ ```bash
31
+ npm install -g @bretwardjames/ghp-cli
32
+ ```
33
+
34
+ **Extension only:**
35
+ Download the `.vsix` from [releases](https://github.com/bretwardjames/vscode-gh-projects/releases) and install:
36
+ ```bash
37
+ code --install-extension gh-projects-*.vsix
38
+ # or for Cursor:
39
+ cursor --install-extension gh-projects-*.vsix
40
+ ```
41
+
42
+ ## Getting Started
43
+
44
+ 1. Authenticate with GitHub:
45
+ ```bash
46
+ ghp auth
47
+ ```
48
+
49
+ 2. View your assigned work:
50
+ ```bash
51
+ ghp work
52
+ ```
53
+
54
+ 3. Open VS Code/Cursor and find the GitHub Projects panel in the sidebar
55
+
56
+ ## Features
57
+
58
+ ### Shared Across Both Tools
59
+
60
+ - **Branch Linking** - Link branches to issues, track which issues have active work
61
+ - **Workflow Automation** - "Start Working" creates branches and updates status
62
+ - **Project Board Views** - See your boards exactly as configured on GitHub
63
+ - **Issue Templates** - Create issues using your repo's templates
64
+
65
+ ### CLI-Specific
66
+
67
+ - **Shortcuts** - Define named filter combinations (`ghp plan bugs`)
68
+ - **Slice Filters** - Filter by any field (`--slice Priority=High`)
69
+ - **Workspace Config** - Share settings with your team via `.ghp/config.json`
70
+ - **Simple List Output** - Integration with fzf, rofi, and other pickers
71
+
72
+ ### Extension-Specific
73
+
74
+ - **Drag and Drop** - Move issues between columns visually
75
+ - **Planning Board** - Full-screen kanban view
76
+ - **Multi-Select** - Bulk operations on multiple items
77
+ - **Real-Time Sync** - Stay in sync with GitHub
78
+
79
+ ## Configuration
80
+
81
+ Both tools share the same configuration concepts. The CLI uses JSON files, the extension uses VS Code settings.
82
+
83
+ ### CLI Configuration (ghp-cli)
84
+
85
+ ```bash
86
+ # View all settings with their sources
87
+ ghp config --show
88
+
89
+ # Edit user config (opens $EDITOR)
90
+ ghp config
91
+
92
+ # Edit workspace config (shared with team)
93
+ ghp config -w
94
+
95
+ # Set individual value
96
+ ghp config mainBranch develop
97
+ ```
98
+
99
+ **Config files:**
100
+ - User: `~/.config/ghp-cli/config.json` (personal overrides)
101
+ - Workspace: `.ghp/config.json` (committed, shared with team)
102
+
103
+ Merge order: defaults -> workspace -> user
104
+
105
+ ### Extension Configuration (VS Code)
106
+
107
+ Settings are in VS Code's settings UI under "GitHub Projects", or in your workspace `.vscode/settings.json`.
108
+
109
+ ## Links
110
+
111
+ - [ghp-cli Documentation](https://github.com/bretwardjames/ghp-cli)
112
+ - [VS Code Extension Documentation](https://github.com/bretwardjames/vscode-gh-projects)
113
+ - [Report Issues](https://github.com/bretwardjames/ghp-core/issues)
114
+
115
+ ## Requirements
116
+
117
+ - Node.js >= 18
118
+ - GitHub account with Projects access
119
+ - VS Code 1.85+ or Cursor (for extension)
120
+
121
+ ## License
122
+
123
+ MIT
package/dist/index.cjs CHANGED
@@ -33,10 +33,13 @@ __export(index_exports, {
33
33
  detectRepository: () => detectRepository,
34
34
  fetchOrigin: () => fetchOrigin,
35
35
  generateBranchName: () => generateBranchName,
36
+ getAllBranches: () => getAllBranches,
36
37
  getCommitsAhead: () => getCommitsAhead,
37
38
  getCommitsBehind: () => getCommitsBehind,
38
39
  getCurrentBranch: () => getCurrentBranch,
39
40
  getDefaultBranch: () => getDefaultBranch,
41
+ getLocalBranches: () => getLocalBranches,
42
+ getRemoteBranches: () => getRemoteBranches,
40
43
  getRepositoryRoot: () => getRepositoryRoot,
41
44
  hasUncommittedChanges: () => hasUncommittedChanges,
42
45
  isGitRepository: () => isGitRepository,
@@ -1225,6 +1228,34 @@ function generateBranchName(pattern, vars, maxLength = 60) {
1225
1228
  }
1226
1229
  return branch;
1227
1230
  }
1231
+ async function getLocalBranches(options = {}) {
1232
+ try {
1233
+ const { stdout } = await execGit('git branch --format="%(refname:short)"', options);
1234
+ return stdout.split("\n").map((b) => b.trim()).filter((b) => b.length > 0);
1235
+ } catch {
1236
+ return [];
1237
+ }
1238
+ }
1239
+ async function getRemoteBranches(options = {}) {
1240
+ try {
1241
+ await execGit("git fetch --prune", options);
1242
+ const { stdout } = await execGit('git branch -r --format="%(refname:short)"', options);
1243
+ return stdout.split("\n").map((b) => b.trim()).filter((b) => b.length > 0 && !b.includes("HEAD")).map((b) => b.replace(/^origin\//, ""));
1244
+ } catch {
1245
+ return [];
1246
+ }
1247
+ }
1248
+ async function getAllBranches(options = {}) {
1249
+ const [local, remote] = await Promise.all([
1250
+ getLocalBranches(options),
1251
+ getRemoteBranches(options)
1252
+ ]);
1253
+ const all = new Set(local);
1254
+ for (const b of remote) {
1255
+ all.add(b);
1256
+ }
1257
+ return Array.from(all);
1258
+ }
1228
1259
  async function getDefaultBranch(options = {}) {
1229
1260
  try {
1230
1261
  const { stdout } = await execGit(
@@ -1258,10 +1289,13 @@ async function getDefaultBranch(options = {}) {
1258
1289
  detectRepository,
1259
1290
  fetchOrigin,
1260
1291
  generateBranchName,
1292
+ getAllBranches,
1261
1293
  getCommitsAhead,
1262
1294
  getCommitsBehind,
1263
1295
  getCurrentBranch,
1264
1296
  getDefaultBranch,
1297
+ getLocalBranches,
1298
+ getRemoteBranches,
1265
1299
  getRepositoryRoot,
1266
1300
  hasUncommittedChanges,
1267
1301
  isGitRepository,
package/dist/index.d.cts CHANGED
@@ -625,6 +625,18 @@ declare function generateBranchName(pattern: string, vars: {
625
625
  title: string;
626
626
  repo: string;
627
627
  }, maxLength?: number): string;
628
+ /**
629
+ * Get all local branches
630
+ */
631
+ declare function getLocalBranches(options?: GitOptions): Promise<string[]>;
632
+ /**
633
+ * Get all remote branches (excluding HEAD), stripped of origin/ prefix
634
+ */
635
+ declare function getRemoteBranches(options?: GitOptions): Promise<string[]>;
636
+ /**
637
+ * Get all branches (local + remote unique)
638
+ */
639
+ declare function getAllBranches(options?: GitOptions): Promise<string[]>;
628
640
  /**
629
641
  * Get the default branch name (main or master)
630
642
  */
@@ -817,4 +829,4 @@ declare namespace queries {
817
829
  export { queries_ADD_COMMENT_MUTATION as ADD_COMMENT_MUTATION, queries_ADD_LABELS_MUTATION as ADD_LABELS_MUTATION, queries_ADD_TO_PROJECT_MUTATION as ADD_TO_PROJECT_MUTATION, queries_COLLABORATORS_QUERY as COLLABORATORS_QUERY, queries_CREATE_ISSUE_MUTATION as CREATE_ISSUE_MUTATION, queries_ISSUES_WITH_LABEL_QUERY as ISSUES_WITH_LABEL_QUERY, queries_ISSUE_AND_LABEL_QUERY as ISSUE_AND_LABEL_QUERY, queries_ISSUE_DETAILS_QUERY as ISSUE_DETAILS_QUERY, queries_ISSUE_FOR_UPDATE_QUERY as ISSUE_FOR_UPDATE_QUERY, queries_ISSUE_NODE_ID_QUERY as ISSUE_NODE_ID_QUERY, queries_ISSUE_TYPES_QUERY as ISSUE_TYPES_QUERY, queries_LABEL_EXISTS_QUERY as LABEL_EXISTS_QUERY, queries_PROJECT_FIELDS_QUERY as PROJECT_FIELDS_QUERY, queries_PROJECT_ITEMS_QUERY as PROJECT_ITEMS_QUERY, queries_PROJECT_VIEWS_QUERY as PROJECT_VIEWS_QUERY, queries_RECENT_ISSUES_QUERY as RECENT_ISSUES_QUERY, queries_REMOVE_LABELS_MUTATION as REMOVE_LABELS_MUTATION, queries_REPOSITORY_ID_QUERY as REPOSITORY_ID_QUERY, queries_REPOSITORY_PROJECTS_QUERY as REPOSITORY_PROJECTS_QUERY, queries_UPDATE_ISSUE_BODY_MUTATION as UPDATE_ISSUE_BODY_MUTATION, queries_UPDATE_ISSUE_MUTATION as UPDATE_ISSUE_MUTATION, queries_UPDATE_ISSUE_TYPE_MUTATION as UPDATE_ISSUE_TYPE_MUTATION, queries_UPDATE_ITEM_FIELD_MUTATION as UPDATE_ITEM_FIELD_MUTATION, queries_UPDATE_ITEM_STATUS_MUTATION as UPDATE_ITEM_STATUS_MUTATION, queries_VIEWER_QUERY as VIEWER_QUERY };
818
830
  }
819
831
 
820
- export { type AssigneeInfo, type AuthError, BranchLinker, type Collaborator, type DateFieldValue, type FieldInfo, type FieldValue, type FieldValueConnection, GitHubAPI, type GitHubAPIOptions, type GitOptions, type IssueDetails, type IssueReference, type IterationFieldValue, type LabelInfo, type NumberFieldValue, type Project, type ProjectConfig, type ProjectItem, type ProjectItemContent, type ProjectItemsQueryResponse, type ProjectV2, type ProjectV2Field, type ProjectV2Item, type ProjectV2View, type ProjectWithViews, type ProjectsQueryResponse, type RepoInfo, type SingleSelectFieldValue, type StatusField, type TextFieldValue, type TokenProvider, branchExists, buildIssueUrl, buildOrgProjectUrl, buildProjectUrl, buildPullRequestUrl, buildRepoUrl, checkoutBranch, createBranch, detectRepository, fetchOrigin, generateBranchName, getCommitsAhead, getCommitsBehind, getCurrentBranch, getDefaultBranch, getRepositoryRoot, hasUncommittedChanges, isGitRepository, parseBranchLink, parseGitHubUrl, parseIssueUrl, pullLatest, queries, removeBranchLinkFromBody, sanitizeForBranchName, setBranchLinkInBody };
832
+ export { type AssigneeInfo, type AuthError, BranchLinker, type Collaborator, type DateFieldValue, type FieldInfo, type FieldValue, type FieldValueConnection, GitHubAPI, type GitHubAPIOptions, type GitOptions, type IssueDetails, type IssueReference, type IterationFieldValue, type LabelInfo, type NumberFieldValue, type Project, type ProjectConfig, type ProjectItem, type ProjectItemContent, type ProjectItemsQueryResponse, type ProjectV2, type ProjectV2Field, type ProjectV2Item, type ProjectV2View, type ProjectWithViews, type ProjectsQueryResponse, type RepoInfo, type SingleSelectFieldValue, type StatusField, type TextFieldValue, type TokenProvider, branchExists, buildIssueUrl, buildOrgProjectUrl, buildProjectUrl, buildPullRequestUrl, buildRepoUrl, checkoutBranch, createBranch, detectRepository, fetchOrigin, generateBranchName, getAllBranches, getCommitsAhead, getCommitsBehind, getCurrentBranch, getDefaultBranch, getLocalBranches, getRemoteBranches, getRepositoryRoot, hasUncommittedChanges, isGitRepository, parseBranchLink, parseGitHubUrl, parseIssueUrl, pullLatest, queries, removeBranchLinkFromBody, sanitizeForBranchName, setBranchLinkInBody };
package/dist/index.d.ts CHANGED
@@ -625,6 +625,18 @@ declare function generateBranchName(pattern: string, vars: {
625
625
  title: string;
626
626
  repo: string;
627
627
  }, maxLength?: number): string;
628
+ /**
629
+ * Get all local branches
630
+ */
631
+ declare function getLocalBranches(options?: GitOptions): Promise<string[]>;
632
+ /**
633
+ * Get all remote branches (excluding HEAD), stripped of origin/ prefix
634
+ */
635
+ declare function getRemoteBranches(options?: GitOptions): Promise<string[]>;
636
+ /**
637
+ * Get all branches (local + remote unique)
638
+ */
639
+ declare function getAllBranches(options?: GitOptions): Promise<string[]>;
628
640
  /**
629
641
  * Get the default branch name (main or master)
630
642
  */
@@ -817,4 +829,4 @@ declare namespace queries {
817
829
  export { queries_ADD_COMMENT_MUTATION as ADD_COMMENT_MUTATION, queries_ADD_LABELS_MUTATION as ADD_LABELS_MUTATION, queries_ADD_TO_PROJECT_MUTATION as ADD_TO_PROJECT_MUTATION, queries_COLLABORATORS_QUERY as COLLABORATORS_QUERY, queries_CREATE_ISSUE_MUTATION as CREATE_ISSUE_MUTATION, queries_ISSUES_WITH_LABEL_QUERY as ISSUES_WITH_LABEL_QUERY, queries_ISSUE_AND_LABEL_QUERY as ISSUE_AND_LABEL_QUERY, queries_ISSUE_DETAILS_QUERY as ISSUE_DETAILS_QUERY, queries_ISSUE_FOR_UPDATE_QUERY as ISSUE_FOR_UPDATE_QUERY, queries_ISSUE_NODE_ID_QUERY as ISSUE_NODE_ID_QUERY, queries_ISSUE_TYPES_QUERY as ISSUE_TYPES_QUERY, queries_LABEL_EXISTS_QUERY as LABEL_EXISTS_QUERY, queries_PROJECT_FIELDS_QUERY as PROJECT_FIELDS_QUERY, queries_PROJECT_ITEMS_QUERY as PROJECT_ITEMS_QUERY, queries_PROJECT_VIEWS_QUERY as PROJECT_VIEWS_QUERY, queries_RECENT_ISSUES_QUERY as RECENT_ISSUES_QUERY, queries_REMOVE_LABELS_MUTATION as REMOVE_LABELS_MUTATION, queries_REPOSITORY_ID_QUERY as REPOSITORY_ID_QUERY, queries_REPOSITORY_PROJECTS_QUERY as REPOSITORY_PROJECTS_QUERY, queries_UPDATE_ISSUE_BODY_MUTATION as UPDATE_ISSUE_BODY_MUTATION, queries_UPDATE_ISSUE_MUTATION as UPDATE_ISSUE_MUTATION, queries_UPDATE_ISSUE_TYPE_MUTATION as UPDATE_ISSUE_TYPE_MUTATION, queries_UPDATE_ITEM_FIELD_MUTATION as UPDATE_ITEM_FIELD_MUTATION, queries_UPDATE_ITEM_STATUS_MUTATION as UPDATE_ITEM_STATUS_MUTATION, queries_VIEWER_QUERY as VIEWER_QUERY };
818
830
  }
819
831
 
820
- export { type AssigneeInfo, type AuthError, BranchLinker, type Collaborator, type DateFieldValue, type FieldInfo, type FieldValue, type FieldValueConnection, GitHubAPI, type GitHubAPIOptions, type GitOptions, type IssueDetails, type IssueReference, type IterationFieldValue, type LabelInfo, type NumberFieldValue, type Project, type ProjectConfig, type ProjectItem, type ProjectItemContent, type ProjectItemsQueryResponse, type ProjectV2, type ProjectV2Field, type ProjectV2Item, type ProjectV2View, type ProjectWithViews, type ProjectsQueryResponse, type RepoInfo, type SingleSelectFieldValue, type StatusField, type TextFieldValue, type TokenProvider, branchExists, buildIssueUrl, buildOrgProjectUrl, buildProjectUrl, buildPullRequestUrl, buildRepoUrl, checkoutBranch, createBranch, detectRepository, fetchOrigin, generateBranchName, getCommitsAhead, getCommitsBehind, getCurrentBranch, getDefaultBranch, getRepositoryRoot, hasUncommittedChanges, isGitRepository, parseBranchLink, parseGitHubUrl, parseIssueUrl, pullLatest, queries, removeBranchLinkFromBody, sanitizeForBranchName, setBranchLinkInBody };
832
+ export { type AssigneeInfo, type AuthError, BranchLinker, type Collaborator, type DateFieldValue, type FieldInfo, type FieldValue, type FieldValueConnection, GitHubAPI, type GitHubAPIOptions, type GitOptions, type IssueDetails, type IssueReference, type IterationFieldValue, type LabelInfo, type NumberFieldValue, type Project, type ProjectConfig, type ProjectItem, type ProjectItemContent, type ProjectItemsQueryResponse, type ProjectV2, type ProjectV2Field, type ProjectV2Item, type ProjectV2View, type ProjectWithViews, type ProjectsQueryResponse, type RepoInfo, type SingleSelectFieldValue, type StatusField, type TextFieldValue, type TokenProvider, branchExists, buildIssueUrl, buildOrgProjectUrl, buildProjectUrl, buildPullRequestUrl, buildRepoUrl, checkoutBranch, createBranch, detectRepository, fetchOrigin, generateBranchName, getAllBranches, getCommitsAhead, getCommitsBehind, getCurrentBranch, getDefaultBranch, getLocalBranches, getRemoteBranches, getRepositoryRoot, hasUncommittedChanges, isGitRepository, parseBranchLink, parseGitHubUrl, parseIssueUrl, pullLatest, queries, removeBranchLinkFromBody, sanitizeForBranchName, setBranchLinkInBody };
package/dist/index.js CHANGED
@@ -1178,6 +1178,34 @@ function generateBranchName(pattern, vars, maxLength = 60) {
1178
1178
  }
1179
1179
  return branch;
1180
1180
  }
1181
+ async function getLocalBranches(options = {}) {
1182
+ try {
1183
+ const { stdout } = await execGit('git branch --format="%(refname:short)"', options);
1184
+ return stdout.split("\n").map((b) => b.trim()).filter((b) => b.length > 0);
1185
+ } catch {
1186
+ return [];
1187
+ }
1188
+ }
1189
+ async function getRemoteBranches(options = {}) {
1190
+ try {
1191
+ await execGit("git fetch --prune", options);
1192
+ const { stdout } = await execGit('git branch -r --format="%(refname:short)"', options);
1193
+ return stdout.split("\n").map((b) => b.trim()).filter((b) => b.length > 0 && !b.includes("HEAD")).map((b) => b.replace(/^origin\//, ""));
1194
+ } catch {
1195
+ return [];
1196
+ }
1197
+ }
1198
+ async function getAllBranches(options = {}) {
1199
+ const [local, remote] = await Promise.all([
1200
+ getLocalBranches(options),
1201
+ getRemoteBranches(options)
1202
+ ]);
1203
+ const all = new Set(local);
1204
+ for (const b of remote) {
1205
+ all.add(b);
1206
+ }
1207
+ return Array.from(all);
1208
+ }
1181
1209
  async function getDefaultBranch(options = {}) {
1182
1210
  try {
1183
1211
  const { stdout } = await execGit(
@@ -1210,10 +1238,13 @@ export {
1210
1238
  detectRepository,
1211
1239
  fetchOrigin,
1212
1240
  generateBranchName,
1241
+ getAllBranches,
1213
1242
  getCommitsAhead,
1214
1243
  getCommitsBehind,
1215
1244
  getCurrentBranch,
1216
1245
  getDefaultBranch,
1246
+ getLocalBranches,
1247
+ getRemoteBranches,
1217
1248
  getRepositoryRoot,
1218
1249
  hasUncommittedChanges,
1219
1250
  isGitRepository,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bretwardjames/ghp-core",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Shared core library for GitHub Projects tools",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",