periplon 0.2.0

Rust SDK for building multi-agent AI workflows and automation
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
# Predefined Tasks Implementation Plan

## Overview

This document outlines the design and implementation plan for adding predefined task functionality, ecosystem, and marketplace support to the DSL system. This will enable easy integration with third-party systems (Google, Notion, GitHub, etc.) through reusable, versioned task definitions stored locally or in git repositories.

## Goals

1. **Reusability**: Define tasks once, use across multiple workflows
2. **Discoverability**: Auto-discover available predefined tasks via manifests and registries
3. **Flexibility**: Support both task referencing and embedding
4. **Versioning**: Proper semantic versioning with dependency resolution
5. **Ecosystem**: Enable third-party task sharing via git repositories and multiple marketplaces
6. **Security**: Trust and permission management for external tasks with per-registry configuration
7. **Multi-Marketplace**: Support official, community, company-internal, and self-hosted registries
8. **Task Groups**: Bundle related tasks into cohesive integration suites
9. **Offline Support**: Work without internet connectivity using cached registries
10. **Priority Resolution**: Intelligent task resolution across multiple sources

## Architecture

### 1. Predefined Task Structure

#### Task Definition Schema

```yaml
# google/drive/upload.task.yaml
apiVersion: "task/v1"
kind: "PredefinedTask"
metadata:
  name: "google-drive-upload"
  version: "1.2.0"
  author: "community/google-integrations"
  description: "Upload files to Google Drive"
  license: "MIT"
  repository: "https://github.com/claude-tasks/google-integrations"
  tags: ["google", "storage", "upload"]

spec:
  # Task implementation
  agent_template:
    description: "Upload ${input.file_path} to Google Drive folder ${input.folder_id}"
    model: "claude-sonnet-4-5"
    tools: ["Bash", "WebFetch"]
    permissions:
      mode: "acceptEdits"

  # Input schema with validation
  inputs:
    file_path:
      type: string
      required: true
      description: "Local file path to upload"
      validation:
        pattern: "^[^<>:\"|?*]+$"

    folder_id:
      type: string
      required: false
      default: "root"
      description: "Google Drive folder ID"

    credentials:
      type: secret
      required: true
      description: "Google OAuth credentials"
      source: "${env.GOOGLE_CREDENTIALS}"

  # Output schema
  outputs:
    file_id:
      type: string
      description: "Uploaded file ID"
      source:
        type: state
        key: "drive_file_id"

    share_url:
      type: string
      description: "Shareable link"
      source:
        type: state
        key: "share_link"

  # Dependencies on other predefined tasks
  dependencies:
    - name: "google-auth"
      version: "^2.0.0"
      optional: false

  # Example usage
  examples:
    - name: "Upload PDF report"
      inputs:
        file_path: "./report.pdf"
        folder_id: "abc123xyz"
      description: "Upload a PDF to a specific folder"
```

#### Package Manifest

```yaml
# package.yaml (repository root)
apiVersion: "package/v1"
kind: "TaskPackage"
metadata:
  name: "google-integrations"
  version: "2.1.0"
  description: "Google Workspace integration tasks"
  author: "community"
  homepage: "https://github.com/claude-tasks/google-integrations"
  license: "MIT"

tasks:
  - path: "drive/upload.task.yaml"
    name: "google-drive-upload"
    version: "1.2.0"

  - path: "drive/download.task.yaml"
    name: "google-drive-download"
    version: "1.1.0"

  - path: "docs/create.task.yaml"
    name: "google-docs-create"
    version: "2.0.0"

  - path: "sheets/read.task.yaml"
    name: "google-sheets-read"
    version: "1.5.0"

dependencies:
  - name: "oauth-common"
    version: "^1.0.0"
    repository: "https://github.com/claude-tasks/oauth-common"

# Compatibility
requires:
  sdk_version: ">=0.2.0"
  min_model: "claude-sonnet-4"
```

### 2. Storage & Discovery

#### Storage Locations (Priority Order)

1. **Project Local**: `./.claude/tasks/`
2. **User Global**: `~/.claude/tasks/`
3. **Git Repositories**: Configured in `~/.claude/task-sources.yaml`
4. **Marketplace Registries**: Multiple registries with different purposes:
   - Official public marketplace
   - Company/organization private registries
   - Community-driven registries
   - Self-hosted internal registries

#### Task Sources Configuration

```yaml
# ~/.claude/task-sources.yaml
sources:
  # Local directories
  - type: local
    name: "project-tasks"
    path: "./.claude/tasks"
    priority: 10

  # Git repositories
  - type: git
    name: "official-tasks"
    url: "https://github.com/claude-tasks/official"
    branch: "main"
    cache_dir: "~/.claude/cache/official-tasks"
    update_policy: "daily"  # daily, weekly, manual
    priority: 5
    trusted: true

  - type: git
    name: "google-integrations"
    url: "https://github.com/claude-tasks/google-integrations"
    branch: "main"
    tag: "v2.1.0"  # Pin to specific version
    priority: 5
    trusted: true

  # Multiple Marketplace Registries
  - type: registry
    name: "official-marketplace"
    url: "https://registry.claude-tasks.io"
    priority: 3
    auto_discover: true
    trust_level: "trusted"
    auth:
      type: "none"  # Public registry

  - type: registry
    name: "company-internal"
    url: "https://tasks.mycompany.internal"
    priority: 8
    auto_discover: true
    trust_level: "trusted"
    auth:
      type: "token"
      token: "${env.COMPANY_REGISTRY_TOKEN}"
    tls:
      verify: true
      ca_cert: "~/.claude/certs/company-ca.pem"

  - type: registry
    name: "community-hub"
    url: "https://community.claude-tasks.org"
    priority: 2
    auto_discover: false  # Manual search only
    trust_level: "community"
    auth:
      type: "none"

  - type: registry
    name: "self-hosted"
    url: "http://localhost:8080/registry"
    priority: 9
    auto_discover: true
    trust_level: "trusted"
    auth:
      type: "basic"
      username: "${env.REGISTRY_USER}"
      password: "${env.REGISTRY_PASS}"
```

#### Discovery Mechanism

```rust
// src/dsl/predefined_tasks/discovery.rs

pub struct TaskDiscovery {
    sources: Vec<TaskSource>,
    cache: TaskCache,
}

impl TaskDiscovery {
    /// Load all task sources from config
    pub async fn load_sources(config_path: &Path) -> Result<Self>;

    /// Discover all available tasks from all sources
    pub async fn discover_all(&self) -> Result<Vec<TaskMetadata>>;

    /// Find task by name, searching all registries by priority
    pub async fn find_task(&self, name: &str, version: &str) -> Result<PredefinedTask>;

    /// Find task from specific registry
    pub async fn find_task_in_registry(
        &self,
        registry: &str,
        name: &str,
        version: &str,
    ) -> Result<PredefinedTask>;

    /// Search tasks across all registries
    pub async fn search(&self, query: &str) -> Result<Vec<TaskMetadata>>;

    /// Search tasks in specific registry
    pub async fn search_registry(
        &self,
        registry: &str,
        query: &str,
    ) -> Result<Vec<TaskMetadata>>;

    /// List tasks by category/tag across all registries
    pub async fn list_by_tag(&self, tag: &str) -> Result<Vec<TaskMetadata>>;

    /// List all configured registries
    pub fn list_registries(&self) -> Vec<RegistryInfo>;

    /// Add new registry dynamically
    pub async fn add_registry(&mut self, config: RegistryConfig) -> Result<()>;

    /// Remove registry
    pub async fn remove_registry(&mut self, name: &str) -> Result<()>;

    /// Update git sources and registries
    pub async fn update_sources(&self) -> Result<()>;

    /// Sync specific registry
    pub async fn sync_registry(&self, name: &str) -> Result<()>;
}
```

### 3. Task Reference vs Embedding

#### Reference Method (Recommended)

Reference external task definitions by URI/path:

```yaml
# workflow.yaml
name: "Upload Report Workflow"

tasks:
  upload_to_drive:
    # Reference by package name and version
    uses: "google-drive-upload@1.2.0"
    inputs:
      file_path: "./report.pdf"
      folder_id: "abc123xyz"
      credentials: "${env.GOOGLE_CREDENTIALS}"
    outputs:
      file_id: "${task.file_id}"
      share_url: "${task.share_url}"
```

**Benefits**:
- Always use latest compatible version
- Automatic updates with version constraints
- Smaller workflow files
- Shared bug fixes/improvements

#### Embedding Method

Copy task definition into workflow (for stability/customization):

```yaml
# workflow.yaml
name: "Upload Report Workflow"

tasks:
  upload_to_drive:
    # Embed complete task definition
    embed: "google-drive-upload@1.2.0"
    # Override specific properties
    overrides:
      agent_template:
        model: "claude-opus-4"  # Use different model
      inputs:
        timeout:
          type: integer
          default: 300  # Add custom input
```

**Benefits**:
- Version pinning (workflow won't break)
- Customization of task behavior
- Offline execution (no external deps)
- Audit trail of exact task version

### 4. Task Groups

Task groups allow defining collections of tasks that work together as cohesive units. This is useful for multi-step workflows, integration suites, or feature bundles.

#### Task Group Definition Schema

```yaml
# google/workspace/full-suite.taskgroup.yaml
apiVersion: "taskgroup/v1"
kind: "TaskGroup"
metadata:
  name: "google-workspace-suite"
  version: "2.0.0"
  author: "community/google-integrations"
  description: "Complete Google Workspace integration suite"
  license: "MIT"
  tags: ["google", "workspace", "integration"]

spec:
  # Tasks included in this group
  tasks:
    - name: "google-drive-upload"
      version: "^1.2.0"
      required: true

    - name: "google-drive-download"
      version: "^1.1.0"
      required: true

    - name: "google-docs-create"
      version: "^2.0.0"
      required: false  # Optional task

    - name: "google-sheets-read"
      version: "^1.5.0"
      required: true

    - name: "google-auth"
      version: "^2.0.0"
      required: true

  # Shared configuration for all tasks in group
  shared_config:
    inputs:
      credentials:
        type: secret
        required: true
        description: "Google OAuth credentials for all tasks"
        source: "${env.GOOGLE_CREDENTIALS}"

    permissions:
      mode: "acceptEdits"
      max_turns: 10

  # Pre-configured workflows using these tasks
  workflows:
    - name: "backup-to-drive"
      description: "Backup files to Google Drive"
      tasks:
        - upload_files:
            uses: "google-drive-upload"
            inputs:
              credentials: "${group.credentials}"

    - name: "report-generation"
      description: "Generate and share report"
      tasks:
        - create_doc:
            uses: "google-docs-create"
            inputs:
              credentials: "${group.credentials}"

        - upload_to_drive:
            uses: "google-drive-upload"
            depends_on: [create_doc]
            inputs:
              credentials: "${group.credentials}"

  # Group-level dependencies
  dependencies:
    - name: "oauth-common"
      version: "^1.0.0"

  # Installation hooks
  hooks:
    post_install:
      - type: "command"
        command: "echo 'Google Workspace suite installed successfully'"

    pre_use:
      - type: "validate"
        check: "env.GOOGLE_CREDENTIALS"
        message: "GOOGLE_CREDENTIALS environment variable required"
```

#### Using Task Groups in Workflows

##### Method 1: Import Entire Group

```yaml
name: "My Workflow"

# Import all tasks from group
imports:
  - group: "google-workspace-suite@^2.0.0"
    as: "gws"  # Namespace alias

tasks:
  upload_report:
    # Reference task from imported group
    uses: "gws.google-drive-upload"
    inputs:
      file_path: "./report.pdf"
      credentials: "${env.GOOGLE_CREDENTIALS}"
```

##### Method 2: Use Predefined Workflow from Group

```yaml
name: "Backup Workflow"

tasks:
  backup_data:
    # Use pre-configured workflow from task group
    uses_workflow: "google-workspace-suite@^2.0.0#backup-to-drive"
    inputs:
      credentials: "${env.GOOGLE_CREDENTIALS}"
      files:
        - "./data/*.csv"
        - "./reports/*.pdf"
```

##### Method 3: Selective Import

```yaml
name: "Simple Upload"

# Import only specific tasks from group
imports:
  - group: "google-workspace-suite@^2.0.0"
    tasks: ["google-drive-upload", "google-auth"]
    as: "gws"

tasks:
  upload:
    uses: "gws.google-drive-upload"
    inputs:
      file_path: "./file.txt"
```

#### Task Group Use Cases

**1. Platform Integration Suites**
```yaml
# slack/notifications-suite.taskgroup.yaml
metadata:
  name: "slack-notifications-suite"
  version: "1.0.0"

spec:
  tasks:
    - {name: "slack-send-message", version: "^2.0.0"}
    - {name: "slack-create-channel", version: "^1.5.0"}
    - {name: "slack-upload-file", version: "^1.3.0"}
    - {name: "slack-update-status", version: "^1.0.0"}
```

**2. CI/CD Pipeline Groups**
```yaml
# ci-cd/deployment-suite.taskgroup.yaml
metadata:
  name: "deployment-suite"
  version: "3.0.0"

spec:
  tasks:
    - {name: "docker-build", version: "^2.0.0"}
    - {name: "docker-push", version: "^2.0.0"}
    - {name: "kubernetes-deploy", version: "^1.8.0"}
    - {name: "health-check", version: "^1.2.0"}
    - {name: "rollback", version: "^1.0.0"}

  workflows:
    - name: "blue-green-deployment"
      description: "Zero-downtime deployment"
      # ... workflow definition
```

**3. Data Processing Pipelines**
```yaml
# data/etl-suite.taskgroup.yaml
metadata:
  name: "etl-suite"
  version: "1.5.0"

spec:
  tasks:
    - {name: "extract-postgres", version: "^2.0.0"}
    - {name: "extract-mysql", version: "^1.8.0"}
    - {name: "transform-json", version: "^3.0.0"}
    - {name: "load-bigquery", version: "^2.5.0"}
    - {name: "load-snowflake", version: "^1.9.0"}
```

#### Task Group Discovery and Management

Task groups are discovered alongside predefined tasks:

```rust
// src/dsl/predefined_tasks/groups.rs

pub struct TaskGroup {
    pub metadata: TaskGroupMetadata,
    pub tasks: Vec<TaskReference>,
    pub shared_config: Option<SharedConfig>,
    pub workflows: Vec<PrebuiltWorkflow>,
    pub dependencies: Vec<Dependency>,
}

impl TaskGroup {
    /// Load task group from YAML
    pub fn from_yaml(yaml: &str) -> Result<Self>;

    /// Resolve all tasks in group
    pub async fn resolve_tasks(&self, discovery: &TaskDiscovery) -> Result<Vec<PredefinedTask>>;

    /// Install all tasks from group
    pub async fn install(&self, target_dir: &Path) -> Result<()>;

    /// Validate group integrity
    pub fn validate(&self) -> Result<()>;
}
```

#### Task Group Registry Schema

Task groups are published to registries alongside individual tasks:

```json
{
  "api_version": "v1",
  "kind": "registry_index",
  "tasks": [
    {
      "name": "google-drive-upload",
      "type": "task",
      "latest_version": "1.2.3"
    }
  ],
  "task_groups": [
    {
      "name": "google-workspace-suite",
      "type": "task_group",
      "latest_version": "2.0.0",
      "included_tasks": [
        "google-drive-upload@^1.2.0",
        "google-docs-create@^2.0.0",
        "google-sheets-read@^1.5.0"
      ],
      "downloads": 15234,
      "rating": 4.7
    }
  ]
}
```

#### CLI Commands for Task Groups

```bash
# List available task groups
periplon-executor groups list

# Search task groups
periplon-executor groups search "google"

# Show group details
periplon-executor groups show google-workspace-suite

# Install task group (installs all included tasks)
periplon-executor groups install google-workspace-suite@2.0.0

# Show tasks in group
periplon-executor groups tasks google-workspace-suite

# Show predefined workflows in group
periplon-executor groups workflows google-workspace-suite

# Create new task group
periplon-executor groups new my-group --tasks="task1,task2,task3"

# Validate task group definition
periplon-executor groups validate ./my-group.taskgroup.yaml

# Publish task group to registry
periplon-executor groups publish ./my-group.taskgroup.yaml --registry=company-internal
```

#### Benefits of Task Groups

1. **Cohesive Integration**: Related tasks packaged together
2. **Simplified Discovery**: Find complete solutions, not individual tasks
3. **Shared Configuration**: Common settings applied to all tasks
4. **Version Compatibility**: Guaranteed compatible task versions
5. **Predefined Workflows**: Ready-to-use workflow templates
6. **Easier Updates**: Update entire suite at once
7. **Better Documentation**: Suite-level docs and examples
8. **Namespace Management**: Avoid naming conflicts with group prefixes

### 5. Versioning & Dependency Resolution

#### Semantic Versioning

Follow semver (MAJOR.MINOR.PATCH):
- **MAJOR**: Breaking changes to inputs/outputs
- **MINOR**: New features, backward compatible
- **PATCH**: Bug fixes, no API changes

#### Version Constraints

```yaml
tasks:
  upload:
    uses: "google-drive-upload@^1.2.0"  # >=1.2.0 <2.0.0
    # Other formats:
    # "google-drive-upload@~1.2.0"  # >=1.2.0 <1.3.0
    # "google-drive-upload@1.2.0"   # Exact version
    # "google-drive-upload@latest"  # Latest stable
    # "google-drive-upload@1.x"     # Any 1.x version
```

#### Lock File

Generate lock file for reproducible builds:

```yaml
# workflow.lock.yaml
version: 1
generated_at: "2025-01-15T10:30:00Z"

resolved_tasks:
  google-drive-upload:
    version: "1.2.3"
    source:
      type: "git"
      url: "https://github.com/claude-tasks/google-integrations"
      commit: "a3b2c1d"
    registry: null
    checksum: "sha256:abc123..."

  google-auth:
    version: "2.0.1"
    source:
      type: "registry"
      registry: "official-marketplace"
      url: "https://registry.claude-tasks.io"
    checksum: "sha256:def456..."

  notion-create-page:
    version: "1.5.0"
    source:
      type: "registry"
      registry: "company-internal"
      url: "https://tasks.mycompany.internal"
    checksum: "sha256:xyz789..."
```

### 5. Implementation Phases

#### Phase 1: Local Predefined Tasks (Weeks 1-2)

**Goal**: Basic predefined task support with local storage

**Deliverables**:
1. Task definition schema (`PredefinedTask` struct)
2. Parser for `.task.yaml` files
3. Local task discovery (`.claude/tasks/`)
4. Task reference in workflows (`uses:` syntax)
5. Input/output binding
6. Basic validation

**Files to Create**:
- `src/dsl/predefined_tasks/mod.rs` - Module root
- `src/dsl/predefined_tasks/schema.rs` - Task definition types
- `src/dsl/predefined_tasks/parser.rs` - YAML parsing
- `src/dsl/predefined_tasks/loader.rs` - Load from filesystem
- `src/dsl/predefined_tasks/resolver.rs` - Resolve task references
- `tests/dsl/predefined_tasks_tests.rs` - Unit tests

**Workflow Changes**:
```rust
// src/dsl/schema.rs
pub struct Task {
    // Existing fields...

    // NEW: Reference to predefined task
    pub uses: Option<String>,  // e.g., "google-drive-upload@1.2.0"
    pub embed: Option<String>, // Embed instead of reference
    pub overrides: Option<serde_yaml::Value>, // Override task properties
}
```

#### Phase 2: Git Repository Support (Weeks 3-4)

**Goal**: Pull tasks from git repositories with caching

**Deliverables**:
1. Git source configuration (`task-sources.yaml`)
2. Git cloning/pulling with caching
3. Package manifest parsing (`package.yaml`)
4. Multi-source task discovery
5. Priority-based resolution
6. Update mechanism

**Files to Create**:
- `src/dsl/predefined_tasks/sources/mod.rs`
- `src/dsl/predefined_tasks/sources/git.rs` - Git integration
- `src/dsl/predefined_tasks/sources/local.rs` - Local filesystem
- `src/dsl/predefined_tasks/cache.rs` - Caching layer
- `src/dsl/predefined_tasks/discovery.rs` - Multi-source discovery

**Dependencies to Add**:
```toml
[dependencies]
git2 = "0.18"  # Git operations
dirs = "5.0"   # Platform-specific directories
```

#### Phase 3: Versioning & Dependency Resolution (Weeks 5-6)

**Goal**: Proper semver resolution with dependency graphs

**Deliverables**:
1. Semver parsing and constraint matching
2. Dependency graph construction
3. Version resolution algorithm
4. Lock file generation
5. Conflict detection
6. Update checker

**Files to Create**:
- `src/dsl/predefined_tasks/version.rs` - Semver types
- `src/dsl/predefined_tasks/resolver.rs` - Dependency resolution
- `src/dsl/predefined_tasks/lockfile.rs` - Lock file management
- `src/dsl/predefined_tasks/graph.rs` - Dependency graph

**Dependencies to Add**:
```toml
[dependencies]
semver = "1.0"  # Semantic versioning
petgraph = "0.6"  # Dependency graphs
```

#### Phase 4: Task Groups (Weeks 7-8)

**Goal**: Support for task groups and bundle workflows

**Deliverables**:
1. Task group schema and parser
2. Group import mechanism (namespace support)
3. Predefined workflow execution from groups
4. Selective task import from groups
5. Shared configuration inheritance
6. Group validation and dependency resolution

**Files to Create**:
- `src/dsl/predefined_tasks/groups/mod.rs` - Module root
- `src/dsl/predefined_tasks/groups/schema.rs` - TaskGroup types
- `src/dsl/predefined_tasks/groups/parser.rs` - YAML parsing
- `src/dsl/predefined_tasks/groups/loader.rs` - Load and resolve groups
- `src/dsl/predefined_tasks/groups/namespace.rs` - Namespace management
- `tests/dsl/task_groups_tests.rs` - Unit tests

**Workflow Changes**:
```rust
// src/dsl/schema.rs
pub struct Workflow {
    // Existing fields...

    // NEW: Group imports
    pub imports: Option<Vec<GroupImport>>,
}

pub struct GroupImport {
    pub group: String,  // "google-workspace-suite@^2.0.0"
    pub as_name: Option<String>,  // Namespace alias
    pub tasks: Option<Vec<String>>,  // Selective import
}

pub struct Task {
    // Existing fields...

    // NEW: Reference workflow from group
    pub uses_workflow: Option<String>,  // "group@version#workflow"
}
```

#### Phase 5: Multiple Marketplace Support (Weeks 9-10)

**Goal**: Enable multiple registries with priority-based resolution

**Deliverables**:
1. Multi-registry configuration support
2. Registry priority and conflict resolution
3. Registry-specific task references (`registry::task@version`)
4. Registry health monitoring and failover
5. Authentication per registry (token, basic, client cert)
6. Offline mode with registry caching
7. Registry management CLI commands

**Files to Create**:
- `src/dsl/predefined_tasks/registry/mod.rs` - Module root
- `src/dsl/predefined_tasks/registry/client.rs` - HTTP client
- `src/dsl/predefined_tasks/registry/config.rs` - Registry config
- `src/dsl/predefined_tasks/registry/auth.rs` - Authentication handlers
- `src/dsl/predefined_tasks/registry/health.rs` - Health monitoring
- `src/dsl/predefined_tasks/registry/cache.rs` - Offline caching
- `src/dsl/predefined_tasks/resolution.rs` - Multi-registry resolution

**Dependencies to Add**:
```toml
[dependencies]
reqwest = { version = "0.11", features = ["json", "rustls-tls"] }
rustls = "0.21"  # TLS support with client certs
tokio = { version = "1.0", features = ["time"] }  # Health check timeouts
```

**CLI Extensions**:
```bash
# Registry management
periplon-executor registry list
periplon-executor registry add --name=my-reg --url=https://...
periplon-executor registry remove my-reg
periplon-executor registry test company-internal
periplon-executor registry sync official-marketplace

# Multi-registry search
periplon-executor tasks search "google" --registry=all
periplon-executor tasks search "google" --registry=company-internal
```

#### Phase 6: Marketplace & Publishing (Weeks 11-12)

**Goal**: Public registry infrastructure and publishing tools

**Deliverables**:
1. Task search functionality across registries
2. Category/tag filtering
3. Task and group validation tools
4. Publishing CLI commands
5. Trust/signature verification
6. Marketplace web UI (separate project)
7. Download stats and ratings

**Files to Create**:
- `src/dsl/predefined_tasks/search.rs` - Search engine
- `src/dsl/predefined_tasks/publish.rs` - Publishing tools
- `src/dsl/predefined_tasks/security.rs` - Trust verification
- `src/dsl/predefined_tasks/analytics.rs` - Download tracking
- `bin/task-publisher.rs` - Publishing CLI

**New Binary Target**:
```bash
# Publish task to registry
task-publisher publish ./my-task.yaml --registry=official-marketplace

# Publish task group
task-publisher publish ./my-group.taskgroup.yaml --registry=company-internal

# Search marketplace
task-publisher search "google drive" --registry=all

# Show analytics
task-publisher stats google-drive-upload

# Update all tasks
task-publisher update --check-only
```

### 6. Third-Party Integration Examples

#### Google Workspace Tasks

```yaml
# google/drive/upload.task.yaml
apiVersion: "task/v1"
kind: "PredefinedTask"
metadata:
  name: "google-drive-upload"
  version: "1.2.0"

spec:
  agent_template:
    description: |
      Upload file to Google Drive using the Drive API.
      File: ${input.file_path}
      Folder: ${input.folder_id}
    tools: ["Bash", "WebFetch"]

  inputs:
    file_path: {type: string, required: true}
    folder_id: {type: string, default: "root"}
    credentials: {type: secret, required: true}

  outputs:
    file_id: {type: string}
    share_url: {type: string}
```

#### Notion Integration Tasks

```yaml
# notion/create-page.task.yaml
apiVersion: "task/v1"
kind: "PredefinedTask"
metadata:
  name: "notion-create-page"
  version: "1.0.0"

spec:
  agent_template:
    description: |
      Create a new Notion page in database ${input.database_id}
      with title "${input.title}" and properties ${input.properties}
    tools: ["WebFetch", "Bash"]

  inputs:
    database_id: {type: string, required: true}
    title: {type: string, required: true}
    properties: {type: object, required: false}
    api_token: {type: secret, required: true, source: "${env.NOTION_TOKEN}"}

  outputs:
    page_id: {type: string}
    page_url: {type: string}
```

#### GitHub Integration Tasks

```yaml
# github/create-issue.task.yaml
apiVersion: "task/v1"
kind: "PredefinedTask"
metadata:
  name: "github-create-issue"
  version: "2.0.0"

spec:
  agent_template:
    description: |
      Create GitHub issue in ${input.repository}:
      Title: ${input.title}
      Body: ${input.body}
      Labels: ${input.labels}
    tools: ["Bash"]

  inputs:
    repository: {type: string, required: true, description: "owner/repo"}
    title: {type: string, required: true}
    body: {type: string, required: true}
    labels: {type: array, items: string, required: false}
    token: {type: secret, required: true, source: "${env.GITHUB_TOKEN}"}

  outputs:
    issue_number: {type: integer}
    issue_url: {type: string}
```

### 7. Security & Trust Model

#### Trust Levels

```yaml
sources:
  - type: git
    name: "official-tasks"
    url: "https://github.com/claude-tasks/official"
    trust_level: "trusted"  # trusted, verified, community, untrusted
```

**Trust Levels**:
1. **trusted**: Official tasks, auto-approved
2. **verified**: Signed by known authors, minimal review
3. **community**: Require user approval before use
4. **untrusted**: Show warning, require explicit approval

#### Permission Scoping

Predefined tasks declare required permissions:

```yaml
spec:
  required_permissions:
    - type: "file_write"
      paths: ["./output/**"]
    - type: "network"
      domains: ["*.googleapis.com"]
    - type: "environment"
      variables: ["GOOGLE_CREDENTIALS"]
```

Workflow executor validates permissions before task execution.

#### Signature Verification (Future)

```yaml
metadata:
  signature:
    algorithm: "ed25519"
    public_key: "base64:..."
    signature: "base64:..."
    signed_at: "2025-01-15T10:30:00Z"
```

### 8. Multiple Marketplace Management

Supporting multiple marketplaces enables different use cases and organizational needs.

#### Marketplace Types

**1. Official Public Marketplace**
- Curated, high-quality tasks
- Vetted by maintainers
- Free to use
- Highest trust level
- Example: `https://registry.claude-tasks.io`

**2. Company/Organization Internal Registry**
- Private, organization-specific tasks
- Behind corporate firewall
- Authentication required
- Contains proprietary integrations
- Example: `https://tasks.mycompany.internal`

**3. Community Marketplace**
- User-contributed tasks
- Lower trust level
- Requires approval before use
- Diverse ecosystem
- Example: `https://community.claude-tasks.org`

**4. Self-Hosted Registry**
- Deployed on-premises or private cloud
- Full control over content
- Custom security policies
- Air-gapped environments
- Example: `http://localhost:8080/registry`

#### Registry Priority and Resolution

When multiple registries are configured, task resolution follows priority order:

```rust
// src/dsl/predefined_tasks/resolution.rs

pub struct TaskResolver {
    sources: Vec<TaskSource>,
}

impl TaskResolver {
    /// Find task across all registries by priority
    pub async fn resolve_task(
        &self,
        name: &str,
        version: &str,
    ) -> Result<ResolvedTask> {
        // Sort sources by priority (higher = searched first)
        let mut sorted_sources = self.sources.clone();
        sorted_sources.sort_by(|a, b| b.priority.cmp(&a.priority));

        for source in sorted_sources {
            if let Ok(task) = source.find_task(name, version).await {
                return Ok(ResolvedTask {
                    task,
                    source: source.name.clone(),
                });
            }
        }

        Err(Error::TaskNotFound(name.to_string()))
    }

    /// Find task from specific registry
    pub async fn resolve_from_registry(
        &self,
        registry: &str,
        name: &str,
        version: &str,
    ) -> Result<ResolvedTask> {
        let source = self.sources
            .iter()
            .find(|s| s.name == registry)
            .ok_or(Error::RegistryNotFound(registry.to_string()))?;

        let task = source.find_task(name, version).await?;
        Ok(ResolvedTask {
            task,
            source: registry.to_string(),
        })
    }
}
```

#### Registry-Specific Task References

Tasks can explicitly specify which registry to use:

```yaml
tasks:
  # Use default priority-based resolution
  upload:
    uses: "google-drive-upload@^1.2.0"

  # Explicitly use company registry
  internal_task:
    uses: "company-internal::custom-integration@1.0.0"
    # Syntax: "registry::task@version"

  # Use community registry
  community_task:
    uses: "community-hub::experimental-feature@0.5.0"
```

#### Registry Configuration Schema

```yaml
# ~/.claude/registries.yaml
registries:
  # Official marketplace (public)
  - name: "official-marketplace"
    type: "registry"
    url: "https://registry.claude-tasks.io"
    priority: 3
    trust_level: "trusted"
    enabled: true
    features:
      search: true
      auto_discover: true
      caching: true
      offline_mode: true
    metadata:
      description: "Official curated marketplace"
      contact: "support@claude-tasks.io"

  # Company internal (private)
  - name: "company-internal"
    type: "registry"
    url: "https://tasks.mycompany.internal"
    priority: 8
    trust_level: "trusted"
    enabled: true
    auth:
      type: "token"
      token: "${env.COMPANY_REGISTRY_TOKEN}"
    tls:
      verify: true
      ca_cert: "~/.claude/certs/company-ca.pem"
      client_cert: "~/.claude/certs/client.pem"
      client_key: "~/.claude/certs/client-key.pem"
    features:
      search: true
      auto_discover: true
      caching: true
    rate_limit:
      requests_per_minute: 100
    metadata:
      description: "Internal company task registry"
      admin: "devops@mycompany.com"

  # Community hub (public, lower trust)
  - name: "community-hub"
    type: "registry"
    url: "https://community.claude-tasks.org"
    priority: 2
    trust_level: "community"
    enabled: true
    features:
      search: true
      auto_discover: false  # Require explicit search
      caching: true
      approval_required: true  # Prompt before using tasks
    metadata:
      description: "Community-contributed tasks"
      website: "https://community.claude-tasks.org"

  # Self-hosted (local development)
  - name: "dev-local"
    type: "registry"
    url: "http://localhost:8080/registry"
    priority: 9
    trust_level: "trusted"
    enabled: true
    auth:
      type: "basic"
      username: "admin"
      password: "${env.LOCAL_REGISTRY_PASS}"
    tls:
      verify: false  # Dev environment
    features:
      search: true
      auto_discover: true
      caching: false  # Always fetch fresh
    metadata:
      description: "Local development registry"
```

#### Registry API Specification

All registries must implement this API:

```
GET /api/v1/tasks
  - List all available tasks
  - Query params: ?page=1&limit=50&tag=google

GET /api/v1/tasks/{name}
  - Get task metadata and versions
  - Returns: task info, all versions, download stats

GET /api/v1/tasks/{name}/{version}
  - Get specific task version
  - Returns: complete task definition

GET /api/v1/search?q={query}
  - Full-text search across tasks
  - Returns: matching tasks with relevance scores

GET /api/v1/groups
  - List all task groups
  - Query params: ?page=1&limit=50

GET /api/v1/groups/{name}
  - Get task group metadata
  - Returns: group info, included tasks

POST /api/v1/publish
  - Publish new task/group (requires auth)
  - Body: task definition + metadata

DELETE /api/v1/tasks/{name}/{version}
  - Remove task version (requires auth)
  - Returns: deletion confirmation

GET /api/v1/health
  - Health check endpoint
  - Returns: registry status, version
```

#### Registry Mirroring and Fallbacks

Configure fallback registries for high availability:

```yaml
registries:
  - name: "official-marketplace"
    url: "https://registry.claude-tasks.io"
    priority: 3
    mirrors:
      - url: "https://mirror1.claude-tasks.io"
        active: true
      - url: "https://mirror2.claude-tasks.io"
        active: true
    fallback_timeout: "5s"
```

#### Registry Health Monitoring

```rust
// src/dsl/predefined_tasks/registry_health.rs

pub struct RegistryHealth {
    pub name: String,
    pub status: HealthStatus,
    pub response_time: Duration,
    pub last_check: DateTime<Utc>,
    pub error: Option<String>,
}

pub enum HealthStatus {
    Healthy,
    Degraded,
    Unreachable,
    Unauthorized,
}

impl Registry {
    pub async fn health_check(&self) -> Result<RegistryHealth> {
        let start = Instant::now();

        match self.client.get(&format!("{}/api/v1/health", self.url)).await {
            Ok(resp) if resp.status().is_success() => {
                Ok(RegistryHealth {
                    name: self.name.clone(),
                    status: HealthStatus::Healthy,
                    response_time: start.elapsed(),
                    last_check: Utc::now(),
                    error: None,
                })
            }
            Ok(resp) if resp.status() == 401 => {
                Ok(RegistryHealth {
                    name: self.name.clone(),
                    status: HealthStatus::Unauthorized,
                    response_time: start.elapsed(),
                    last_check: Utc::now(),
                    error: Some("Authentication failed".to_string()),
                })
            }
            Err(e) => {
                Ok(RegistryHealth {
                    name: self.name.clone(),
                    status: HealthStatus::Unreachable,
                    response_time: start.elapsed(),
                    last_check: Utc::now(),
                    error: Some(e.to_string()),
                })
            }
        }
    }
}
```

#### Cross-Registry Task Discovery

Search across all enabled registries:

```bash
# Search all registries
periplon-executor tasks search "google drive"

# Output:
# official-marketplace:
#   - google-drive-upload@1.2.3 (downloads: 15.2k, rating: 4.8/5)
#   - google-drive-download@1.1.5 (downloads: 12.5k, rating: 4.7/5)
#
# company-internal:
#   - google-drive-enterprise@2.0.0 (downloads: 234, rating: 5.0/5)
#
# community-hub:
#   - google-drive-advanced@0.8.0 (downloads: 523, rating: 4.2/5)
```

#### Registry Conflict Resolution

When multiple registries have the same task name:

```yaml
# Conflict resolution strategies
conflict_resolution:
  strategy: "priority"  # priority, prompt, explicit

  # priority: Use highest priority registry
  # prompt: Ask user to choose
  # explicit: Require registry prefix (registry::task)

  # Per-task overrides
  overrides:
    "google-drive-upload":
      preferred_registry: "company-internal"
      reason: "Use enterprise version with enhanced features"
```

#### Offline Mode Support

Cache tasks locally for offline use:

```yaml
registries:
  - name: "official-marketplace"
    url: "https://registry.claude-tasks.io"
    features:
      offline_mode: true
      cache_policy:
        max_age: "7d"
        max_size: "500MB"
        location: "~/.claude/cache/official-marketplace"
```

```bash
# Pre-cache tasks for offline use
periplon-executor registry cache official-marketplace --all

# Use cached tasks when offline
periplon-executor run workflow.yaml --offline
```

### 9. CLI Commands

#### DSL Executor Extensions

```bash
# List available predefined tasks
periplon-executor tasks list

# List tasks from specific registry
periplon-executor tasks list --registry=company-internal

# Search tasks across all registries
periplon-executor tasks search "google drive"

# Search in specific registry
periplon-executor tasks search "google drive" --registry=official-marketplace

# Show task details
periplon-executor tasks show google-drive-upload

# Show task from specific registry
periplon-executor tasks show google-drive-upload --registry=official-marketplace

# Install task locally
periplon-executor tasks install google-drive-upload@1.2.0

# Install from specific registry
periplon-executor tasks install google-drive-upload@1.2.0 --registry=company-internal

# Update all task sources
periplon-executor tasks update

# Update specific registry
periplon-executor tasks update --registry=official-marketplace

# Validate task definition
periplon-executor tasks validate ./my-task.yaml

# Create new task from template
periplon-executor tasks new my-task --template=basic

# Registry Management Commands
# List all configured registries
periplon-executor registry list

# Add new registry
periplon-executor registry add \
  --name=my-registry \
  --url=https://registry.example.com \
  --trust-level=community \
  --priority=5

# Remove registry
periplon-executor registry remove my-registry

# Show registry details
periplon-executor registry show company-internal

# Test registry connectivity
periplon-executor registry test company-internal

# Sync registry cache
periplon-executor registry sync official-marketplace
```

### 9. Example Usage

#### Complete Workflow with Predefined Tasks

```yaml
name: "Automated Report Generation"
version: "1.0.0"

inputs:
  report_date:
    type: string
    required: true
  google_folder:
    type: string
    default: "root"

tasks:
  # Generate report data
  generate_data:
    description: "Generate sales report for ${workflow.report_date}"
    agent: data_analyst
    outputs:
      report_file:
        source:
          type: file
          path: "./sales_report.pdf"

  # Upload to Google Drive (predefined task)
  upload_to_drive:
    uses: "google-drive-upload@^1.2.0"
    depends_on: [generate_data]
    inputs:
      file_path: "${task.generate_data.report_file}"
      folder_id: "${workflow.google_folder}"
      credentials: "${env.GOOGLE_CREDENTIALS}"
    outputs:
      drive_url: "${task.share_url}"

  # Create Notion page (predefined task)
  create_notion_page:
    uses: "notion-create-page@^1.0.0"
    depends_on: [upload_to_drive]
    inputs:
      database_id: "${env.NOTION_DB_ID}"
      title: "Sales Report - ${workflow.report_date}"
      properties:
        Date: "${workflow.report_date}"
        DriveLink: "${task.upload_to_drive.drive_url}"
      api_token: "${env.NOTION_TOKEN}"

  # Notify team (predefined task)
  send_slack_notification:
    uses: "slack-send-message@^2.0.0"
    depends_on: [create_notion_page]
    inputs:
      channel: "#reports"
      message: "📊 Sales report for ${workflow.report_date} is ready: ${task.create_notion_page.page_url}"
      webhook_url: "${env.SLACK_WEBHOOK}"

agents:
  data_analyst:
    description: "Analyze sales data and generate PDF report"
    tools: ["Read", "Write", "Bash"]
```

### 10. Testing Strategy

#### Unit Tests
- Task schema parsing
- Version constraint matching
- Dependency resolution
- Input/output validation

#### Integration Tests
- Git repository cloning
- Multi-source discovery
- Task reference resolution
- End-to-end workflow execution

#### Example Test Suite

```rust
#[cfg(test)]
mod tests {
    use super::*;

    #[tokio::test]
    async fn test_parse_predefined_task() {
        let yaml = r#"
apiVersion: "task/v1"
kind: "PredefinedTask"
metadata:
  name: "test-task"
  version: "1.0.0"
spec:
  inputs:
    input1: {type: string, required: true}
  outputs:
    output1: {type: string}
"#;
        let task = PredefinedTask::from_yaml(yaml).unwrap();
        assert_eq!(task.metadata.name, "test-task");
    }

    #[tokio::test]
    async fn test_version_constraint_matching() {
        let constraint = VersionConstraint::parse("^1.2.0").unwrap();
        assert!(constraint.matches("1.2.3"));
        assert!(constraint.matches("1.9.0"));
        assert!(!constraint.matches("2.0.0"));
    }

    #[tokio::test]
    async fn test_dependency_resolution() {
        // Test diamond dependency resolution
        let tasks = vec![
            create_task("A", "1.0.0", vec![("B", "^1.0"), ("C", "^1.0")]),
            create_task("B", "1.0.0", vec![("D", "^2.0")]),
            create_task("C", "1.0.0", vec![("D", "^2.0")]),
            create_task("D", "2.1.0", vec![]),
        ];

        let resolved = resolve_dependencies(&tasks).await.unwrap();
        assert_eq!(resolved.get("D").unwrap(), "2.1.0");
    }
}
```

### 11. Migration Path

#### Backward Compatibility

Existing workflows continue to work unchanged. New features opt-in via `uses:` syntax.

#### Converting Inline Tasks to Predefined

Tool to extract reusable tasks:

```bash
# Extract task from workflow
periplon-executor tasks extract workflow.yaml upload_to_drive > google-drive-upload.task.yaml

# Replace inline task with reference
periplon-executor tasks replace workflow.yaml upload_to_drive google-drive-upload@1.0.0
```

### 12. Documentation Requirements

1. **User Guide**: How to use predefined tasks in workflows
2. **Author Guide**: How to create and publish tasks
3. **API Reference**: Task definition schema reference
4. **Integration Guides**: Google, Notion, GitHub examples
5. **Security Guide**: Trust model and best practices

### 13. Future Enhancements

1. **Task Composition**: Combine multiple predefined tasks into higher-level tasks
2. **Conditional Tasks**: Tasks that adapt based on runtime conditions
3. **Streaming Tasks**: Tasks that produce incremental outputs
4. **Marketplace Analytics**: Download stats, ratings, reviews
5. **IDE Integration**: VSCode extension for task discovery/completion
6. **MCP Server Bridge**: Auto-generate predefined tasks from MCP servers
7. **AI-Generated Tasks**: Use LLM to generate task definitions from natural language

## Summary

This implementation plan provides a comprehensive roadmap for adding predefined task functionality to the DSL system, including support for multiple marketplaces and task groups. The phased approach allows for incremental delivery while building toward a full-featured task ecosystem.

### Key Features

**1. Predefined Tasks**
- Reusable task definitions with semantic versioning
- Reference or embed tasks in workflows
- Comprehensive input/output validation
- Dependency management and resolution

**2. Multiple Marketplace Support**
- Official public marketplace
- Private company/organization registries
- Community-driven marketplaces
- Self-hosted registries
- Priority-based resolution across registries
- Registry-specific task references (`registry::task@version`)
- Offline mode with intelligent caching
- Health monitoring and failover

**3. Task Groups**
- Bundle related tasks into cohesive suites
- Shared configuration across grouped tasks
- Predefined workflows within groups
- Namespace management to avoid conflicts
- Selective or full group imports
- Platform integration suites (Google, Slack, GitHub, etc.)

**4. Discovery & Distribution**
- Local filesystem (`.claude/tasks/`)
- Git repositories with auto-update
- Multiple registry support with authentication
- Full-text search across all sources
- Category and tag filtering
- Manifest-based auto-discovery

**5. Security & Trust**
- Four-level trust model (trusted, verified, community, untrusted)
- Per-registry trust configuration
- Permission scoping and validation
- Signature verification (future)
- Approval workflows for community tasks

### Implementation Timeline

**Total Duration**: 12 weeks for complete implementation

- **Phase 1** (Weeks 1-2): Local predefined tasks
- **Phase 2** (Weeks 3-4): Git repository support
- **Phase 3** (Weeks 5-6): Versioning & dependency resolution
- **Phase 4** (Weeks 7-8): Task groups
- **Phase 5** (Weeks 9-10): Multiple marketplace support
- **Phase 6** (Weeks 11-12): Publishing & marketplace infrastructure

**Post-Implementation**: Ongoing ecosystem growth and community task development

### Key Success Metrics

**Technical Metrics**:
- 90%+ test coverage for predefined task system
- Sub-100ms task discovery performance
- Sub-500ms cross-registry search
- 99.9% registry uptime (with mirrors)
- Zero breaking changes to existing workflows

**Ecosystem Metrics**:
- 50+ official predefined tasks in first 3 months
- 10+ task groups (integration suites) in first 6 months
- 5+ community task packages published
- 3+ operational registries (official, community, example company)
- 100+ total tasks across all registries within 6 months

**Adoption Metrics**:
- 1000+ task downloads in first quarter
- 50+ active workflows using predefined tasks
- 10+ organizations running private registries
- 80%+ user satisfaction with task discovery

### Use Case Examples

**1. Enterprise Integration**: Company maintains internal registry with proprietary integrations (Salesforce, SAP, internal APIs)

**2. DevOps Automation**: Public task groups for CI/CD pipelines (Docker, Kubernetes, cloud providers)

**3. Data Engineering**: ETL task suites for common data processing patterns

**4. SaaS Integration**: Community marketplace for popular SaaS platforms (Google, Notion, Slack, GitHub)

**5. Rapid Prototyping**: Developers quickly assemble workflows from pre-built tasks without writing custom agent logic