better-notion 1.5.5__py3-none-any.whl → 1.7.0__py3-none-any.whl

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.
@@ -0,0 +1,860 @@
1
+ """Agents plugin schema for AI agent documentation.
2
+
3
+ This module provides comprehensive documentation about the agents workflow
4
+ system that AI agents can consume to understand how to work with the system.
5
+
6
+ This is the SINGLE SOURCE OF TRUTH for agents documentation. All other
7
+ documentation (CLI help, website, etc.) should be derived from this schema.
8
+ """
9
+
10
+ from better_notion._cli.docs.base import (
11
+ Command,
12
+ Concept,
13
+ Schema,
14
+ Workflow,
15
+ WorkflowStep,
16
+ )
17
+
18
+ # =============================================================================
19
+ # DATABASE SCHEMAS
20
+ # =============================================================================
21
+
22
+ ORGANIZATIONS_DB_SCHEMA = {
23
+ "title": "Organizations",
24
+ "property_types": {
25
+ "Name": {
26
+ "type": "title",
27
+ "required": True,
28
+ "description": "Organization name"
29
+ },
30
+ "Slug": {
31
+ "type": "rich_text",
32
+ "required": False,
33
+ "description": "URL-friendly identifier"
34
+ },
35
+ "Status": {
36
+ "type": "select",
37
+ "required": False,
38
+ "options": ["Active", "Inactive"],
39
+ "default": "Active"
40
+ },
41
+ "Website": {
42
+ "type": "url",
43
+ "required": False,
44
+ "description": "Organization website URL"
45
+ }
46
+ },
47
+ "example_creation": {
48
+ "command": "notion pages create --parent ORG_DB_ID --title 'WareflowX'",
49
+ "properties": {
50
+ "Name": "WareflowX",
51
+ "Slug": "wareflowx",
52
+ "Status": "Active"
53
+ }
54
+ }
55
+ }
56
+
57
+ PROJECTS_DB_SCHEMA = {
58
+ "title": "Projects",
59
+ "property_types": {
60
+ "Name": {
61
+ "type": "title",
62
+ "required": True,
63
+ "description": "Project name"
64
+ },
65
+ "Organization": {
66
+ "type": "relation",
67
+ "required": True,
68
+ "target": "Organizations",
69
+ "description": "Organization this project belongs to"
70
+ },
71
+ "Status": {
72
+ "type": "select",
73
+ "required": False,
74
+ "options": ["Active", "On Hold", "Completed", "Archived"],
75
+ "default": "Active"
76
+ },
77
+ "Description": {
78
+ "type": "rich_text",
79
+ "required": False,
80
+ "description": "Project description"
81
+ }
82
+ },
83
+ "example_creation": {
84
+ "command": "notion pages create --parent PROJECTS_DB_ID --title 'Website Redesign'",
85
+ "properties": {
86
+ "Name": "Website Redesign",
87
+ "Organization": "ORG_PAGE_ID",
88
+ "Status": "Active"
89
+ }
90
+ }
91
+ }
92
+
93
+ VERSIONS_DB_SCHEMA = {
94
+ "title": "Versions",
95
+ "property_types": {
96
+ "Name": {
97
+ "type": "title",
98
+ "required": True,
99
+ "description": "Version name (e.g., v1.0.0)"
100
+ },
101
+ "Project": {
102
+ "type": "relation",
103
+ "required": True,
104
+ "target": "Projects",
105
+ "description": "Project this version belongs to"
106
+ },
107
+ "Status": {
108
+ "type": "select",
109
+ "required": False,
110
+ "options": ["Planned", "In Progress", "Released", "Archived"],
111
+ "default": "Planned"
112
+ },
113
+ "Release Date": {
114
+ "type": "date",
115
+ "required": False,
116
+ "description": "Planned or actual release date"
117
+ }
118
+ },
119
+ "example_creation": {
120
+ "command": "notion pages create --parent VERSIONS_DB_ID --title 'v1.0.0'",
121
+ "properties": {
122
+ "Name": "v1.0.0",
123
+ "Project": "PROJECT_PAGE_ID",
124
+ "Status": "Planned"
125
+ }
126
+ }
127
+ }
128
+
129
+ TASKS_DB_SCHEMA = {
130
+ "title": "Tasks",
131
+ "property_types": {
132
+ "Name": {
133
+ "type": "title",
134
+ "required": True,
135
+ "description": "Task name"
136
+ },
137
+ "Status": {
138
+ "type": "select",
139
+ "required": True,
140
+ "options": ["Todo", "In Progress", "Done", "Cancelled"],
141
+ "default": "Todo"
142
+ },
143
+ "Version": {
144
+ "type": "relation",
145
+ "required": True,
146
+ "target": "Versions",
147
+ "description": "Version this task belongs to (REQUIRED)"
148
+ },
149
+ "Target Version": {
150
+ "type": "relation",
151
+ "required": False,
152
+ "target": "Versions",
153
+ "description": "Version where task should be implemented"
154
+ },
155
+ "Dependencies": {
156
+ "type": "relation",
157
+ "required": False,
158
+ "target": "Tasks",
159
+ "dual_property": "Dependent Tasks",
160
+ "description": "Tasks that must complete before this task"
161
+ },
162
+ "Dependent Tasks": {
163
+ "type": "relation",
164
+ "required": False,
165
+ "target": "Tasks",
166
+ "dual_property": "Dependencies",
167
+ "description": "Tasks blocked by this task"
168
+ },
169
+ "Priority": {
170
+ "type": "select",
171
+ "required": False,
172
+ "options": ["Low", "Medium", "High", "Critical"],
173
+ "default": "Medium"
174
+ }
175
+ },
176
+ "example_creation": {
177
+ "command": "notion pages create --parent TASKS_DB_ID --title 'Fix login bug'",
178
+ "properties": {
179
+ "Name": "Fix login bug",
180
+ "Status": "Todo",
181
+ "Version": "VERSION_PAGE_ID",
182
+ "Priority": "High"
183
+ }
184
+ }
185
+ }
186
+
187
+ # =============================================================================
188
+ # CONCEPTS
189
+ # =============================================================================
190
+
191
+ WORKSPACE_CONCEPT = Concept(
192
+ name="workspace",
193
+ description=(
194
+ "A workspace is a collection of 8 interconnected databases that implement "
195
+ "a complete software development workflow management system. It provides "
196
+ "the structure for tracking organizations, projects, versions, tasks, ideas, "
197
+ "work issues, and incidents in a unified manner."
198
+ ),
199
+ properties={
200
+ "databases": [
201
+ "Organizations",
202
+ "Tags",
203
+ "Projects",
204
+ "Versions",
205
+ "Tasks",
206
+ "Ideas",
207
+ "Work Issues",
208
+ "Incidents",
209
+ ],
210
+ "initialization": "Created via 'agents init' command",
211
+ "detection": "Automatically detected by scanning for expected databases",
212
+ "uniqueness": "One workspace per Notion page",
213
+ },
214
+ relationships={
215
+ "Organizations → Projects": "Many-to-one (many projects belong to one organization)",
216
+ "Projects → Versions": "Many-to-one (many versions belong to one project)",
217
+ "Versions → Tasks": "Many-to-one (many tasks belong to one version)",
218
+ "Tasks → Tasks": "Self-referential (tasks can depend on other tasks)",
219
+ },
220
+ )
221
+
222
+ ORGANIZATION_CONCEPT = Concept(
223
+ name="organization",
224
+ description=(
225
+ "An organization represents a company, team, or entity that owns projects. "
226
+ "Organizations are the top-level entities in the agents workflow hierarchy."
227
+ ),
228
+ properties={
229
+ "database_schema": ORGANIZATIONS_DB_SCHEMA,
230
+ "creation": {
231
+ "command": "notion agents orgs create --name 'Org Name' --slug 'org-slug'",
232
+ "alternative": "notion pages create --parent ORG_DB_ID --title 'Org Name' --properties '{...}'",
233
+ "required_properties": ["Name"],
234
+ "property_types": {
235
+ "Name": "title (required)",
236
+ "Slug": "rich_text (optional, URL-friendly identifier)",
237
+ "Status": "select [Active, Inactive] (optional, default: Active)",
238
+ "Website": "url (optional)"
239
+ }
240
+ },
241
+ "listing": {
242
+ "command": "notion agents orgs list",
243
+ "description": "List all organizations in workspace"
244
+ }
245
+ },
246
+ relationships={
247
+ "Projects": "One-to-many - organization contains multiple projects",
248
+ "description": "All projects must belong to an organization"
249
+ },
250
+ )
251
+
252
+ TASK_CONCEPT = Concept(
253
+ name="task",
254
+ description=(
255
+ "A task represents a unit of work that needs to be completed as part of "
256
+ "a project version. Tasks have states (Todo, In Progress, Done, Cancelled) "
257
+ "and can depend on other tasks."
258
+ ),
259
+ properties={
260
+ "required_properties": {
261
+ "Title": "Task name (title property)",
262
+ "Status": "Current state: Todo, In Progress, Done, Cancelled",
263
+ "Version": "Relation to Version database (required)",
264
+ },
265
+ "optional_properties": {
266
+ "Target Version": "Version where task should be implemented",
267
+ "Dependencies": "Other tasks this task depends on",
268
+ "Dependent Tasks": "Tasks that depend on this task",
269
+ },
270
+ "workflow": "Todo → In Progress → Done",
271
+ },
272
+ relationships={
273
+ "Version": "Required - each task must belong to one version",
274
+ "Dependencies": "Optional - tasks that must complete before this task",
275
+ "Dependent Tasks": "Inverse of dependencies - tasks blocked by this task",
276
+ },
277
+ )
278
+
279
+ PROJECT_CONCEPT = Concept(
280
+ name="project",
281
+ description=(
282
+ "A project represents a software project or product being developed. "
283
+ "Projects belong to organizations and contain multiple versions."
284
+ ),
285
+ properties={
286
+ "required_properties": {
287
+ "Title": "Project name",
288
+ "Organization": "Relation to organization (required)",
289
+ },
290
+ "contains": ["Versions", "Tasks", "Ideas", "Work Issues", "Incidents"],
291
+ },
292
+ relationships={
293
+ "Organization": "Required - each project belongs to one organization",
294
+ "Versions": "One-to-many - project contains multiple versions",
295
+ },
296
+ )
297
+
298
+ VERSION_CONCEPT = Concept(
299
+ name="version",
300
+ description=(
301
+ "A version represents a release or milestone of a project. Examples: "
302
+ "v1.0.0, v1.1.0, v2.0.0. Tasks are created within versions."
303
+ ),
304
+ properties={
305
+ "required_properties": {
306
+ "Title": "Version name (e.g., v1.0.0)",
307
+ "Project": "Relation to project (required)",
308
+ },
309
+ "contains": ["Tasks"],
310
+ "examples": ["v1.0.0", "v1.1.0", "v2.0.0-beta", "sprint-1"],
311
+ },
312
+ relationships={
313
+ "Project": "Required - each version belongs to one project",
314
+ "Tasks": "One-to-many - version contains multiple tasks",
315
+ },
316
+ )
317
+
318
+ # =============================================================================
319
+ # WORKFLOWS
320
+ # =============================================================================
321
+
322
+ INITIALIZE_WORKSPACE = Workflow(
323
+ name="initialize_workspace",
324
+ description="Create a complete agents workflow management system with 8 databases",
325
+ steps=[
326
+ WorkflowStep(
327
+ description="Detect existing workspace in page",
328
+ purpose="Prevent duplicate workspace creation",
329
+ ),
330
+ WorkflowStep(
331
+ description="Create Organizations database",
332
+ command="notion databases create --parent PAGE_ID --title Organizations",
333
+ ),
334
+ WorkflowStep(
335
+ description="Create Tags database",
336
+ command="notion databases create --parent PAGE_ID --title Tags",
337
+ ),
338
+ WorkflowStep(
339
+ description="Create Projects database",
340
+ command="notion databases create --parent PAGE_ID --title Projects",
341
+ ),
342
+ WorkflowStep(
343
+ description="Create Versions database",
344
+ command="notion databases create --parent PAGE_ID --title Versions",
345
+ ),
346
+ WorkflowStep(
347
+ description="Create Tasks database",
348
+ command="notion databases create --parent PAGE_ID --title Tasks",
349
+ ),
350
+ WorkflowStep(
351
+ description="Create Ideas database",
352
+ command="notion databases create --parent PAGE_ID --title Ideas",
353
+ ),
354
+ WorkflowStep(
355
+ description="Create Work Issues database",
356
+ command="notion databases create --parent PAGE_ID --title 'Work Issues'",
357
+ ),
358
+ WorkflowStep(
359
+ description="Create Incidents database",
360
+ command="notion databases create --parent PAGE_ID --title Incidents",
361
+ ),
362
+ WorkflowStep(
363
+ description="Establish database relationships",
364
+ purpose="Create relations between databases (Projects→Organizations, etc.)",
365
+ ),
366
+ WorkflowStep(
367
+ description="Save workspace metadata",
368
+ command="agents info --parent-page PAGE_ID",
369
+ purpose="Verify setup and get database IDs",
370
+ ),
371
+ ],
372
+ commands=[
373
+ "agents init --parent-page PAGE_ID",
374
+ "agents info --parent-page PAGE_ID",
375
+ ],
376
+ prerequisites=["valid_page_id"],
377
+ error_recovery={
378
+ "workspace_exists": {
379
+ "message": "Detected 5+ expected databases in page",
380
+ "meaning": "Workspace already initialized in this page",
381
+ "solutions": [
382
+ {
383
+ "flag": "--skip",
384
+ "action": "use_existing_workspace",
385
+ "description": "Skip initialization and use existing workspace",
386
+ "when_to_use": "You want to keep existing data",
387
+ },
388
+ {
389
+ "flag": "--reset",
390
+ "action": "recreate_workspace",
391
+ "description": "Delete all databases and recreate (WARNING: data loss)",
392
+ "warning": "This will delete all existing databases and their content",
393
+ "when_to_use": "You want to start completely fresh",
394
+ },
395
+ ],
396
+ }
397
+ },
398
+ )
399
+
400
+ CREATE_ORGANIZATION_WORKFLOW = Workflow(
401
+ name="create_organization",
402
+ description="Create a new organization in the agents workspace",
403
+ steps=[
404
+ WorkflowStep(
405
+ description="Verify workspace is initialized",
406
+ command="agents info --parent-page PAGE_ID",
407
+ purpose="Get Organizations database ID and verify workspace exists",
408
+ ),
409
+ WorkflowStep(
410
+ description="Create organization using agents command",
411
+ command="notion agents orgs create --name 'Org Name' --slug 'org-slug'",
412
+ purpose="Create organization with proper properties",
413
+ ),
414
+ ],
415
+ commands=[
416
+ "agents info --parent-page PAGE_ID",
417
+ "notion agents orgs create --name 'WareflowX' --slug 'wareflowx'",
418
+ ],
419
+ prerequisites=["workspace_initialized"],
420
+ error_recovery={
421
+ "workspace_not_found": {
422
+ "message": "No workspace detected in page",
423
+ "solution": "Run 'agents init --parent-page PAGE_ID' first to create workspace",
424
+ },
425
+ "missing_name": {
426
+ "message": "Organization name is required",
427
+ "solution": "Always specify --name flag when creating organization",
428
+ },
429
+ },
430
+ )
431
+
432
+ CREATE_PROJECT_WORKFLOW = Workflow(
433
+ name="create_project",
434
+ description="Create a new project in an organization",
435
+ steps=[
436
+ WorkflowStep(
437
+ description="Verify workspace is initialized",
438
+ command="agents info --parent-page PAGE_ID",
439
+ purpose="Get database IDs and verify workspace exists",
440
+ ),
441
+ WorkflowStep(
442
+ description="List organizations to find target",
443
+ command="notion agents orgs list",
444
+ purpose="Identify which organization the project belongs to",
445
+ ),
446
+ WorkflowStep(
447
+ description="Create project with organization relation",
448
+ command="notion agents projects create --org 'Org Name/Slug' --name 'Project Name'",
449
+ purpose="Create project with Organization relation (required)",
450
+ ),
451
+ ],
452
+ commands=[
453
+ "agents info --parent-page PAGE_ID",
454
+ "notion agents orgs list",
455
+ "notion agents projects create --org 'WareflowX' --name 'Website Redesign'",
456
+ ],
457
+ prerequisites=["workspace_initialized", "organization_exists"],
458
+ error_recovery={
459
+ "workspace_not_found": {
460
+ "message": "No workspace detected in page",
461
+ "solution": "Run 'agents init --parent-page PAGE_ID' first to create workspace",
462
+ },
463
+ "organization_not_found": {
464
+ "message": "Organization not found",
465
+ "solution": "Create organization first with 'agents orgs create --name NAME'",
466
+ },
467
+ "missing_org_relation": {
468
+ "message": "Project must have Organization relation",
469
+ "solution": "Always specify --org flag when creating project",
470
+ },
471
+ },
472
+ )
473
+
474
+ CREATE_VERSION_WORKFLOW = Workflow(
475
+ name="create_version",
476
+ description="Create a new version in a project",
477
+ steps=[
478
+ WorkflowStep(
479
+ description="Verify workspace is initialized",
480
+ command="agents info --parent-page PAGE_ID",
481
+ purpose="Get database IDs and verify workspace exists",
482
+ ),
483
+ WorkflowStep(
484
+ description="List projects to find target",
485
+ command="notion agents projects list",
486
+ purpose="Identify which project the version belongs to",
487
+ ),
488
+ WorkflowStep(
489
+ description="Create version with project relation",
490
+ command="notion agents versions create --project 'Project Name' --name 'v1.0.0'",
491
+ purpose="Create version with Project relation (required)",
492
+ ),
493
+ ],
494
+ commands=[
495
+ "agents info --parent-page PAGE_ID",
496
+ "notion agents projects list",
497
+ "notion agents versions create --project 'Website Redesign' --name 'v1.0.0'",
498
+ ],
499
+ prerequisites=["workspace_initialized", "organization_exists", "project_exists"],
500
+ error_recovery={
501
+ "workspace_not_found": {
502
+ "message": "No workspace detected in page",
503
+ "solution": "Run 'agents init --parent-page PAGE_ID' first to create workspace",
504
+ },
505
+ "project_not_found": {
506
+ "message": "Project not found",
507
+ "solution": "Create project first with 'agents projects create --org ORG --name NAME'",
508
+ },
509
+ "missing_project_relation": {
510
+ "message": "Version must have Project relation",
511
+ "solution": "Always specify --project flag when creating version",
512
+ },
513
+ },
514
+ )
515
+
516
+ CREATE_TASK_WORKFLOW = Workflow(
517
+ name="create_task",
518
+ description="Create a new task in the agents workflow system",
519
+ steps=[
520
+ WorkflowStep(
521
+ description="Verify workspace is initialized",
522
+ command="agents info --parent-page PAGE_ID",
523
+ purpose="Get database IDs and verify workspace exists",
524
+ ),
525
+ WorkflowStep(
526
+ description="Identify target Version",
527
+ purpose="Tasks must belong to a Version (required relation)",
528
+ ),
529
+ WorkflowStep(
530
+ description="Create task page with proper properties",
531
+ command="notion pages create --parent TASKS_DB_ID --title 'Task Name' --properties '{...}'",
532
+ purpose="Create task with Status and Version relation",
533
+ ),
534
+ ],
535
+ commands=[
536
+ "agents info --parent-page PAGE_ID",
537
+ "notion pages create --parent TASKS_DB_ID --title 'Task' --properties '{\"Status\": \"Todo\", \"Version\": \"VERSION_ID\"}'",
538
+ ],
539
+ prerequisites=["workspace_initialized"],
540
+ error_recovery={
541
+ "workspace_not_found": {
542
+ "message": "No workspace detected in page",
543
+ "solution": "Run 'agents init' first to create workspace",
544
+ },
545
+ "missing_version_relation": {
546
+ "message": "Task must have a Version relation",
547
+ "solution": "Always specify Version property when creating task",
548
+ },
549
+ },
550
+ )
551
+
552
+ QUERY_TASKS_WORKFLOW = Workflow(
553
+ name="query_tasks",
554
+ description="Query and filter tasks in the workspace",
555
+ steps=[
556
+ WorkflowStep(
557
+ description="Get workspace database IDs",
558
+ command="agents info --parent-page PAGE_ID",
559
+ purpose="Obtain tasks database ID",
560
+ ),
561
+ WorkflowStep(
562
+ description="Query tasks database",
563
+ command="notion databases query --database TASKS_DB_ID --filter '{...}'",
564
+ purpose="Retrieve tasks with optional filtering",
565
+ ),
566
+ ],
567
+ commands=[
568
+ "agents info --parent-page PAGE_ID",
569
+ "notion databases query --database TASKS_DB_ID",
570
+ ],
571
+ prerequisites=["workspace_initialized"],
572
+ )
573
+
574
+ # =============================================================================
575
+ # COMMANDS
576
+ # =============================================================================
577
+
578
+ INIT_COMMAND = Command(
579
+ name="init",
580
+ purpose="Initialize a new agents workspace or manage existing one",
581
+ description=(
582
+ "Creates a complete workflow management system with 8 databases "
583
+ "and their relationships. Can detect existing workspaces to prevent duplicates."
584
+ ),
585
+ flags={
586
+ "--parent-page": "Parent page ID where workspace will be created",
587
+ "--workspace-name": "Name for the workspace (default: 'Agents Workspace')",
588
+ "--reset": "Force recreation (deletes existing databases and recreates)",
589
+ "--skip": "Skip initialization if workspace already exists",
590
+ "--debug": "Enable debug output",
591
+ },
592
+ workflow="initialize_workspace",
593
+ when_to_use=[
594
+ "First time setting up agents system in a page",
595
+ "Starting fresh in a new page",
596
+ "Recovering from corrupted workspace (use --reset)",
597
+ "Safely checking for existing workspace (use --skip)",
598
+ ],
599
+ error_recovery={
600
+ "workspace_exists": {
601
+ "solutions": [
602
+ {"flag": "--skip", "use_case": "Keep existing workspace"},
603
+ {"flag": "--reset", "use_case": "Delete and recreate (data loss)"},
604
+ ]
605
+ }
606
+ },
607
+ )
608
+
609
+ INFO_COMMAND = Command(
610
+ name="info",
611
+ purpose="Display workspace status and metadata",
612
+ description="Shows whether a workspace exists, database IDs, and workspace info",
613
+ flags={
614
+ "--parent-page": "Parent page ID to check for workspace",
615
+ },
616
+ workflow=None,
617
+ when_to_use=[
618
+ "Verify workspace initialization",
619
+ "Get database IDs for queries",
620
+ "Check workspace version and metadata",
621
+ "Debug workspace issues",
622
+ ],
623
+ )
624
+
625
+ # =============================================================================
626
+ # SUBCOMMANDS
627
+ # =============================================================================
628
+
629
+ # ORGS_SUBCOMMAND documents the agents orgs commands
630
+ ORGS_COMMAND = Command(
631
+ name="orgs",
632
+ purpose="Organizations management - top-level entities in workflow hierarchy",
633
+ description=(
634
+ "Organizations are the starting point for all projects. "
635
+ "Every project must belong to an organization."
636
+ ),
637
+ subcommands={
638
+ "list": {
639
+ "purpose": "List all organizations in workspace",
640
+ "usage": "notion agents orgs list",
641
+ "output": "Returns list of organizations with their IDs and properties"
642
+ },
643
+ "create": {
644
+ "purpose": "Create a new organization",
645
+ "usage": "notion agents orgs create --name NAME [--slug SLUG] [--status STATUS]",
646
+ "required_flags": {
647
+ "--name": "Organization name (required)"
648
+ },
649
+ "optional_flags": {
650
+ "--slug": "URL-friendly identifier (optional)",
651
+ "--status": "Active or Inactive (default: Active)"
652
+ },
653
+ "examples": [
654
+ "notion agents orgs create --name 'WareflowX'",
655
+ "notion agents orgs create --name 'WareflowX' --slug 'wareflowx' --status 'Active'"
656
+ ]
657
+ },
658
+ "info": {
659
+ "purpose": "Get organization details",
660
+ "usage": "notion agents orgs info --org ORG_NAME_OR_SLUG",
661
+ "output": "Returns organization details with projects count"
662
+ }
663
+ }
664
+ )
665
+
666
+ # PROJECTS_SUBCOMMAND documents the agents projects commands
667
+ PROJECTS_COMMAND = Command(
668
+ name="projects",
669
+ purpose="Projects management - belongs to organizations",
670
+ description=(
671
+ "Projects represent software development efforts. "
672
+ "Every project must belong to an organization."
673
+ ),
674
+ subcommands={
675
+ "list": {
676
+ "purpose": "List all projects (optionally filtered by organization)",
677
+ "usage": "notion agents projects list [--org ORG_NAME]",
678
+ "output": "Returns list of projects with their organizations"
679
+ },
680
+ "create": {
681
+ "purpose": "Create a new project in an organization",
682
+ "usage": "notion agents projects create --org ORG_NAME --name NAME",
683
+ "required_flags": {
684
+ "--org": "Organization name or slug (required)",
685
+ "--name": "Project name (required)"
686
+ },
687
+ "examples": [
688
+ "notion agents projects create --org 'WareflowX' --name 'Website Redesign'"
689
+ ]
690
+ },
691
+ "info": {
692
+ "purpose": "Get project details",
693
+ "usage": "notion agents projects info --project PROJECT_NAME"
694
+ }
695
+ }
696
+ )
697
+
698
+ # VERSIONS_SUBCOMMAND documents the agents versions commands
699
+ VERSIONS_COMMAND = Command(
700
+ name="versions",
701
+ purpose="Versions management - releases and milestones",
702
+ description=(
703
+ "Versions represent releases or milestones. "
704
+ "Every version must belong to a project."
705
+ ),
706
+ subcommands={
707
+ "list": {
708
+ "purpose": "List all versions (optionally filtered by project)",
709
+ "usage": "notion agents versions list [--project PROJECT_NAME]",
710
+ "output": "Returns list of versions with their projects"
711
+ },
712
+ "create": {
713
+ "purpose": "Create a new version in a project",
714
+ "usage": "notion agents versions create --project PROJECT_NAME --name VERSION",
715
+ "required_flags": {
716
+ "--project": "Project name (required)",
717
+ "--name": "Version name e.g. v1.0.0 (required)"
718
+ },
719
+ "examples": [
720
+ "notion agents versions create --project 'Website Redesign' --name 'v1.0.0'",
721
+ "notion agents versions create --project 'Website Redesign' --name 'sprint-1'"
722
+ ]
723
+ }
724
+ }
725
+ )
726
+
727
+ # TASKS_SUBCOMMAND documents the agents tasks commands
728
+ TASKS_COMMAND = Command(
729
+ name="tasks",
730
+ purpose="Tasks management - units of work in versions",
731
+ description=(
732
+ "Tasks represent work items. Every task must belong to a version. "
733
+ "Tasks can have dependencies on other tasks."
734
+ ),
735
+ subcommands={
736
+ "list": {
737
+ "purpose": "List all tasks (optionally filtered by version or status)",
738
+ "usage": "notion agents tasks list [--version VERSION] [--status STATUS]",
739
+ "output": "Returns list of tasks with their versions and status"
740
+ },
741
+ "create": {
742
+ "purpose": "Create a new task in a version",
743
+ "usage": "notion agents tasks create --version VERSION_NAME --name TASK_NAME",
744
+ "required_flags": {
745
+ "--version": "Version name (required)",
746
+ "--name": "Task name (required)"
747
+ },
748
+ "optional_flags": {
749
+ "--status": "Todo, In Progress, Done (default: Todo)",
750
+ "--priority": "Low, Medium, High, Critical (default: Medium)"
751
+ },
752
+ "examples": [
753
+ "notion agents tasks create --version 'v1.0.0' --name 'Fix login bug'",
754
+ "notion agents tasks create --version 'v1.0.0' --name 'Add feature' --status 'Todo' --priority 'High'"
755
+ ]
756
+ },
757
+ "next": {
758
+ "purpose": "Find next available task to work on",
759
+ "usage": "notion agents tasks next [--version VERSION]",
760
+ "description": "Finds tasks with status 'Todo' and no incomplete dependencies"
761
+ }
762
+ }
763
+ )
764
+
765
+ # =============================================================================
766
+ # COMPLETE SCHEMA
767
+ # =============================================================================
768
+
769
+ AGENTS_SCHEMA = Schema(
770
+ name="agents",
771
+ version="2.0.0",
772
+ description=(
773
+ "Workflow management system for software development. "
774
+ "Provides complete structure for tracking organizations, projects, "
775
+ "versions, tasks, ideas, work issues, and incidents."
776
+ ),
777
+ concepts=[
778
+ WORKSPACE_CONCEPT,
779
+ ORGANIZATION_CONCEPT,
780
+ PROJECT_CONCEPT,
781
+ VERSION_CONCEPT,
782
+ TASK_CONCEPT,
783
+ ],
784
+ workflows=[
785
+ INITIALIZE_WORKSPACE,
786
+ CREATE_ORGANIZATION_WORKFLOW,
787
+ CREATE_PROJECT_WORKFLOW,
788
+ CREATE_VERSION_WORKFLOW,
789
+ CREATE_TASK_WORKFLOW,
790
+ QUERY_TASKS_WORKFLOW,
791
+ ],
792
+ commands={
793
+ "init": INIT_COMMAND,
794
+ "info": INFO_COMMAND,
795
+ "orgs": ORGS_COMMAND,
796
+ "projects": PROJECTS_COMMAND,
797
+ "versions": VERSIONS_COMMAND,
798
+ "tasks": TASKS_COMMAND,
799
+ },
800
+ best_practices=[
801
+ "Follow the hierarchy: Organization → Project → Version → Task",
802
+ "Always run 'agents info' before operations to verify workspace state",
803
+ "Use --skip flag to safely check for existing workspaces (prevents duplicates)",
804
+ "Use --reset flag only when you need to recreate workspace (causes data loss)",
805
+ "Create organization before creating projects",
806
+ "Create project before creating versions",
807
+ "Create version before creating tasks",
808
+ "Tasks must have a Version relation (required)",
809
+ "Projects must have an Organization relation (required)",
810
+ "Use 'agents tasks next' to find next available task",
811
+ ],
812
+ examples={
813
+ "initial_setup": """# First time setup
814
+ notion agents init --parent-page PAGE_ID
815
+
816
+ # Verify setup
817
+ notion agents info --parent-page PAGE_ID""",
818
+
819
+ "safe_initialization": """# Check if workspace exists, use if found
820
+ notion agents init --parent-page PAGE_ID --skip""",
821
+
822
+ "force_recreate": """# Delete existing workspace and recreate (WARNING: data loss)
823
+ notion agents init --parent-page PAGE_ID --reset""",
824
+
825
+ "complete_lifecycle": """# Complete workflow: Org → Project → Version → Task
826
+
827
+ # 1. Create organization
828
+ notion agents orgs create --name "WareflowX" --slug "wareflowx"
829
+
830
+ # 2. Create project in organization
831
+ notion agents projects create --org "WareflowX" --name "Website Redesign"
832
+
833
+ # 3. Create version in project
834
+ notion agents versions create --project "Website Redesign" --name "v1.0.0"
835
+
836
+ # 4. Create task in version
837
+ notion agents tasks create --version "v1.0.0" --name "Fix login bug" --priority "High".""",
838
+
839
+ "query_and_create": """# List existing organizations
840
+ notion agents orgs list
841
+
842
+ # List projects in organization
843
+ notion agents projects list --org "WareflowX"
844
+
845
+ # List tasks in version
846
+ notion agents tasks list --version "v1.0.0"
847
+
848
+ # Find next task to work on
849
+ notion agents tasks next --version "v1.0.0\"""",
850
+
851
+ "create_task": """# Create task using agents command (recommended)
852
+ notion agents tasks create --version "v1.0.0" --name "Fix login bug"
853
+
854
+ # Alternative: Create task directly with pages command
855
+ notion pages create \\
856
+ --parent TASKS_DB_ID \\
857
+ --title "Fix login bug" \\
858
+ --properties '{"Status": "Todo", "Version": "VERSION_ID", "Priority": "High"}'""",
859
+ },
860
+ )