Skip to content

Comments

Add private frontmatter field to block add command#17801

Merged
pelikhan merged 3 commits intomainfrom
copilot/add-private-frontmatter-field
Feb 23, 2026
Merged

Add private frontmatter field to block add command#17801
pelikhan merged 3 commits intomainfrom
copilot/add-private-frontmatter-field

Conversation

Copy link
Contributor

Copilot AI commented Feb 23, 2026

Workflows marked private: true should not be installable into other repositories via gh aw add. This adds that enforcement.

Changes

  • FrontmatterConfig (pkg/workflow/frontmatter_types.go): New Private *bool field (pointer, consistent with Strict *bool)
  • ExtractWorkflowPrivate (pkg/cli/packages.go): Helper to read the private field from frontmatter, following the same pattern as ExtractWorkflowDescription/ExtractWorkflowEngine
  • ResolveWorkflows (pkg/cli/add_workflow_resolution.go): Returns an error early if a resolved workflow has private: true; also tracks IsPrivate on ResolvedWorkflow
  • JSON Schema (pkg/parser/schemas/main_workflow_schema.json): Added private field definition with type, default, and description
  • Editor Autocomplete (docs/public/editor/autocomplete-data.json): Added private to the autocomplete data for editor support
  • Reference Docs (docs/src/content/docs/reference/frontmatter-full.md): Regenerated to include the private field

Usage

---
name: Internal Tooling
private: true
on:
  workflow_dispatch:
---

Attempting to gh aw add this workflow from another repo:

workflow 'owner/repo/internal-tooling' is private and cannot be added to other repositories
Original prompt

Add a top-level frontmatter field private, which is a boolean.

This field blocks the add command from adding the workflow as a reference or into another repository. A workflow with private: true is not meant to be shared outside its repository.


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add top-level frontmatter field 'private' as boolean Add private frontmatter field to block add command Feb 23, 2026
Copy link
Contributor

@pelikhan pelikhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot add to json schema

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 23, 2026

@copilot add to json schema

Done in c598450. Added private to pkg/parser/schemas/main_workflow_schema.json (the embedded schema) and docs/public/editor/autocomplete-data.json (editor autocomplete). The docs reference page was also regenerated.

@pelikhan pelikhan marked this pull request as ready for review February 23, 2026 02:51
Copilot AI review requested due to automatic review settings February 23, 2026 02:51
@pelikhan pelikhan merged commit 1c8368c into main Feb 23, 2026
118 checks passed
@pelikhan pelikhan deleted the copilot/add-private-frontmatter-field branch February 23, 2026 02:54
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a private frontmatter field to prevent workflows from being shared across repositories via the gh aw add command. When a workflow is marked with private: true, attempting to add it to another repository will result in an error.

Changes:

  • Added Private field to FrontmatterConfig struct as a pointer type (consistent with Strict field)
  • Implemented ExtractWorkflowPrivate helper function to extract the private field from workflow frontmatter
  • Added validation in ResolveWorkflows to reject workflows with private: true
  • Updated JSON schema, editor autocomplete data, and regenerated reference documentation

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
pkg/workflow/frontmatter_types.go Added Private field to FrontmatterConfig struct
pkg/parser/schemas/main_workflow_schema.json Added private field definition to JSON schema
pkg/cli/packages.go Implemented ExtractWorkflowPrivate helper function
pkg/cli/add_workflow_resolution.go Added private workflow validation and IsPrivate field to ResolvedWorkflow
pkg/cli/add_private_test.go Added unit tests for ExtractWorkflowPrivate function
docs/public/editor/autocomplete-data.json Added private field to editor autocomplete data
docs/src/content/docs/reference/frontmatter-full.md Regenerated documentation to include private field and other schema updates
Comments suppressed due to low confidence (1)

pkg/cli/add_workflow_resolution.go:150

  • The IsPrivate field is set but never used. Since the function returns early on line 134 when a workflow is private, this field will always be false in any ResolvedWorkflow that is successfully created. Consider removing this field from the ResolvedWorkflow struct since it serves no purpose.
			IsPrivate:           isPrivate,

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


// Check if workflow is private - private workflows cannot be added to other repositories
isPrivate := ExtractWorkflowPrivate(string(fetched.Content))
if isPrivate {
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The private check blocks local workflows from being added to the current repository. Lines 78-93 show that workflows from the current repository are intentionally allowed when they are local file paths. However, the private check on line 133 applies to all workflows, including local ones. This means a user with a private workflow file on their local filesystem cannot add it to their own repository, which seems overly restrictive. The private field should only prevent sharing workflows with other repositories, not prevent local use. Consider skipping the private check for local workflows by checking spec.IsLocal or using isLocalWorkflowPath(spec.WorkflowPath) before the private check.

Suggested change
if isPrivate {
if isPrivate && !spec.IsLocal {

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +63
//go:build !integration

package cli

import (
"testing"
)

// TestExtractWorkflowPrivate tests the ExtractWorkflowPrivate function
func TestExtractWorkflowPrivate(t *testing.T) {
tests := []struct {
name string
content string
expected bool
}{
{
name: "workflow with private: true",
content: `---
name: Test Workflow
private: true
on: push
---

# Test Workflow`,
expected: true,
},
{
name: "workflow with private: false",
content: `---
name: Test Workflow
private: false
on: push
---

# Test Workflow`,
expected: false,
},
{
name: "workflow without private field",
content: `---
name: Test Workflow
on: push
---

# Test Workflow`,
expected: false,
},
{
name: "workflow without frontmatter",
content: "# Test Workflow\n\nThis is the workflow content.",
expected: false,
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := ExtractWorkflowPrivate(tt.content)
if result != tt.expected {
t.Errorf("ExtractWorkflowPrivate() = %v, want %v", result, tt.expected)
}
})
}
}
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test file only covers the ExtractWorkflowPrivate function but doesn't test the actual blocking behavior in ResolveWorkflows. Consider adding an integration test that verifies a workflow with private: true is properly rejected when attempting to resolve it for adding to another repository. This would ensure the end-to-end functionality works as expected.

Copilot uses AI. Check for mistakes.
Comment on lines +31 to +32
// IsPrivate indicates if the workflow has private: true in its frontmatter
IsPrivate bool
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the ResolveWorkflows function returns an error when encountering a private workflow (line 134 in add_workflow_resolution.go), the IsPrivate field will always be false for any successfully resolved workflow. This field serves no purpose and should be removed to avoid confusion.

This issue also appears on line 150 of the same file.

Suggested change
// IsPrivate indicates if the workflow has private: true in its frontmatter
IsPrivate bool

Copilot uses AI. Check for mistakes.
github-actions bot added a commit that referenced this pull request Feb 23, 2026
Documents the new `private: true` frontmatter field that prevents
workflows from being installed into other repositories via `gh aw add`.

- Adds Private Workflows section to frontmatter reference
- Adds note about private workflows to the packaging/imports guide

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants