Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
ee20fa7
feat: Set up agent skills management architecture
reidbaker Jun 17, 2026
26b37ae
feat: Add check-readiness skill
reidbaker Jun 17, 2026
d825767
feat: Add local check-readiness skill and configure linter
reidbaker Jun 17, 2026
f7f0646
test: ensure tracked skills cannot be published accidentally
reidbaker Jun 17, 2026
ea27e43
build: pin dart_skills_lint to support individual_skills
reidbaker Jun 17, 2026
9ac31a2
test: rewrite tracked skills test to use ValidationSession API
reidbaker Jun 17, 2026
87cfaf1
test: fix analyzer warnings
reidbaker Jun 17, 2026
acbcc3e
build: update dart_skills_lint to 8f85e82b on main
reidbaker Jun 18, 2026
7eabf5f
test: rewrite tracked skills test to use yaml parsing, address PR com…
reidbaker Jun 18, 2026
9e0d9e5
test: revert yaml parsing, use public ValidationSession from repo
reidbaker Jun 18, 2026
6b68664
test: revert to ValidationSession and use ignore implementation_imports
reidbaker Jun 18, 2026
0942453
test: replace yaml parsing with custom skill rule EnforceTrackedSkill…
reidbaker Jun 18, 2026
9471107
test: extract EnforceTrackedSkillsInternalRule to its own file with docs
reidbaker Jun 18, 2026
c4e832f
ci: allow dart_skills_lint in packages
reidbaker Jun 18, 2026
acc34a5
test: fix internal rule validation feedback
reidbaker Jun 18, 2026
288e5ec
Fix missing copyright headers in check-readiness agent skill
reidbaker Jun 19, 2026
43be3d1
Support .pubignore in publish-check
reidbaker Jun 19, 2026
8d17949
Add tests for publish_check pubignore parsing
reidbaker Jun 19, 2026
81c1c52
Fix .gitignore for check-readiness skill and symlinked skills
reidbaker Jun 19, 2026
438537c
Revert un-ignoring of symlinked skills
reidbaker Jun 19, 2026
f64190b
Add TODO for tracking dart-lang/pub issue 4841
reidbaker Jun 19, 2026
14d7cfc
Group pubignore tracking tests under issue 4841
reidbaker Jun 19, 2026
d7f024e
Move TODO out of group name
reidbaker Jun 19, 2026
bc37ae6
Fix analyzer warnings
reidbaker Jun 19, 2026
16e3f28
Fix .gitignore un-ignore rule overreach
reidbaker Jun 19, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .repo_tool_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ allowed_dependencies:
# Google-owned packages
- _discoveryapis_commons
- adaptive_navigation
- dart_skills_lint
- googleapis
- googleapis_auth
- json_annotation
Expand Down
15 changes: 15 additions & 0 deletions packages/camera/camera_android_camerax/.agents/skills/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Ignore everything by default
*

# Un-ignore specific checked-in skills
# (Add specific contributor skills here as they are created)
!check-readiness/
!check-readiness/SKILL.md
!check-readiness/scripts/
!check-readiness/scripts/check.sh

# Keep essential configuration and docs
!.gitignore
!README.md
!ignore.json
!flutter_skills_ignore.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Agent Skills

This directory contains skills intended for repository maintainers and contributors. Local, checked-in skills are evaluated by `dart_skills_lint` and should be configured to prevent publishing to pub.dev.

**Note on Remotely Managed Skills:**
Skills that are remotely defined and managed using `npx skills` should **not** be installed directly into this directory. Instead, they must be installed into the repository root's `third_party/` directory to comply with third-party code policies. Once installed there, they should be symlinked into this directory.

Please see the `third_party/README.md` file at the root of the repository for specific rules and instructions on adding new remote skills.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
name: check-readiness
description: Run this skill to check if the repository is ready for new work. Use this skill whenever the user asks to "check readiness", "see if we are ready to start work", or when starting a new task in the camera_android_camerax package.
metadata:
internal: true
---
# Check Readiness

This skill verifies that the local environment is properly configured and clean before starting new work in the `camera_android_camerax` package.

## Instructions
Run the bundled verification script ([scripts/check.sh](scripts/check.sh)) to perform the automated environment checks:
```bash
bash .agents/skills/check-readiness/scripts/check.sh
Comment thread
reidbaker marked this conversation as resolved.
Comment thread
reidbaker marked this conversation as resolved.
```

### Handling the Results
1. **If the script succeeds:** Inform the user that the environment is clean, dependencies are resolved, and it is ready for new work.
2. **If the script fails:** Explain exactly which check failed (e.g., git is not clean, a symlink is broken, Flutter is missing from PATH) and offer to help resolve it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@camsim99 I have some work happening to turn this into dart code but if you are ok with it I would like to land that change independently.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash
# Copyright 2013 The Flutter Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# Stop on first error
set -e

# Get the directory of this script, then go up to camera_android_camerax root
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
CAMERAX_DIR="$SCRIPT_DIR/../../../.."

echo "🔍 Checking if environment is ready for new work..."

# 1. Check symlinks resolve
echo "1️⃣ Checking skill symlinks..."
broken_links=$(find "$CAMERAX_DIR/.agents/skills" -type l ! -exec test -e {} \; -print)
if [ -n "$broken_links" ]; then
echo "❌ Error: Found broken symlinks in .agents/skills:"
echo "$broken_links"
exit 1
fi
echo "✅ All symlinks resolve correctly."

# 2. Check git state
echo "2️⃣ Checking git state..."
# Check the whole repository git state
if [ -n "$(git status --porcelain)" ]; then
echo "❌ Error: Git working directory is not clean. Please commit or stash your changes before starting new work."
exit 1
fi
Comment thread
reidbaker marked this conversation as resolved.
echo "✅ Git working directory is clean."

# 3. Check dart and flutter
echo "3️⃣ Checking Flutter and Dart..."
if ! command -v flutter &> /dev/null; then
echo "❌ Error: 'flutter' is not on the PATH."
exit 1
fi
if ! command -v dart &> /dev/null; then
echo "❌ Error: 'dart' is not on the PATH."
exit 1
fi
echo "✅ Flutter and Dart are on the PATH."

# 4. Check dependencies in camera_android_camerax
echo "4️⃣ Checking dependencies in camera_android_camerax..."
cd "$CAMERAX_DIR"
if ! flutter pub get; then
echo "❌ Error: Failed to resolve dependencies."
exit 1
fi
echo "✅ Dependencies are resolved and ready."

echo "🎉 Environment is fully ready!"
1 change: 1 addition & 0 deletions packages/camera/camera_android_camerax/.pubignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.agents/
10 changes: 10 additions & 0 deletions packages/camera/camera_android_camerax/dart_skills_lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
dart_skills_lint:
rules:
check-relative-paths: error
check-trailing-whitespace: error
directories:
- path: "skills"
individual_skills:
- path: ".agents/skills/check-readiness"
rules:
prevent-skills-sh-publishing: error
6 changes: 6 additions & 0 deletions packages/camera/camera_android_camerax/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,15 @@ dependencies:

dev_dependencies:
build_runner: ^2.2.0
dart_skills_lint:
git:
url: https://github.com/flutter/skills.git
path: tool/dart_skills_lint
ref: 8f85e82be6da429980f7cfe84f2f214a06cbfee1
flutter_test:
sdk: flutter
leak_tracker_flutter_testing: any
logging: ^1.2.0
mockito: ^5.4.4
pigeon: ^26.1.4

Expand Down
3 changes: 3 additions & 0 deletions packages/camera/camera_android_camerax/skills/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Published Skills

This directory contains AI agent skills that are intended to be published to pub.dev.
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// Copyright 2013 The Flutter Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:io';

import 'package:dart_skills_lint/dart_skills_lint.dart';

/// A custom lint rule that enforces that all skills tracked in version control
/// are marked as internal.
///
/// This rule is specifically used to prevent the accidental publishing of
/// workspace-specific agent skills to the global public skills registry. It
/// uses `git ls-files` to determine if a skill directory is checked into git,
/// and if it is, strictly requires that the `metadata: internal: true`
/// frontmatter is present in the `SKILL.md` file.
class EnforceTrackedSkillsInternalRule extends SkillRule {
@override
String get name => 'enforce-tracked-skills-internal';

@override
AnalysisSeverity get severity => AnalysisSeverity.error;

@override
Future<List<ValidationError>> validate(SkillContext context) async {
// Check if any files in the skill directory are tracked in git
final ProcessResult processResult;
try {
processResult = await Process.run('git', ['ls-files', context.directory.path]);
} on ProcessException catch (e) {
return [
ValidationError(
ruleId: name,
severity: severity,
file: 'SKILL.md',
message:
'Failed to run git to check tracked status. Is git installed and on the PATH? Error: $e',
),
];
}
if (processResult.exitCode != 0) {
return [];
}
final String output = (processResult.stdout as String).trim();
if (output.isEmpty) {
// Not tracked by git, no enforcement needed
return [];
}

final Object? yaml = context.parsedYaml;
if (yaml is! Map) {
return [
ValidationError(
ruleId: name,
severity: severity,
file: 'SKILL.md',
message: 'Tracked skills must have "metadata: internal: true" in SKILL.md frontmatter.',
),
];
}

final Object? metadata = yaml['metadata'];
if (metadata is! Map || metadata['internal'] != true) {
return [
ValidationError(
ruleId: name,
severity: severity,
file: 'SKILL.md',
message: 'Tracked skills must have "metadata: internal: true" in SKILL.md frontmatter.',
),
];
}

return [];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright 2013 The Flutter Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:async';

import 'package:dart_skills_lint/dart_skills_lint.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:logging/logging.dart';

import 'enforce_tracked_skills_internal_rule.dart';

void main() {
test('Validate Skills', () async {
final Level oldLevel = Logger.root.level;
Logger.root.level = Level.ALL;
final StreamSubscription<LogRecord> subscription = Logger.root.onRecord.listen((record) {
debugPrint(record.message);
});

try {
final Configuration config = await ConfigParser.loadConfig();
final bool isValid = await validateSkills(
config: config,
customRules: [EnforceTrackedSkillsInternalRule()],
);
expect(isValid, isTrue, reason: 'Skills validation failed. See above for details.');
} finally {
Logger.root.level = oldLevel;
await subscription.cancel();
}
});
}
93 changes: 89 additions & 4 deletions script/tool/lib/src/publish_check_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -190,20 +190,105 @@ class PublishCheckCommand extends PackageLoopingCommand {
return true;
}

if (!getBoolArg(_allowPrereleaseFlag)) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this code was not deleted only moved.

return false;
}

await stdOutCompleter.future;
await stdInCompleter.future;

final output = outputBuffer.toString();

// TODO(reidbaker): Remove this custom error handling for gitignored files
// once https://github.com/dart-lang/pub/issues/4841 is resolved.
if (await process.exitCode == 65 && _onlyPubignoreWarnings(output, package)) {
print('Ignoring warning about gitignored files because they are in .pubignore.');
return true;
}

if (!getBoolArg(_allowPrereleaseFlag)) {
return false;
}

return output.contains('Package has 1 warning') &&
output.contains(
'Packages with an SDK constraint on a pre-release of the Dart SDK should themselves be published as a pre-release version.',
);
}

bool _onlyPubignoreWarnings(String output, RepositoryPackage package) {
if (!output.contains('Files that are checked in while gitignored:')) {
return false;
}

final warningCountRegex = RegExp(r'Package has (\d+) warning');
final Match? match = warningCountRegex.firstMatch(output);
if (match != null) {
final int count = int.parse(match.group(1)!);
if (count > 1) {
return false;
}
}

final List<String> lines = output.split('\n');
var inFilesSection = false;
final gitignoredFiles = <String>[];

for (final line in lines) {
if (line.trim() == 'Files that are checked in while gitignored:') {
inFilesSection = true;
continue;
}
if (inFilesSection) {
if (line.trim().isEmpty) {
continue;
}
if (line.startsWith(' ') && !line.startsWith(' ')) {
gitignoredFiles.add(line.trim());
} else if (!line.startsWith(' ')) {
inFilesSection = false;
}
}
}

if (gitignoredFiles.isEmpty) {
return false;
}

final io.File pubignoreFile = package.directory.childFile('.pubignore');
if (!pubignoreFile.existsSync()) {
return false;
}

final List<String> pubignoreLines = pubignoreFile
.readAsLinesSync()
.map((String line) => line.trim())
.where((String line) => line.isNotEmpty && !line.startsWith('#'))
.toList();

for (final file in gitignoredFiles) {
var isIgnored = false;
for (final ignoreRule in pubignoreLines) {
var rule = ignoreRule;
if (rule.startsWith('/')) {
rule = rule.substring(1);
}
if (rule.endsWith('/')) {
if (file.startsWith(rule)) {
isIgnored = true;
break;
}
} else {
if (file == rule || file.startsWith('$rule/')) {
isIgnored = true;
break;
}
}
}
if (!isIgnored) {
return false;
}
}

return true;
}

/// Returns true if the package has been explicitly marked as not for
/// publishing.
bool _isMarkedAsUnpublishable(RepositoryPackage package) {
Expand Down
Loading
Loading