@bretwardjames/ghp-core 0.8.0 → 0.10.0
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 +20 -0
- package/dist/index.cjs +75 -17
- package/dist/index.d.cts +30 -5
- package/dist/index.d.ts +30 -5
- package/dist/index.js +73 -17
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -105,6 +105,21 @@ const result = await withRetry(
|
|
|
105
105
|
const result = await withRetry(() => api.getIssue(repo, 123), DEFAULT_RETRY_CONFIG);
|
|
106
106
|
```
|
|
107
107
|
|
|
108
|
+
### Git Utilities
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
import { listTags, resolveRef, createBranch } from '@bretwardjames/ghp-core';
|
|
112
|
+
|
|
113
|
+
// List git tags sorted by version (newest first)
|
|
114
|
+
const tags = await listTags(); // ['v1.2.0', 'v1.1.0', ...]
|
|
115
|
+
|
|
116
|
+
// Validate and resolve a git ref (tag, commit, branch)
|
|
117
|
+
const sha = await resolveRef('v1.2.0'); // 'abc123...' or null
|
|
118
|
+
|
|
119
|
+
// Create a branch from a specific ref (for hotfixes)
|
|
120
|
+
await createBranch('hotfix/fix-login', { startPoint: 'v1.2.0' });
|
|
121
|
+
```
|
|
122
|
+
|
|
108
123
|
### Shell Utilities
|
|
109
124
|
|
|
110
125
|
Safe shell command construction to prevent injection:
|
|
@@ -120,6 +135,11 @@ const num = validateNumericInput("123", "issue number"); // 123 or throws
|
|
|
120
135
|
|
|
121
136
|
// Validate URLs
|
|
122
137
|
validateUrl("https://github.com/...", "issue URL"); // throws if invalid
|
|
138
|
+
|
|
139
|
+
// Validate git ref strings (rejects shell metacharacters)
|
|
140
|
+
import { validateRefString } from '@bretwardjames/ghp-core';
|
|
141
|
+
validateRefString('v1.2.0'); // ok
|
|
142
|
+
validateRefString('v1; rm -rf /'); // throws Error
|
|
123
143
|
```
|
|
124
144
|
|
|
125
145
|
### Event Hooks
|
package/dist/index.cjs
CHANGED
|
@@ -125,6 +125,7 @@ __export(index_exports, {
|
|
|
125
125
|
isGitRepository: () => isGitRepository,
|
|
126
126
|
isTransientError: () => isTransientError,
|
|
127
127
|
listAgents: () => listAgents,
|
|
128
|
+
listTags: () => listTags,
|
|
128
129
|
listWorktrees: () => listWorktrees,
|
|
129
130
|
loadEventHooksConfig: () => loadEventHooksConfig,
|
|
130
131
|
loadHooksConfig: () => loadHooksConfig,
|
|
@@ -146,6 +147,7 @@ __export(index_exports, {
|
|
|
146
147
|
removeWorktree: () => removeWorktree,
|
|
147
148
|
removeWorktreeWorkflow: () => removeWorktreeWorkflow,
|
|
148
149
|
resolveConflicts: () => resolveConflicts,
|
|
150
|
+
resolveRef: () => resolveRef,
|
|
149
151
|
sanitizeForBranchName: () => sanitizeForBranchName,
|
|
150
152
|
saveEventHooksConfig: () => saveEventHooksConfig,
|
|
151
153
|
saveHooksConfig: () => saveHooksConfig,
|
|
@@ -335,6 +337,10 @@ var PROJECT_FIELDS_QUERY = `
|
|
|
335
337
|
... on ProjectV2IterationField {
|
|
336
338
|
id
|
|
337
339
|
name
|
|
340
|
+
configuration {
|
|
341
|
+
iterations { id title }
|
|
342
|
+
completedIterations { id title }
|
|
343
|
+
}
|
|
338
344
|
}
|
|
339
345
|
}
|
|
340
346
|
}
|
|
@@ -1348,28 +1354,48 @@ var GitHubAPI = class {
|
|
|
1348
1354
|
async getProjectFields(projectId) {
|
|
1349
1355
|
if (!this.graphqlWithAuth) throw new Error("Not authenticated");
|
|
1350
1356
|
const response = await this.graphqlWithRetry(PROJECT_FIELDS_QUERY, { projectId });
|
|
1351
|
-
return response.node.fields.nodes.map((f) =>
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
+
return response.node.fields.nodes.map((f) => {
|
|
1358
|
+
let options = f.options;
|
|
1359
|
+
if (f.configuration) {
|
|
1360
|
+
const all = [...f.configuration.iterations, ...f.configuration.completedIterations];
|
|
1361
|
+
options = all.map((i) => ({ id: i.id, name: i.title }));
|
|
1362
|
+
}
|
|
1363
|
+
return {
|
|
1364
|
+
id: f.id,
|
|
1365
|
+
name: f.name,
|
|
1366
|
+
type: f.__typename.replace("ProjectV2", "").replace("Field", ""),
|
|
1367
|
+
options
|
|
1368
|
+
};
|
|
1369
|
+
});
|
|
1357
1370
|
}
|
|
1358
1371
|
/**
|
|
1359
|
-
* Set a field value on a project item
|
|
1372
|
+
* Set a field value on a project item.
|
|
1373
|
+
* Routes SingleSelect fields through the inline mutation pattern
|
|
1374
|
+
* (passing the option ID as a scalar variable) since GitHub's API
|
|
1375
|
+
* does not reliably deserialize ProjectV2FieldValue input objects.
|
|
1360
1376
|
*/
|
|
1361
1377
|
async setFieldValue(projectId, itemId, fieldId, value) {
|
|
1362
1378
|
if (!this.graphqlWithAuth) throw new Error("Not authenticated");
|
|
1363
1379
|
try {
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1380
|
+
if (value.singleSelectOptionId) {
|
|
1381
|
+
await this.graphqlWithRetry(UPDATE_ITEM_STATUS_MUTATION, {
|
|
1382
|
+
projectId,
|
|
1383
|
+
itemId,
|
|
1384
|
+
fieldId,
|
|
1385
|
+
optionId: value.singleSelectOptionId
|
|
1386
|
+
});
|
|
1387
|
+
} else {
|
|
1388
|
+
await this.graphqlWithRetry(UPDATE_ITEM_FIELD_MUTATION, {
|
|
1389
|
+
projectId,
|
|
1390
|
+
itemId,
|
|
1391
|
+
fieldId,
|
|
1392
|
+
value
|
|
1393
|
+
});
|
|
1394
|
+
}
|
|
1395
|
+
return { success: true };
|
|
1396
|
+
} catch (error) {
|
|
1397
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1398
|
+
return { success: false, error: message };
|
|
1373
1399
|
}
|
|
1374
1400
|
}
|
|
1375
1401
|
/**
|
|
@@ -2333,6 +2359,15 @@ function buildOrgProjectUrl(org, projectNumber) {
|
|
|
2333
2359
|
function sanitizeForPath(input) {
|
|
2334
2360
|
return String(input).replace(/\.\./g, "_").replace(/[;&|`$(){}[\]<>!]/g, "").replace(/\s+/g, "-").replace(/[^a-zA-Z0-9_\-./]/g, "_");
|
|
2335
2361
|
}
|
|
2362
|
+
function validateRefString(ref) {
|
|
2363
|
+
if (!ref || ref.trim().length === 0) {
|
|
2364
|
+
throw new Error("Ref cannot be empty");
|
|
2365
|
+
}
|
|
2366
|
+
const dangerousChars = /[`$\\!;|&<>(){}[\]'"]/;
|
|
2367
|
+
if (dangerousChars.test(ref)) {
|
|
2368
|
+
throw new Error(`Ref contains invalid characters: ${ref}`);
|
|
2369
|
+
}
|
|
2370
|
+
}
|
|
2336
2371
|
function validateBranchName(branch) {
|
|
2337
2372
|
if (!branch || branch.trim().length === 0) {
|
|
2338
2373
|
throw new Error("Branch name cannot be empty");
|
|
@@ -2393,7 +2428,11 @@ async function branchExists(branchName, options = {}) {
|
|
|
2393
2428
|
}
|
|
2394
2429
|
}
|
|
2395
2430
|
async function createBranch(branchName, options = {}) {
|
|
2396
|
-
|
|
2431
|
+
if (options.startPoint) {
|
|
2432
|
+
validateRefString(options.startPoint);
|
|
2433
|
+
}
|
|
2434
|
+
const cmd = options.startPoint ? `git checkout -b "${branchName}" "${options.startPoint}"` : `git checkout -b "${branchName}"`;
|
|
2435
|
+
await execGit(cmd, options);
|
|
2397
2436
|
}
|
|
2398
2437
|
async function checkoutBranch(branchName, options = {}) {
|
|
2399
2438
|
await execGit(`git checkout "${branchName}"`, options);
|
|
@@ -2465,6 +2504,23 @@ function extractIssueNumberFromBranch(branchName) {
|
|
|
2465
2504
|
}
|
|
2466
2505
|
return null;
|
|
2467
2506
|
}
|
|
2507
|
+
async function listTags(options = {}) {
|
|
2508
|
+
try {
|
|
2509
|
+
const { stdout } = await execGit("git tag -l --sort=-version:refname", options);
|
|
2510
|
+
return stdout.split("\n").filter(Boolean);
|
|
2511
|
+
} catch {
|
|
2512
|
+
return [];
|
|
2513
|
+
}
|
|
2514
|
+
}
|
|
2515
|
+
async function resolveRef(ref, options = {}) {
|
|
2516
|
+
validateRefString(ref);
|
|
2517
|
+
try {
|
|
2518
|
+
const { stdout } = await execGit(`git rev-parse --verify "${ref}"`, options);
|
|
2519
|
+
return stdout.trim();
|
|
2520
|
+
} catch {
|
|
2521
|
+
return null;
|
|
2522
|
+
}
|
|
2523
|
+
}
|
|
2468
2524
|
async function getLocalBranches(options = {}) {
|
|
2469
2525
|
const { stdout } = await execGit('git branch --format="%(refname:short)"', options);
|
|
2470
2526
|
return stdout.split("\n").map((b) => b.trim()).filter((b) => b.length > 0);
|
|
@@ -5924,6 +5980,7 @@ EOF
|
|
|
5924
5980
|
isGitRepository,
|
|
5925
5981
|
isTransientError,
|
|
5926
5982
|
listAgents,
|
|
5983
|
+
listTags,
|
|
5927
5984
|
listWorktrees,
|
|
5928
5985
|
loadEventHooksConfig,
|
|
5929
5986
|
loadHooksConfig,
|
|
@@ -5945,6 +6002,7 @@ EOF
|
|
|
5945
6002
|
removeWorktree,
|
|
5946
6003
|
removeWorktreeWorkflow,
|
|
5947
6004
|
resolveConflicts,
|
|
6005
|
+
resolveRef,
|
|
5948
6006
|
sanitizeForBranchName,
|
|
5949
6007
|
saveEventHooksConfig,
|
|
5950
6008
|
saveHooksConfig,
|
package/dist/index.d.cts
CHANGED
|
@@ -557,13 +557,21 @@ declare class GitHubAPI {
|
|
|
557
557
|
}>;
|
|
558
558
|
}>>;
|
|
559
559
|
/**
|
|
560
|
-
* Set a field value on a project item
|
|
560
|
+
* Set a field value on a project item.
|
|
561
|
+
* Routes SingleSelect fields through the inline mutation pattern
|
|
562
|
+
* (passing the option ID as a scalar variable) since GitHub's API
|
|
563
|
+
* does not reliably deserialize ProjectV2FieldValue input objects.
|
|
561
564
|
*/
|
|
562
565
|
setFieldValue(projectId: string, itemId: string, fieldId: string, value: {
|
|
563
566
|
text?: string;
|
|
564
567
|
number?: number;
|
|
565
568
|
singleSelectOptionId?: string;
|
|
566
|
-
|
|
569
|
+
date?: string;
|
|
570
|
+
iterationId?: string;
|
|
571
|
+
}): Promise<{
|
|
572
|
+
success: boolean;
|
|
573
|
+
error?: string;
|
|
574
|
+
}>;
|
|
567
575
|
/**
|
|
568
576
|
* Create a new issue
|
|
569
577
|
*/
|
|
@@ -790,9 +798,13 @@ declare function hasUncommittedChanges(options?: GitOptions): Promise<boolean>;
|
|
|
790
798
|
declare function branchExists(branchName: string, options?: GitOptions): Promise<boolean>;
|
|
791
799
|
/**
|
|
792
800
|
* Create and checkout a new branch.
|
|
801
|
+
* @param branchName - Name for the new branch
|
|
802
|
+
* @param options - Git options. Use `startPoint` to branch from a specific tag, commit, or ref.
|
|
793
803
|
* @throws {GitError} If the branch cannot be created (e.g., already exists, invalid name)
|
|
794
804
|
*/
|
|
795
|
-
declare function createBranch(branchName: string, options?: GitOptions
|
|
805
|
+
declare function createBranch(branchName: string, options?: GitOptions & {
|
|
806
|
+
startPoint?: string;
|
|
807
|
+
}): Promise<void>;
|
|
796
808
|
/**
|
|
797
809
|
* Checkout an existing branch.
|
|
798
810
|
* @throws {GitError} If the branch cannot be checked out (e.g., doesn't exist, uncommitted changes)
|
|
@@ -852,6 +864,19 @@ declare function generateBranchName(pattern: string, vars: {
|
|
|
852
864
|
* - ends with #123 or /123
|
|
853
865
|
*/
|
|
854
866
|
declare function extractIssueNumberFromBranch(branchName: string): number | null;
|
|
867
|
+
/**
|
|
868
|
+
* List git tags, sorted by version (highest version first, using semantic version ordering).
|
|
869
|
+
* @param options - Git options
|
|
870
|
+
* @returns Array of tag names, highest version first
|
|
871
|
+
*/
|
|
872
|
+
declare function listTags(options?: GitOptions): Promise<string[]>;
|
|
873
|
+
/**
|
|
874
|
+
* Verify that a git ref (tag, commit, branch) exists and resolve it to a commit hash.
|
|
875
|
+
* @param ref - Tag name, commit hash, or branch name
|
|
876
|
+
* @param options - Git options
|
|
877
|
+
* @returns The resolved commit hash, or null if the ref doesn't exist
|
|
878
|
+
*/
|
|
879
|
+
declare function resolveRef(ref: string, options?: GitOptions): Promise<string | null>;
|
|
855
880
|
/**
|
|
856
881
|
* Get all local branches.
|
|
857
882
|
* @throws {GitError} If the git command fails (e.g., not a git repo)
|
|
@@ -1162,7 +1187,7 @@ declare const PROJECT_ITEMS_QUERY = "\n query($projectId: ID!, $cursor: Strin
|
|
|
1162
1187
|
/**
|
|
1163
1188
|
* Query to get project fields (including status options)
|
|
1164
1189
|
*/
|
|
1165
|
-
declare const PROJECT_FIELDS_QUERY = "\n query($projectId: ID!) {\n node(id: $projectId) {\n ... on ProjectV2 {\n fields(first: 30) {\n nodes {\n __typename\n ... on ProjectV2Field {\n id\n name\n }\n ... on ProjectV2SingleSelectField {\n id\n name\n options { id name }\n }\n ... on ProjectV2IterationField {\n id\n name\n }\n }\n }\n }\n }\n }\n";
|
|
1190
|
+
declare const PROJECT_FIELDS_QUERY = "\n query($projectId: ID!) {\n node(id: $projectId) {\n ... on ProjectV2 {\n fields(first: 30) {\n nodes {\n __typename\n ... on ProjectV2Field {\n id\n name\n }\n ... on ProjectV2SingleSelectField {\n id\n name\n options { id name }\n }\n ... on ProjectV2IterationField {\n id\n name\n configuration {\n iterations { id title }\n completedIterations { id title }\n }\n }\n }\n }\n }\n }\n }\n";
|
|
1166
1191
|
/**
|
|
1167
1192
|
* Query to get project views
|
|
1168
1193
|
*/
|
|
@@ -3334,4 +3359,4 @@ declare function shouldAbort(results: HookResult[]): boolean;
|
|
|
3334
3359
|
*/
|
|
3335
3360
|
declare function hasHooksForEvent(event: EventType): boolean;
|
|
3336
3361
|
|
|
3337
|
-
export { type ActivityEvent, type AgentInstance, type AgentRegistry, type AgentSessionStatus, type AgentStatus, type AgentSummary, type ApiKeyProvider, type AssigneeInfo, type AuthError, type BaseEventPayload, type BlockingIssue, type BlockingRelationships, type BranchDashboardData, BranchLinker, CLI_TO_VSCODE_MAP, ClaudeClient, type ClaudeClientOptions, type ClaudeResult, type ClaudeTool, type Collaborator, type Commit, type ConflictChoices, type ConflictResolution, type ContentBlock, type CreateIssueOptions, type CreateIssueResult, type CreatePROptions, type CreatePRResult, type CreateWorktreeOptions, type CreateWorktreeResult, DEFAULT_RETRY_CONFIG, DEFAULT_VALUES, type DashboardHook, type DashboardOptions, type DateFieldValue, type DiffStats, type EventHook, type EventHookSettings, type EventHooksConfig, type EventPayload, type EventType, type ExpandIssueOptions, type ExpandedIssue, type FieldInfo, type FieldValue, type FieldValueConnection, type FileChange, type FormatStandupOptions, GHP_TOOLS, type GeneratePRDescriptionOptions, GitError, GitHubAPI, type GitHubAPIOptions, type GitOptions, type HookExecutionOptions, type HookExecutionResult, type HookExitCodes, type HookItem, type HookMode, type HookOutcome, type HookResponse, type HookResult, type HooksConfig, type IssueActivity, type IssueCreatedPayload, type IssueDetails, type IssueReference, type IssueRelationships, type IssueStartedPayload, type IterationFieldValue, type LabelInfo, type Message, type NumberFieldValue, type OnFailureBehavior, type PRInfo, type PermissionPrompt, type PlanEpicOptions, type PlanEpicResult, type PrCreatedPayload, type PrCreatingPayload, type PrMergedPayload, type PrePrPayload, type Project, type ProjectConfig, type ProjectConventions, type ProjectItem, type ProjectItemContent, type ProjectItemsQueryResponse, type ProjectV2, type ProjectV2Field, type ProjectV2Item, type ProjectV2View, type ProjectWithViews, type ProjectsQueryResponse, type RegisterAgentOptions, type RelatedIssue, type RemoveWorktreeOptions, type RemoveWorktreeResult, type RepoInfo, type ResolvedClaudeConfig, type ResolvedSettings, type RetryConfig, SETTING_DISPLAY_NAMES, SYNCABLE_KEYS, type SessionEvent, SessionWatcher, type SettingConflict, type SettingsDiff, type SettingsSource, type SingleSelectFieldValue, type StartIssueOptions, type StartIssueResult, type StatusField, type StreamCallbacks, type StreamErrorEvent, type StreamEvent, type StreamEventBase, type StreamMessageCompleteEvent, type StreamOptions, type StreamTextEvent, type StreamToolInputDeltaEvent, type StreamToolUseCompleteEvent, type StreamToolUseStartEvent, type SyncableSettingKey, type SyncableSettings, TOOL_NAMES, type TextFieldValue, type TokenProvider, type TokenUsage, type ToolContext, type ToolHandler, type ToolHandlers, type UpdateAgentOptions, VSCODE_TO_CLI_MAP, type IssueInfo as WorkflowIssueInfo, type WorkflowResult, type WorktreeInfo as WorkflowWorktreeInfo, type WorktreeCreatedPayload, type WorktreeInfo$1 as WorktreeInfo, type WorktreeRemovedPayload, addEventHook, addHook, branchExists, buildConventionsContext, buildIssueUrl, buildOrgProjectUrl, buildProjectUrl, buildPullRequestUrl, buildRepoUrl, calculateBackoffDelay, checkTmuxForPermission, checkoutBranch, index as claudePrompts, cleanupStaleAgents, computeSettingsDiff, createBranch, createIssueWorkflow, createPRWorkflow, createSessionWatcher, createWorktree, createWorktreeWorkflow, detectRepository, disableEventHook, disableHook, enableEventHook, enableHook, executeAllHooks, executeEventHook, executeHook, executeHooksForEvent, extractIssueNumberFromBranch, fetchOrigin, findSessionFile, formatAction, formatConflict, formatStandupText, gatherDashboardData, generateBranchName, generateWorktreePath, getAgent, getAgentByIssue, getAgentSummaries, getAllBranches, getChangedFiles, getCommitHistory, getCommitsAhead, getCommitsBehind, getCurrentBranch$1 as getCurrentBranch, getCurrentBranch as getDashboardCurrentBranch, getDefaultBaseBranch, getDefaultBranch, getDiffStats, getDiffSummary, getEnabledEventHooks, getEnabledHooks, getEventHook, getEventHooks, getEventHooksConfigPath, getEventSettings, getFullDiff, getGitHubRepo, getHook, getHooks, getHooksByCategory, getHooksConfigPath, getHooksForEvent, getIssueReferenceText, getLocalBranches, getRegistryPath, getRemoteBranches, getRepositoryRoot, getTools, getValidEventTypes, getValidModes, getValidOnFailureBehaviors, getWorktreeForBranch, hasDifferences, hasHooksForEvent, hasUncommittedChanges, isGitRepository, isTransientError, listAgents, listWorktrees, loadEventHooksConfig, loadHooksConfig, loadProjectConventions, loadRegistry, normalizeVSCodeSettings, parseBranchLink, parseGitHubUrl, parseIssueUrl, parseRateLimitDelay, parseSessionLine, parseSince, pullLatest, queries, registerAgent, removeBranchLinkFromBody, removeEventHook, removeHook, removeWorktree, removeWorktreeWorkflow, resolveConflicts, sanitizeForBranchName, saveEventHooksConfig, saveHooksConfig, saveRegistry, setBranchLinkInBody, shellEscape, shouldAbort, skip, startIssueWorkflow, substituteTemplateVariables, toVSCodeSettings, unregisterAgent, updateAgent, updateEventHook, updateHook, useCli, useCustom, useVSCode, validateNumericInput, validateSafeString, validateUrl, withRetry, worktreeExists, wrapWithRetry };
|
|
3362
|
+
export { type ActivityEvent, type AgentInstance, type AgentRegistry, type AgentSessionStatus, type AgentStatus, type AgentSummary, type ApiKeyProvider, type AssigneeInfo, type AuthError, type BaseEventPayload, type BlockingIssue, type BlockingRelationships, type BranchDashboardData, BranchLinker, CLI_TO_VSCODE_MAP, ClaudeClient, type ClaudeClientOptions, type ClaudeResult, type ClaudeTool, type Collaborator, type Commit, type ConflictChoices, type ConflictResolution, type ContentBlock, type CreateIssueOptions, type CreateIssueResult, type CreatePROptions, type CreatePRResult, type CreateWorktreeOptions, type CreateWorktreeResult, DEFAULT_RETRY_CONFIG, DEFAULT_VALUES, type DashboardHook, type DashboardOptions, type DateFieldValue, type DiffStats, type EventHook, type EventHookSettings, type EventHooksConfig, type EventPayload, type EventType, type ExpandIssueOptions, type ExpandedIssue, type FieldInfo, type FieldValue, type FieldValueConnection, type FileChange, type FormatStandupOptions, GHP_TOOLS, type GeneratePRDescriptionOptions, GitError, GitHubAPI, type GitHubAPIOptions, type GitOptions, type HookExecutionOptions, type HookExecutionResult, type HookExitCodes, type HookItem, type HookMode, type HookOutcome, type HookResponse, type HookResult, type HooksConfig, type IssueActivity, type IssueCreatedPayload, type IssueDetails, type IssueReference, type IssueRelationships, type IssueStartedPayload, type IterationFieldValue, type LabelInfo, type Message, type NumberFieldValue, type OnFailureBehavior, type PRInfo, type PermissionPrompt, type PlanEpicOptions, type PlanEpicResult, type PrCreatedPayload, type PrCreatingPayload, type PrMergedPayload, type PrePrPayload, type Project, type ProjectConfig, type ProjectConventions, type ProjectItem, type ProjectItemContent, type ProjectItemsQueryResponse, type ProjectV2, type ProjectV2Field, type ProjectV2Item, type ProjectV2View, type ProjectWithViews, type ProjectsQueryResponse, type RegisterAgentOptions, type RelatedIssue, type RemoveWorktreeOptions, type RemoveWorktreeResult, type RepoInfo, type ResolvedClaudeConfig, type ResolvedSettings, type RetryConfig, SETTING_DISPLAY_NAMES, SYNCABLE_KEYS, type SessionEvent, SessionWatcher, type SettingConflict, type SettingsDiff, type SettingsSource, type SingleSelectFieldValue, type StartIssueOptions, type StartIssueResult, type StatusField, type StreamCallbacks, type StreamErrorEvent, type StreamEvent, type StreamEventBase, type StreamMessageCompleteEvent, type StreamOptions, type StreamTextEvent, type StreamToolInputDeltaEvent, type StreamToolUseCompleteEvent, type StreamToolUseStartEvent, type SyncableSettingKey, type SyncableSettings, TOOL_NAMES, type TextFieldValue, type TokenProvider, type TokenUsage, type ToolContext, type ToolHandler, type ToolHandlers, type UpdateAgentOptions, VSCODE_TO_CLI_MAP, type IssueInfo as WorkflowIssueInfo, type WorkflowResult, type WorktreeInfo as WorkflowWorktreeInfo, type WorktreeCreatedPayload, type WorktreeInfo$1 as WorktreeInfo, type WorktreeRemovedPayload, addEventHook, addHook, branchExists, buildConventionsContext, buildIssueUrl, buildOrgProjectUrl, buildProjectUrl, buildPullRequestUrl, buildRepoUrl, calculateBackoffDelay, checkTmuxForPermission, checkoutBranch, index as claudePrompts, cleanupStaleAgents, computeSettingsDiff, createBranch, createIssueWorkflow, createPRWorkflow, createSessionWatcher, createWorktree, createWorktreeWorkflow, detectRepository, disableEventHook, disableHook, enableEventHook, enableHook, executeAllHooks, executeEventHook, executeHook, executeHooksForEvent, extractIssueNumberFromBranch, fetchOrigin, findSessionFile, formatAction, formatConflict, formatStandupText, gatherDashboardData, generateBranchName, generateWorktreePath, getAgent, getAgentByIssue, getAgentSummaries, getAllBranches, getChangedFiles, getCommitHistory, getCommitsAhead, getCommitsBehind, getCurrentBranch$1 as getCurrentBranch, getCurrentBranch as getDashboardCurrentBranch, getDefaultBaseBranch, getDefaultBranch, getDiffStats, getDiffSummary, getEnabledEventHooks, getEnabledHooks, getEventHook, getEventHooks, getEventHooksConfigPath, getEventSettings, getFullDiff, getGitHubRepo, getHook, getHooks, getHooksByCategory, getHooksConfigPath, getHooksForEvent, getIssueReferenceText, getLocalBranches, getRegistryPath, getRemoteBranches, getRepositoryRoot, getTools, getValidEventTypes, getValidModes, getValidOnFailureBehaviors, getWorktreeForBranch, hasDifferences, hasHooksForEvent, hasUncommittedChanges, isGitRepository, isTransientError, listAgents, listTags, listWorktrees, loadEventHooksConfig, loadHooksConfig, loadProjectConventions, loadRegistry, normalizeVSCodeSettings, parseBranchLink, parseGitHubUrl, parseIssueUrl, parseRateLimitDelay, parseSessionLine, parseSince, pullLatest, queries, registerAgent, removeBranchLinkFromBody, removeEventHook, removeHook, removeWorktree, removeWorktreeWorkflow, resolveConflicts, resolveRef, sanitizeForBranchName, saveEventHooksConfig, saveHooksConfig, saveRegistry, setBranchLinkInBody, shellEscape, shouldAbort, skip, startIssueWorkflow, substituteTemplateVariables, toVSCodeSettings, unregisterAgent, updateAgent, updateEventHook, updateHook, useCli, useCustom, useVSCode, validateNumericInput, validateSafeString, validateUrl, withRetry, worktreeExists, wrapWithRetry };
|
package/dist/index.d.ts
CHANGED
|
@@ -557,13 +557,21 @@ declare class GitHubAPI {
|
|
|
557
557
|
}>;
|
|
558
558
|
}>>;
|
|
559
559
|
/**
|
|
560
|
-
* Set a field value on a project item
|
|
560
|
+
* Set a field value on a project item.
|
|
561
|
+
* Routes SingleSelect fields through the inline mutation pattern
|
|
562
|
+
* (passing the option ID as a scalar variable) since GitHub's API
|
|
563
|
+
* does not reliably deserialize ProjectV2FieldValue input objects.
|
|
561
564
|
*/
|
|
562
565
|
setFieldValue(projectId: string, itemId: string, fieldId: string, value: {
|
|
563
566
|
text?: string;
|
|
564
567
|
number?: number;
|
|
565
568
|
singleSelectOptionId?: string;
|
|
566
|
-
|
|
569
|
+
date?: string;
|
|
570
|
+
iterationId?: string;
|
|
571
|
+
}): Promise<{
|
|
572
|
+
success: boolean;
|
|
573
|
+
error?: string;
|
|
574
|
+
}>;
|
|
567
575
|
/**
|
|
568
576
|
* Create a new issue
|
|
569
577
|
*/
|
|
@@ -790,9 +798,13 @@ declare function hasUncommittedChanges(options?: GitOptions): Promise<boolean>;
|
|
|
790
798
|
declare function branchExists(branchName: string, options?: GitOptions): Promise<boolean>;
|
|
791
799
|
/**
|
|
792
800
|
* Create and checkout a new branch.
|
|
801
|
+
* @param branchName - Name for the new branch
|
|
802
|
+
* @param options - Git options. Use `startPoint` to branch from a specific tag, commit, or ref.
|
|
793
803
|
* @throws {GitError} If the branch cannot be created (e.g., already exists, invalid name)
|
|
794
804
|
*/
|
|
795
|
-
declare function createBranch(branchName: string, options?: GitOptions
|
|
805
|
+
declare function createBranch(branchName: string, options?: GitOptions & {
|
|
806
|
+
startPoint?: string;
|
|
807
|
+
}): Promise<void>;
|
|
796
808
|
/**
|
|
797
809
|
* Checkout an existing branch.
|
|
798
810
|
* @throws {GitError} If the branch cannot be checked out (e.g., doesn't exist, uncommitted changes)
|
|
@@ -852,6 +864,19 @@ declare function generateBranchName(pattern: string, vars: {
|
|
|
852
864
|
* - ends with #123 or /123
|
|
853
865
|
*/
|
|
854
866
|
declare function extractIssueNumberFromBranch(branchName: string): number | null;
|
|
867
|
+
/**
|
|
868
|
+
* List git tags, sorted by version (highest version first, using semantic version ordering).
|
|
869
|
+
* @param options - Git options
|
|
870
|
+
* @returns Array of tag names, highest version first
|
|
871
|
+
*/
|
|
872
|
+
declare function listTags(options?: GitOptions): Promise<string[]>;
|
|
873
|
+
/**
|
|
874
|
+
* Verify that a git ref (tag, commit, branch) exists and resolve it to a commit hash.
|
|
875
|
+
* @param ref - Tag name, commit hash, or branch name
|
|
876
|
+
* @param options - Git options
|
|
877
|
+
* @returns The resolved commit hash, or null if the ref doesn't exist
|
|
878
|
+
*/
|
|
879
|
+
declare function resolveRef(ref: string, options?: GitOptions): Promise<string | null>;
|
|
855
880
|
/**
|
|
856
881
|
* Get all local branches.
|
|
857
882
|
* @throws {GitError} If the git command fails (e.g., not a git repo)
|
|
@@ -1162,7 +1187,7 @@ declare const PROJECT_ITEMS_QUERY = "\n query($projectId: ID!, $cursor: Strin
|
|
|
1162
1187
|
/**
|
|
1163
1188
|
* Query to get project fields (including status options)
|
|
1164
1189
|
*/
|
|
1165
|
-
declare const PROJECT_FIELDS_QUERY = "\n query($projectId: ID!) {\n node(id: $projectId) {\n ... on ProjectV2 {\n fields(first: 30) {\n nodes {\n __typename\n ... on ProjectV2Field {\n id\n name\n }\n ... on ProjectV2SingleSelectField {\n id\n name\n options { id name }\n }\n ... on ProjectV2IterationField {\n id\n name\n }\n }\n }\n }\n }\n }\n";
|
|
1190
|
+
declare const PROJECT_FIELDS_QUERY = "\n query($projectId: ID!) {\n node(id: $projectId) {\n ... on ProjectV2 {\n fields(first: 30) {\n nodes {\n __typename\n ... on ProjectV2Field {\n id\n name\n }\n ... on ProjectV2SingleSelectField {\n id\n name\n options { id name }\n }\n ... on ProjectV2IterationField {\n id\n name\n configuration {\n iterations { id title }\n completedIterations { id title }\n }\n }\n }\n }\n }\n }\n }\n";
|
|
1166
1191
|
/**
|
|
1167
1192
|
* Query to get project views
|
|
1168
1193
|
*/
|
|
@@ -3334,4 +3359,4 @@ declare function shouldAbort(results: HookResult[]): boolean;
|
|
|
3334
3359
|
*/
|
|
3335
3360
|
declare function hasHooksForEvent(event: EventType): boolean;
|
|
3336
3361
|
|
|
3337
|
-
export { type ActivityEvent, type AgentInstance, type AgentRegistry, type AgentSessionStatus, type AgentStatus, type AgentSummary, type ApiKeyProvider, type AssigneeInfo, type AuthError, type BaseEventPayload, type BlockingIssue, type BlockingRelationships, type BranchDashboardData, BranchLinker, CLI_TO_VSCODE_MAP, ClaudeClient, type ClaudeClientOptions, type ClaudeResult, type ClaudeTool, type Collaborator, type Commit, type ConflictChoices, type ConflictResolution, type ContentBlock, type CreateIssueOptions, type CreateIssueResult, type CreatePROptions, type CreatePRResult, type CreateWorktreeOptions, type CreateWorktreeResult, DEFAULT_RETRY_CONFIG, DEFAULT_VALUES, type DashboardHook, type DashboardOptions, type DateFieldValue, type DiffStats, type EventHook, type EventHookSettings, type EventHooksConfig, type EventPayload, type EventType, type ExpandIssueOptions, type ExpandedIssue, type FieldInfo, type FieldValue, type FieldValueConnection, type FileChange, type FormatStandupOptions, GHP_TOOLS, type GeneratePRDescriptionOptions, GitError, GitHubAPI, type GitHubAPIOptions, type GitOptions, type HookExecutionOptions, type HookExecutionResult, type HookExitCodes, type HookItem, type HookMode, type HookOutcome, type HookResponse, type HookResult, type HooksConfig, type IssueActivity, type IssueCreatedPayload, type IssueDetails, type IssueReference, type IssueRelationships, type IssueStartedPayload, type IterationFieldValue, type LabelInfo, type Message, type NumberFieldValue, type OnFailureBehavior, type PRInfo, type PermissionPrompt, type PlanEpicOptions, type PlanEpicResult, type PrCreatedPayload, type PrCreatingPayload, type PrMergedPayload, type PrePrPayload, type Project, type ProjectConfig, type ProjectConventions, type ProjectItem, type ProjectItemContent, type ProjectItemsQueryResponse, type ProjectV2, type ProjectV2Field, type ProjectV2Item, type ProjectV2View, type ProjectWithViews, type ProjectsQueryResponse, type RegisterAgentOptions, type RelatedIssue, type RemoveWorktreeOptions, type RemoveWorktreeResult, type RepoInfo, type ResolvedClaudeConfig, type ResolvedSettings, type RetryConfig, SETTING_DISPLAY_NAMES, SYNCABLE_KEYS, type SessionEvent, SessionWatcher, type SettingConflict, type SettingsDiff, type SettingsSource, type SingleSelectFieldValue, type StartIssueOptions, type StartIssueResult, type StatusField, type StreamCallbacks, type StreamErrorEvent, type StreamEvent, type StreamEventBase, type StreamMessageCompleteEvent, type StreamOptions, type StreamTextEvent, type StreamToolInputDeltaEvent, type StreamToolUseCompleteEvent, type StreamToolUseStartEvent, type SyncableSettingKey, type SyncableSettings, TOOL_NAMES, type TextFieldValue, type TokenProvider, type TokenUsage, type ToolContext, type ToolHandler, type ToolHandlers, type UpdateAgentOptions, VSCODE_TO_CLI_MAP, type IssueInfo as WorkflowIssueInfo, type WorkflowResult, type WorktreeInfo as WorkflowWorktreeInfo, type WorktreeCreatedPayload, type WorktreeInfo$1 as WorktreeInfo, type WorktreeRemovedPayload, addEventHook, addHook, branchExists, buildConventionsContext, buildIssueUrl, buildOrgProjectUrl, buildProjectUrl, buildPullRequestUrl, buildRepoUrl, calculateBackoffDelay, checkTmuxForPermission, checkoutBranch, index as claudePrompts, cleanupStaleAgents, computeSettingsDiff, createBranch, createIssueWorkflow, createPRWorkflow, createSessionWatcher, createWorktree, createWorktreeWorkflow, detectRepository, disableEventHook, disableHook, enableEventHook, enableHook, executeAllHooks, executeEventHook, executeHook, executeHooksForEvent, extractIssueNumberFromBranch, fetchOrigin, findSessionFile, formatAction, formatConflict, formatStandupText, gatherDashboardData, generateBranchName, generateWorktreePath, getAgent, getAgentByIssue, getAgentSummaries, getAllBranches, getChangedFiles, getCommitHistory, getCommitsAhead, getCommitsBehind, getCurrentBranch$1 as getCurrentBranch, getCurrentBranch as getDashboardCurrentBranch, getDefaultBaseBranch, getDefaultBranch, getDiffStats, getDiffSummary, getEnabledEventHooks, getEnabledHooks, getEventHook, getEventHooks, getEventHooksConfigPath, getEventSettings, getFullDiff, getGitHubRepo, getHook, getHooks, getHooksByCategory, getHooksConfigPath, getHooksForEvent, getIssueReferenceText, getLocalBranches, getRegistryPath, getRemoteBranches, getRepositoryRoot, getTools, getValidEventTypes, getValidModes, getValidOnFailureBehaviors, getWorktreeForBranch, hasDifferences, hasHooksForEvent, hasUncommittedChanges, isGitRepository, isTransientError, listAgents, listWorktrees, loadEventHooksConfig, loadHooksConfig, loadProjectConventions, loadRegistry, normalizeVSCodeSettings, parseBranchLink, parseGitHubUrl, parseIssueUrl, parseRateLimitDelay, parseSessionLine, parseSince, pullLatest, queries, registerAgent, removeBranchLinkFromBody, removeEventHook, removeHook, removeWorktree, removeWorktreeWorkflow, resolveConflicts, sanitizeForBranchName, saveEventHooksConfig, saveHooksConfig, saveRegistry, setBranchLinkInBody, shellEscape, shouldAbort, skip, startIssueWorkflow, substituteTemplateVariables, toVSCodeSettings, unregisterAgent, updateAgent, updateEventHook, updateHook, useCli, useCustom, useVSCode, validateNumericInput, validateSafeString, validateUrl, withRetry, worktreeExists, wrapWithRetry };
|
|
3362
|
+
export { type ActivityEvent, type AgentInstance, type AgentRegistry, type AgentSessionStatus, type AgentStatus, type AgentSummary, type ApiKeyProvider, type AssigneeInfo, type AuthError, type BaseEventPayload, type BlockingIssue, type BlockingRelationships, type BranchDashboardData, BranchLinker, CLI_TO_VSCODE_MAP, ClaudeClient, type ClaudeClientOptions, type ClaudeResult, type ClaudeTool, type Collaborator, type Commit, type ConflictChoices, type ConflictResolution, type ContentBlock, type CreateIssueOptions, type CreateIssueResult, type CreatePROptions, type CreatePRResult, type CreateWorktreeOptions, type CreateWorktreeResult, DEFAULT_RETRY_CONFIG, DEFAULT_VALUES, type DashboardHook, type DashboardOptions, type DateFieldValue, type DiffStats, type EventHook, type EventHookSettings, type EventHooksConfig, type EventPayload, type EventType, type ExpandIssueOptions, type ExpandedIssue, type FieldInfo, type FieldValue, type FieldValueConnection, type FileChange, type FormatStandupOptions, GHP_TOOLS, type GeneratePRDescriptionOptions, GitError, GitHubAPI, type GitHubAPIOptions, type GitOptions, type HookExecutionOptions, type HookExecutionResult, type HookExitCodes, type HookItem, type HookMode, type HookOutcome, type HookResponse, type HookResult, type HooksConfig, type IssueActivity, type IssueCreatedPayload, type IssueDetails, type IssueReference, type IssueRelationships, type IssueStartedPayload, type IterationFieldValue, type LabelInfo, type Message, type NumberFieldValue, type OnFailureBehavior, type PRInfo, type PermissionPrompt, type PlanEpicOptions, type PlanEpicResult, type PrCreatedPayload, type PrCreatingPayload, type PrMergedPayload, type PrePrPayload, type Project, type ProjectConfig, type ProjectConventions, type ProjectItem, type ProjectItemContent, type ProjectItemsQueryResponse, type ProjectV2, type ProjectV2Field, type ProjectV2Item, type ProjectV2View, type ProjectWithViews, type ProjectsQueryResponse, type RegisterAgentOptions, type RelatedIssue, type RemoveWorktreeOptions, type RemoveWorktreeResult, type RepoInfo, type ResolvedClaudeConfig, type ResolvedSettings, type RetryConfig, SETTING_DISPLAY_NAMES, SYNCABLE_KEYS, type SessionEvent, SessionWatcher, type SettingConflict, type SettingsDiff, type SettingsSource, type SingleSelectFieldValue, type StartIssueOptions, type StartIssueResult, type StatusField, type StreamCallbacks, type StreamErrorEvent, type StreamEvent, type StreamEventBase, type StreamMessageCompleteEvent, type StreamOptions, type StreamTextEvent, type StreamToolInputDeltaEvent, type StreamToolUseCompleteEvent, type StreamToolUseStartEvent, type SyncableSettingKey, type SyncableSettings, TOOL_NAMES, type TextFieldValue, type TokenProvider, type TokenUsage, type ToolContext, type ToolHandler, type ToolHandlers, type UpdateAgentOptions, VSCODE_TO_CLI_MAP, type IssueInfo as WorkflowIssueInfo, type WorkflowResult, type WorktreeInfo as WorkflowWorktreeInfo, type WorktreeCreatedPayload, type WorktreeInfo$1 as WorktreeInfo, type WorktreeRemovedPayload, addEventHook, addHook, branchExists, buildConventionsContext, buildIssueUrl, buildOrgProjectUrl, buildProjectUrl, buildPullRequestUrl, buildRepoUrl, calculateBackoffDelay, checkTmuxForPermission, checkoutBranch, index as claudePrompts, cleanupStaleAgents, computeSettingsDiff, createBranch, createIssueWorkflow, createPRWorkflow, createSessionWatcher, createWorktree, createWorktreeWorkflow, detectRepository, disableEventHook, disableHook, enableEventHook, enableHook, executeAllHooks, executeEventHook, executeHook, executeHooksForEvent, extractIssueNumberFromBranch, fetchOrigin, findSessionFile, formatAction, formatConflict, formatStandupText, gatherDashboardData, generateBranchName, generateWorktreePath, getAgent, getAgentByIssue, getAgentSummaries, getAllBranches, getChangedFiles, getCommitHistory, getCommitsAhead, getCommitsBehind, getCurrentBranch$1 as getCurrentBranch, getCurrentBranch as getDashboardCurrentBranch, getDefaultBaseBranch, getDefaultBranch, getDiffStats, getDiffSummary, getEnabledEventHooks, getEnabledHooks, getEventHook, getEventHooks, getEventHooksConfigPath, getEventSettings, getFullDiff, getGitHubRepo, getHook, getHooks, getHooksByCategory, getHooksConfigPath, getHooksForEvent, getIssueReferenceText, getLocalBranches, getRegistryPath, getRemoteBranches, getRepositoryRoot, getTools, getValidEventTypes, getValidModes, getValidOnFailureBehaviors, getWorktreeForBranch, hasDifferences, hasHooksForEvent, hasUncommittedChanges, isGitRepository, isTransientError, listAgents, listTags, listWorktrees, loadEventHooksConfig, loadHooksConfig, loadProjectConventions, loadRegistry, normalizeVSCodeSettings, parseBranchLink, parseGitHubUrl, parseIssueUrl, parseRateLimitDelay, parseSessionLine, parseSince, pullLatest, queries, registerAgent, removeBranchLinkFromBody, removeEventHook, removeHook, removeWorktree, removeWorktreeWorkflow, resolveConflicts, resolveRef, sanitizeForBranchName, saveEventHooksConfig, saveHooksConfig, saveRegistry, setBranchLinkInBody, shellEscape, shouldAbort, skip, startIssueWorkflow, substituteTemplateVariables, toVSCodeSettings, unregisterAgent, updateAgent, updateEventHook, updateHook, useCli, useCustom, useVSCode, validateNumericInput, validateSafeString, validateUrl, withRetry, worktreeExists, wrapWithRetry };
|
package/dist/index.js
CHANGED
|
@@ -166,6 +166,10 @@ var PROJECT_FIELDS_QUERY = `
|
|
|
166
166
|
... on ProjectV2IterationField {
|
|
167
167
|
id
|
|
168
168
|
name
|
|
169
|
+
configuration {
|
|
170
|
+
iterations { id title }
|
|
171
|
+
completedIterations { id title }
|
|
172
|
+
}
|
|
169
173
|
}
|
|
170
174
|
}
|
|
171
175
|
}
|
|
@@ -1179,28 +1183,48 @@ var GitHubAPI = class {
|
|
|
1179
1183
|
async getProjectFields(projectId) {
|
|
1180
1184
|
if (!this.graphqlWithAuth) throw new Error("Not authenticated");
|
|
1181
1185
|
const response = await this.graphqlWithRetry(PROJECT_FIELDS_QUERY, { projectId });
|
|
1182
|
-
return response.node.fields.nodes.map((f) =>
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1186
|
+
return response.node.fields.nodes.map((f) => {
|
|
1187
|
+
let options = f.options;
|
|
1188
|
+
if (f.configuration) {
|
|
1189
|
+
const all = [...f.configuration.iterations, ...f.configuration.completedIterations];
|
|
1190
|
+
options = all.map((i) => ({ id: i.id, name: i.title }));
|
|
1191
|
+
}
|
|
1192
|
+
return {
|
|
1193
|
+
id: f.id,
|
|
1194
|
+
name: f.name,
|
|
1195
|
+
type: f.__typename.replace("ProjectV2", "").replace("Field", ""),
|
|
1196
|
+
options
|
|
1197
|
+
};
|
|
1198
|
+
});
|
|
1188
1199
|
}
|
|
1189
1200
|
/**
|
|
1190
|
-
* Set a field value on a project item
|
|
1201
|
+
* Set a field value on a project item.
|
|
1202
|
+
* Routes SingleSelect fields through the inline mutation pattern
|
|
1203
|
+
* (passing the option ID as a scalar variable) since GitHub's API
|
|
1204
|
+
* does not reliably deserialize ProjectV2FieldValue input objects.
|
|
1191
1205
|
*/
|
|
1192
1206
|
async setFieldValue(projectId, itemId, fieldId, value) {
|
|
1193
1207
|
if (!this.graphqlWithAuth) throw new Error("Not authenticated");
|
|
1194
1208
|
try {
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1209
|
+
if (value.singleSelectOptionId) {
|
|
1210
|
+
await this.graphqlWithRetry(UPDATE_ITEM_STATUS_MUTATION, {
|
|
1211
|
+
projectId,
|
|
1212
|
+
itemId,
|
|
1213
|
+
fieldId,
|
|
1214
|
+
optionId: value.singleSelectOptionId
|
|
1215
|
+
});
|
|
1216
|
+
} else {
|
|
1217
|
+
await this.graphqlWithRetry(UPDATE_ITEM_FIELD_MUTATION, {
|
|
1218
|
+
projectId,
|
|
1219
|
+
itemId,
|
|
1220
|
+
fieldId,
|
|
1221
|
+
value
|
|
1222
|
+
});
|
|
1223
|
+
}
|
|
1224
|
+
return { success: true };
|
|
1225
|
+
} catch (error) {
|
|
1226
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1227
|
+
return { success: false, error: message };
|
|
1204
1228
|
}
|
|
1205
1229
|
}
|
|
1206
1230
|
/**
|
|
@@ -2164,6 +2188,15 @@ function buildOrgProjectUrl(org, projectNumber) {
|
|
|
2164
2188
|
function sanitizeForPath(input) {
|
|
2165
2189
|
return String(input).replace(/\.\./g, "_").replace(/[;&|`$(){}[\]<>!]/g, "").replace(/\s+/g, "-").replace(/[^a-zA-Z0-9_\-./]/g, "_");
|
|
2166
2190
|
}
|
|
2191
|
+
function validateRefString(ref) {
|
|
2192
|
+
if (!ref || ref.trim().length === 0) {
|
|
2193
|
+
throw new Error("Ref cannot be empty");
|
|
2194
|
+
}
|
|
2195
|
+
const dangerousChars = /[`$\\!;|&<>(){}[\]'"]/;
|
|
2196
|
+
if (dangerousChars.test(ref)) {
|
|
2197
|
+
throw new Error(`Ref contains invalid characters: ${ref}`);
|
|
2198
|
+
}
|
|
2199
|
+
}
|
|
2167
2200
|
function validateBranchName(branch) {
|
|
2168
2201
|
if (!branch || branch.trim().length === 0) {
|
|
2169
2202
|
throw new Error("Branch name cannot be empty");
|
|
@@ -2224,7 +2257,11 @@ async function branchExists(branchName, options = {}) {
|
|
|
2224
2257
|
}
|
|
2225
2258
|
}
|
|
2226
2259
|
async function createBranch(branchName, options = {}) {
|
|
2227
|
-
|
|
2260
|
+
if (options.startPoint) {
|
|
2261
|
+
validateRefString(options.startPoint);
|
|
2262
|
+
}
|
|
2263
|
+
const cmd = options.startPoint ? `git checkout -b "${branchName}" "${options.startPoint}"` : `git checkout -b "${branchName}"`;
|
|
2264
|
+
await execGit(cmd, options);
|
|
2228
2265
|
}
|
|
2229
2266
|
async function checkoutBranch(branchName, options = {}) {
|
|
2230
2267
|
await execGit(`git checkout "${branchName}"`, options);
|
|
@@ -2296,6 +2333,23 @@ function extractIssueNumberFromBranch(branchName) {
|
|
|
2296
2333
|
}
|
|
2297
2334
|
return null;
|
|
2298
2335
|
}
|
|
2336
|
+
async function listTags(options = {}) {
|
|
2337
|
+
try {
|
|
2338
|
+
const { stdout } = await execGit("git tag -l --sort=-version:refname", options);
|
|
2339
|
+
return stdout.split("\n").filter(Boolean);
|
|
2340
|
+
} catch {
|
|
2341
|
+
return [];
|
|
2342
|
+
}
|
|
2343
|
+
}
|
|
2344
|
+
async function resolveRef(ref, options = {}) {
|
|
2345
|
+
validateRefString(ref);
|
|
2346
|
+
try {
|
|
2347
|
+
const { stdout } = await execGit(`git rev-parse --verify "${ref}"`, options);
|
|
2348
|
+
return stdout.trim();
|
|
2349
|
+
} catch {
|
|
2350
|
+
return null;
|
|
2351
|
+
}
|
|
2352
|
+
}
|
|
2299
2353
|
async function getLocalBranches(options = {}) {
|
|
2300
2354
|
const { stdout } = await execGit('git branch --format="%(refname:short)"', options);
|
|
2301
2355
|
return stdout.split("\n").map((b) => b.trim()).filter((b) => b.length > 0);
|
|
@@ -5754,6 +5808,7 @@ export {
|
|
|
5754
5808
|
isGitRepository,
|
|
5755
5809
|
isTransientError,
|
|
5756
5810
|
listAgents,
|
|
5811
|
+
listTags,
|
|
5757
5812
|
listWorktrees,
|
|
5758
5813
|
loadEventHooksConfig,
|
|
5759
5814
|
loadHooksConfig,
|
|
@@ -5775,6 +5830,7 @@ export {
|
|
|
5775
5830
|
removeWorktree,
|
|
5776
5831
|
removeWorktreeWorkflow,
|
|
5777
5832
|
resolveConflicts,
|
|
5833
|
+
resolveRef,
|
|
5778
5834
|
sanitizeForBranchName,
|
|
5779
5835
|
saveEventHooksConfig,
|
|
5780
5836
|
saveHooksConfig,
|