Skip to content

Commit 5956f9c

Browse files
jamesadevineCopilot
andcommitted
refactor: remove redundant area: prefix from comment-on-work-item target field
The target field type system already disambiguates naturally: - number → single work item ID - array of numbers → list of IDs - "*" → wildcard - any other string → area path prefix The area: prefix was unnecessary since no other string variant could collide with area paths. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent e894070 commit 5956f9c

3 files changed

Lines changed: 10 additions & 10 deletions

File tree

AGENTS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -774,14 +774,14 @@ Adds a comment to an existing Azure DevOps work item. This is the ADO equivalent
774774
- `"*"` - Any work item in the project (unrestricted, must be explicit)
775775
- `12345` - A specific work item ID
776776
- `[12345, 67890]` - A list of allowed work item IDs
777-
- `"area:Some\\Path"` - Work items under the specified area path prefix (validated via ADO API at Stage 2)
777+
- `"Some\\Path"` - Work items under the specified area path prefix (any string that isn't `"*"`, validated via ADO API at Stage 2)
778778

779779
**Example configuration:**
780780
```yaml
781781
safe-outputs:
782782
comment-on-work-item:
783783
max: 3
784-
target: "area:4x4\\QED"
784+
target: "4x4\\QED"
785785
```
786786

787787
**Note:** The `target` field is required. If omitted, compilation fails with an error. This ensures operators are intentional about which work items agents can comment on.

src/compile/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ pub fn validate_comment_target(front_matter: &FrontMatter) -> Result<()> {
595595
target: \"*\" # any work item (unrestricted)\n \
596596
target: 12345 # specific work item ID\n \
597597
target: [12345, 67890] # list of work item IDs\n \
598-
target: \"area:Path\" # work items under area path prefix\n"
598+
target: \"Path\\\\Sub\" # work items under area path prefix\n"
599599
);
600600
}
601601
} else {

src/tools/comment_on_work_item.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,18 @@ impl Sanitize for CommentOnWorkItemResult {
4848
/// Target scope for which work items can be commented on.
4949
///
5050
/// Deserialized from the `target` field in front matter:
51-
/// - `"*"` → `Wildcard` (any work item)
52-
/// - `12345` → `Id(12345)` (single work item)
53-
/// - `[12345, 67890]` → `Ids(vec![12345, 67890])` (set of work items)
54-
/// - `"area:Some\\Path"` → `AreaPath("Some\\Path")` (work items under area path prefix)
51+
/// - `"*"` → wildcard (any work item)
52+
/// - `12345` → single work item ID
53+
/// - `[12345, 67890]` → set of work item IDs
54+
/// - `"Some\\Path"` → area path prefix (any string that isn't `"*"`)
5555
#[derive(Debug, Clone, Serialize, Deserialize)]
5656
#[serde(untagged)]
5757
pub enum CommentTarget {
5858
/// A single work item ID
5959
SingleId(i64),
6060
/// A list of work item IDs
6161
IdList(Vec<i64>),
62-
/// A string target: "*" for wildcard, "area:..." for area path
62+
/// A string target: "*" for wildcard, anything else is an area path
6363
StringTarget(String),
6464
}
6565

@@ -78,7 +78,7 @@ impl CommentTarget {
7878
/// Get the area path prefix if this is an area-path target.
7979
pub fn area_path_prefix(&self) -> Option<&str> {
8080
match self {
81-
CommentTarget::StringTarget(s) if s.starts_with("area:") => Some(&s[5..]),
81+
CommentTarget::StringTarget(s) if s != "*" => Some(s.as_str()),
8282
_ => None,
8383
}
8484
}
@@ -433,7 +433,7 @@ target: "*"
433433
#[test]
434434
fn test_config_area_path_target() {
435435
let yaml = r#"
436-
target: "area:4x4\\QED"
436+
target: "4x4\\QED"
437437
"#;
438438
let config: CommentOnWorkItemConfig = serde_yaml::from_str(yaml).unwrap();
439439
assert!(config.target.allows_id(1).is_none());

0 commit comments

Comments
 (0)