@karthikrajkumar.kannan/get-things-done 1.0.0

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.
Files changed (177) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +237 -0
  3. package/agents/backward/gtd-accuracy-verifier.md +198 -0
  4. package/agents/backward/gtd-api-doc-writer.md +130 -0
  5. package/agents/backward/gtd-api-extractor.md +128 -0
  6. package/agents/backward/gtd-architecture-analyzer.md +144 -0
  7. package/agents/backward/gtd-capacity-writer.md +123 -0
  8. package/agents/backward/gtd-codebase-mapper.md +274 -0
  9. package/agents/backward/gtd-completeness-auditor.md +129 -0
  10. package/agents/backward/gtd-data-flow-tracer.md +104 -0
  11. package/agents/backward/gtd-dependency-analyzer.md +98 -0
  12. package/agents/backward/gtd-diagram-generator.md +152 -0
  13. package/agents/backward/gtd-hld-writer.md +123 -0
  14. package/agents/backward/gtd-lld-writer.md +126 -0
  15. package/agents/backward/gtd-pattern-detector.md +111 -0
  16. package/agents/backward/gtd-performance-profiler.md +93 -0
  17. package/agents/backward/gtd-runbook-writer.md +126 -0
  18. package/agents/backward/gtd-security-scanner.md +106 -0
  19. package/agents/backward/gtd-sysdesign-writer.md +137 -0
  20. package/agents/backward/gtd-tdd-writer.md +125 -0
  21. package/agents/forward/gtd-code-reviewer.md +130 -0
  22. package/agents/forward/gtd-debugger.md +133 -0
  23. package/agents/forward/gtd-deployer.md +110 -0
  24. package/agents/forward/gtd-executor.md +110 -0
  25. package/agents/forward/gtd-phase-researcher.md +114 -0
  26. package/agents/forward/gtd-plan-checker.md +132 -0
  27. package/agents/forward/gtd-planner.md +136 -0
  28. package/agents/forward/gtd-project-researcher.md +106 -0
  29. package/agents/forward/gtd-research-synthesizer.md +99 -0
  30. package/agents/forward/gtd-roadmapper.md +126 -0
  31. package/agents/forward/gtd-test-runner.md +119 -0
  32. package/agents/forward/gtd-verifier.md +115 -0
  33. package/agents/sync/gtd-alignment-auditor.md +222 -0
  34. package/agents/sync/gtd-drift-detector.md +222 -0
  35. package/agents/sync/gtd-reconciliation-planner.md +194 -0
  36. package/bin/gtd-tools.cjs +89 -0
  37. package/bin/install.js +164 -0
  38. package/commands/gtd/backward/analyze.md +42 -0
  39. package/commands/gtd/backward/create-all.md +32 -0
  40. package/commands/gtd/backward/create-api-docs.md +33 -0
  41. package/commands/gtd/backward/create-capacity.md +33 -0
  42. package/commands/gtd/backward/create-hld.md +33 -0
  43. package/commands/gtd/backward/create-lld.md +33 -0
  44. package/commands/gtd/backward/create-runbook.md +33 -0
  45. package/commands/gtd/backward/create-sysdesign.md +33 -0
  46. package/commands/gtd/backward/create-tdd.md +33 -0
  47. package/commands/gtd/backward/diff.md +22 -0
  48. package/commands/gtd/backward/doc-status.md +24 -0
  49. package/commands/gtd/backward/review-docs.md +22 -0
  50. package/commands/gtd/backward/scan.md +32 -0
  51. package/commands/gtd/backward/update-docs.md +30 -0
  52. package/commands/gtd/backward/verify-docs.md +28 -0
  53. package/commands/gtd/forward/add-phase.md +28 -0
  54. package/commands/gtd/forward/autonomous.md +28 -0
  55. package/commands/gtd/forward/code-review.md +28 -0
  56. package/commands/gtd/forward/complete-milestone.md +28 -0
  57. package/commands/gtd/forward/debug.md +28 -0
  58. package/commands/gtd/forward/discuss-phase.md +29 -0
  59. package/commands/gtd/forward/execute-phase.md +28 -0
  60. package/commands/gtd/forward/fast.md +28 -0
  61. package/commands/gtd/forward/new-milestone.md +28 -0
  62. package/commands/gtd/forward/new-project.md +29 -0
  63. package/commands/gtd/forward/next.md +28 -0
  64. package/commands/gtd/forward/plan-phase.md +29 -0
  65. package/commands/gtd/forward/progress.md +28 -0
  66. package/commands/gtd/forward/quick.md +28 -0
  67. package/commands/gtd/forward/ship.md +28 -0
  68. package/commands/gtd/forward/verify-work.md +28 -0
  69. package/commands/gtd/sync/audit.md +27 -0
  70. package/commands/gtd/sync/drift.md +27 -0
  71. package/commands/gtd/sync/reconcile.md +27 -0
  72. package/commands/gtd/sync/sync.md +27 -0
  73. package/commands/gtd/utility/health.md +53 -0
  74. package/commands/gtd/utility/help.md +61 -0
  75. package/commands/gtd/utility/map-codebase.md +27 -0
  76. package/commands/gtd/utility/settings.md +65 -0
  77. package/commands/gtd/utility/status.md +57 -0
  78. package/contexts/analysis.md +26 -0
  79. package/contexts/execution.md +35 -0
  80. package/contexts/planning.md +33 -0
  81. package/contexts/research.md +26 -0
  82. package/contexts/review.md +27 -0
  83. package/contexts/writing.md +29 -0
  84. package/hooks/gtd-check-update.js +37 -0
  85. package/hooks/gtd-context-monitor.js +32 -0
  86. package/hooks/gtd-prompt-guard.js +35 -0
  87. package/hooks/gtd-statusline.js +32 -0
  88. package/lib/agent-skills.cjs +130 -0
  89. package/lib/analysis.cjs +242 -0
  90. package/lib/config.cjs +255 -0
  91. package/lib/deploy.cjs +222 -0
  92. package/lib/diff-engine.cjs +245 -0
  93. package/lib/docs.cjs +243 -0
  94. package/lib/drift-engine.cjs +202 -0
  95. package/lib/file-ops.cjs +106 -0
  96. package/lib/frontmatter.cjs +100 -0
  97. package/lib/git.cjs +137 -0
  98. package/lib/init.cjs +370 -0
  99. package/lib/installer-core.cjs +197 -0
  100. package/lib/installers/augment.cjs +62 -0
  101. package/lib/installers/claude.cjs +89 -0
  102. package/lib/installers/cline.cjs +96 -0
  103. package/lib/installers/codex.cjs +63 -0
  104. package/lib/installers/copilot.cjs +62 -0
  105. package/lib/installers/cursor.cjs +62 -0
  106. package/lib/installers/gemini.cjs +62 -0
  107. package/lib/installers/opencode.cjs +62 -0
  108. package/lib/installers/windsurf.cjs +62 -0
  109. package/lib/phase.cjs +206 -0
  110. package/lib/roadmap.cjs +156 -0
  111. package/lib/scale-adapter.cjs +192 -0
  112. package/lib/security.cjs +243 -0
  113. package/lib/state.cjs +320 -0
  114. package/lib/template.cjs +218 -0
  115. package/lib/test-runner.cjs +202 -0
  116. package/package.json +76 -0
  117. package/references/agent-contracts.md +157 -0
  118. package/references/analysis-patterns.md +138 -0
  119. package/references/context-budget.md +148 -0
  120. package/references/diagram-conventions.md +88 -0
  121. package/references/document-standards.md +60 -0
  122. package/references/framework-signatures.md +609 -0
  123. package/references/gate-prompts.md +239 -0
  124. package/references/language-analyzers.md +227 -0
  125. package/references/planning-config.md +125 -0
  126. package/references/questioning.md +142 -0
  127. package/references/verification-patterns.md +67 -0
  128. package/templates/backward/api-docs/standard.md +42 -0
  129. package/templates/backward/capacity/standard.md +50 -0
  130. package/templates/backward/formats/compliance-guide.md +45 -0
  131. package/templates/backward/hld/standard.md +62 -0
  132. package/templates/backward/lld/standard.md +63 -0
  133. package/templates/backward/runbook/standard.md +50 -0
  134. package/templates/backward/system-design/standard.md +64 -0
  135. package/templates/backward/tdd/compliance.md +146 -0
  136. package/templates/backward/tdd/enterprise.md +134 -0
  137. package/templates/backward/tdd/standard.md +88 -0
  138. package/templates/backward/tdd/startup.md +51 -0
  139. package/templates/forward/context.md +65 -0
  140. package/templates/forward/phase-prompt.md +109 -0
  141. package/templates/forward/project.md +71 -0
  142. package/templates/forward/requirements.md +74 -0
  143. package/templates/forward/research/ARCHITECTURE.md +118 -0
  144. package/templates/forward/research/FEATURES.md +95 -0
  145. package/templates/forward/research/PITFALLS.md +106 -0
  146. package/templates/forward/research/STACK.md +80 -0
  147. package/templates/forward/research/SUMMARY.md +86 -0
  148. package/templates/forward/roadmap.md +72 -0
  149. package/workflows/backward/analyze-codebase.md +123 -0
  150. package/workflows/backward/create-all.md +53 -0
  151. package/workflows/backward/generate-document.md +182 -0
  152. package/workflows/backward/incremental-update.md +71 -0
  153. package/workflows/backward/review-document.md +102 -0
  154. package/workflows/backward/scan-codebase.md +111 -0
  155. package/workflows/backward/verify-document.md +79 -0
  156. package/workflows/forward/add-phase.md +29 -0
  157. package/workflows/forward/autonomous.md +62 -0
  158. package/workflows/forward/code-review.md +78 -0
  159. package/workflows/forward/complete-milestone.md +45 -0
  160. package/workflows/forward/debug.md +78 -0
  161. package/workflows/forward/deploy-local.md +51 -0
  162. package/workflows/forward/discuss-phase.md +89 -0
  163. package/workflows/forward/execute-phase.md +138 -0
  164. package/workflows/forward/fast.md +64 -0
  165. package/workflows/forward/new-milestone.md +61 -0
  166. package/workflows/forward/new-project.md +126 -0
  167. package/workflows/forward/next.md +49 -0
  168. package/workflows/forward/plan-phase.md +100 -0
  169. package/workflows/forward/progress.md +37 -0
  170. package/workflows/forward/quick.md +65 -0
  171. package/workflows/forward/ship.md +40 -0
  172. package/workflows/forward/test-phase.md +47 -0
  173. package/workflows/forward/verify-work.md +52 -0
  174. package/workflows/sync/audit.md +110 -0
  175. package/workflows/sync/detect-drift.md +122 -0
  176. package/workflows/sync/reconcile.md +113 -0
  177. package/workflows/sync/sync.md +150 -0
@@ -0,0 +1,110 @@
1
+ <purpose>
2
+ Run a full alignment audit across specifications, code, and documentation. Produces a comprehensive coverage matrix and gap analysis showing what is implemented, documented, and tested — and what is missing.
3
+ </purpose>
4
+
5
+ <available_agent_types>
6
+ - gtd-alignment-auditor — Full alignment audit with coverage matrix
7
+ </available_agent_types>
8
+
9
+ <process>
10
+
11
+ <step name="initialize" priority="first">
12
+ Load context:
13
+
14
+ ```bash
15
+ INIT=$(node "$GTD_TOOLS_PATH/gtd-tools.cjs" init audit "$ARGUMENTS")
16
+ if [[ "$INIT" == @file:* ]]; then INIT=$(cat "${INIT#@file:}"); fi
17
+ ```
18
+
19
+ Parse JSON for: `project_root`, `docs_root`, `config`, `state`, `git`, `args`.
20
+
21
+ Parse `--compliance` flag: `soc2` | `iso27001` | none (default: none).
22
+ Parse `--force` flag to re-run even if recent audit exists.
23
+ </step>
24
+
25
+ <step name="check_existing_audit">
26
+ If `.planning/AUDIT-REPORT.md` exists AND is less than 24 hours old AND `--force` is not set:
27
+ Display:
28
+ ```
29
+ Recent audit report found (generated: {timestamp}).
30
+ Use --force to re-run.
31
+ ```
32
+ Present the existing report summary and EXIT.
33
+ </step>
34
+
35
+ <step name="spawn_alignment_auditor">
36
+ Spawn `gtd-alignment-auditor` agent with prompt:
37
+
38
+ ```
39
+ Run a full alignment audit on the project at: {project_root}
40
+
41
+ Compliance checks: {args.compliance or "none"}
42
+
43
+ Docs root: {docs_root}
44
+ Git context:
45
+ commit: {git.commit}
46
+ branch: {git.branch}
47
+
48
+ Follow the process defined in your agent definition.
49
+ Write the audit report to: {docs_root}/AUDIT-REPORT.md
50
+ ```
51
+
52
+ Wait for agent completion. Verify AUDIT-REPORT.md exists.
53
+ </step>
54
+
55
+ <step name="update_state">
56
+ Read the generated AUDIT-REPORT.md frontmatter to get coverage metrics.
57
+
58
+ ```bash
59
+ node "$GTD_TOOLS_PATH/gtd-tools.cjs" state update sync.last_audit "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
60
+ node "$GTD_TOOLS_PATH/gtd-tools.cjs" state update sync.spec_coverage "{spec_coverage}"
61
+ node "$GTD_TOOLS_PATH/gtd-tools.cjs" state update sync.doc_coverage "{doc_coverage}"
62
+ node "$GTD_TOOLS_PATH/gtd-tools.cjs" state update sync.test_coverage "{test_coverage}"
63
+ ```
64
+ </step>
65
+
66
+ <step name="display_report">
67
+ Present the coverage matrix and gap summary:
68
+
69
+ ```
70
+ Alignment Audit Complete
71
+
72
+ Coverage:
73
+ Spec coverage: {spec}% {status_emoji}
74
+ Doc coverage: {doc}% {status_emoji}
75
+ Test coverage: {test}% {status_emoji}
76
+ Full coverage: {full}% {status_emoji}
77
+ Orphan code: {orphan}%
78
+
79
+ Gaps found:
80
+ Undocumented code: {count}
81
+ Unimplemented specs: {count}
82
+ Untested features: {count}
83
+ Orphan documentation: {count}
84
+
85
+ Full report: {docs_root}/AUDIT-REPORT.md
86
+ ```
87
+
88
+ If compliance checks were run:
89
+ ```
90
+ Compliance ({type}):
91
+ Pass: {pass_count}
92
+ Fail: {fail_count}
93
+ Partial: {partial_count}
94
+ ```
95
+
96
+ Suggest next steps based on gaps:
97
+ - If spec coverage < 80%: "Run /gtd-reconcile --strategy spec-wins to plan implementation"
98
+ - If doc coverage < 80%: "Run /gtd-create-all to regenerate documentation"
99
+ - If test coverage < 60%: "Consider adding tests for untested features"
100
+ </step>
101
+
102
+ </process>
103
+
104
+ <error_handling>
105
+ - If alignment auditor agent fails: report error, suggest checking if codebase has been scanned
106
+ - If AUDIT-REPORT.md is not produced: report failure, check agent output for errors
107
+ - If no specs exist: run audit with code-and-docs only, note missing specs in report
108
+ - If no docs exist: run audit with code-and-specs only, note missing docs in report
109
+ - If compliance flag is unrecognized: warn and proceed without compliance checks
110
+ </error_handling>
@@ -0,0 +1,122 @@
1
+ <purpose>
2
+ Detect drift between specifications, documentation, and actual code. This is the entry point of the sync pipeline — it identifies where things have gone out of alignment so that reconciliation can bring them back.
3
+ </purpose>
4
+
5
+ <available_agent_types>
6
+ - gtd-drift-detector — Compares specs and docs against actual code to detect drift
7
+ </available_agent_types>
8
+
9
+ <process>
10
+
11
+ <step name="initialize" priority="first">
12
+ Load context:
13
+
14
+ ```bash
15
+ INIT=$(node "$GTD_TOOLS_PATH/gtd-tools.cjs" init detect-drift "$ARGUMENTS")
16
+ if [[ "$INIT" == @file:* ]]; then INIT=$(cat "${INIT#@file:}"); fi
17
+ ```
18
+
19
+ Parse JSON for: `project_root`, `docs_root`, `config`, `state`, `git`, `args`.
20
+
21
+ Check for `--since` flag (commit hash to compare from) and `--scope` flag (specs|docs|both, default: both).
22
+ </step>
23
+
24
+ <step name="check_if_needed">
25
+ Check if drift detection is needed:
26
+
27
+ ```bash
28
+ DRIFT_CHECK=$(node "$GTD_TOOLS_PATH/drift-engine.cjs" check "$ARGUMENTS")
29
+ if [[ "$DRIFT_CHECK" == @file:* ]]; then DRIFT_CHECK=$(cat "${DRIFT_CHECK#@file:}"); fi
30
+ ```
31
+
32
+ Parse result for `needs_check` boolean and `reason`.
33
+
34
+ If `needs_check` is false AND `--force` is not set:
35
+ Display:
36
+ ```
37
+ No drift detection needed: {reason}
38
+ Use --force to run anyway.
39
+ ```
40
+ EXIT — no work needed.
41
+ </step>
42
+
43
+ <step name="build_drift_context">
44
+ Build context for the drift detector:
45
+
46
+ ```bash
47
+ DRIFT_CTX=$(node "$GTD_TOOLS_PATH/drift-engine.cjs" context "$ARGUMENTS")
48
+ if [[ "$DRIFT_CTX" == @file:* ]]; then DRIFT_CTX=$(cat "${DRIFT_CTX#@file:}"); fi
49
+ ```
50
+
51
+ Parse result for: `specs_available`, `docs_available`, `last_sync_commit`, `files_changed_since`.
52
+
53
+ If no specs and no docs are available:
54
+ Display:
55
+ ```
56
+ No specifications or documents found to compare against code.
57
+ Run /gtd-scan and /gtd-create-* first, or create REQUIREMENTS.md.
58
+ ```
59
+ EXIT.
60
+ </step>
61
+
62
+ <step name="spawn_drift_detector">
63
+ Spawn `gtd-drift-detector` agent with prompt:
64
+
65
+ ```
66
+ Detect drift in the project at: {project_root}
67
+
68
+ Scope: {args.scope or "both"}
69
+ Since commit: {args.since or "all"}
70
+
71
+ Available specs: {specs_available}
72
+ Available docs: {docs_available}
73
+ Last sync commit: {last_sync_commit}
74
+ Files changed since last sync: {files_changed_since}
75
+
76
+ Docs root: {docs_root}
77
+
78
+ Follow the process defined in your agent definition.
79
+ Write the drift report to: {docs_root}/DRIFT-REPORT.md
80
+ ```
81
+
82
+ Wait for agent completion. Verify DRIFT-REPORT.md exists.
83
+ </step>
84
+
85
+ <step name="update_state">
86
+ Read the generated DRIFT-REPORT.md frontmatter to get counts.
87
+
88
+ If total_items > 0 (any drift found):
89
+ ```bash
90
+ node "$GTD_TOOLS_PATH/gtd-tools.cjs" state update sync.status drifted
91
+ node "$GTD_TOOLS_PATH/gtd-tools.cjs" state update sync.last_drift_check "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
92
+ node "$GTD_TOOLS_PATH/gtd-tools.cjs" state update sync.drift_items "{total_items}"
93
+ ```
94
+
95
+ If total_items == 0 (no drift):
96
+ ```bash
97
+ node "$GTD_TOOLS_PATH/gtd-tools.cjs" state update sync.status synced
98
+ node "$GTD_TOOLS_PATH/gtd-tools.cjs" state update sync.last_drift_check "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
99
+ node "$GTD_TOOLS_PATH/gtd-tools.cjs" state update sync.drift_items "0"
100
+ ```
101
+ </step>
102
+
103
+ <step name="report">
104
+ Display summary:
105
+
106
+ ```
107
+ Found {total_items} drift items: {critical} critical, {major} major, {minor} minor, {info} info
108
+
109
+ Status: {DRIFTED or SYNCED}
110
+
111
+ Run /gtd-reconcile to plan fixes, or /gtd-audit for full coverage analysis.
112
+ ```
113
+ </step>
114
+
115
+ </process>
116
+
117
+ <error_handling>
118
+ - If drift detector agent fails: report error, suggest checking if specs/docs exist
119
+ - If DRIFT-REPORT.md is not produced: report failure, check agent output for errors
120
+ - If specs are missing but docs exist: run with docs-only scope
121
+ - If docs are missing but specs exist: run with specs-only scope
122
+ </error_handling>
@@ -0,0 +1,113 @@
1
+ <purpose>
2
+ Plan how to reconcile drift between specifications, documentation, and code. Takes the drift report as input and produces an actionable reconciliation plan with per-item actions and effort estimates.
3
+ </purpose>
4
+
5
+ <available_agent_types>
6
+ - gtd-reconciliation-planner — Plans how to reconcile drift between specs and code
7
+ </available_agent_types>
8
+
9
+ <process>
10
+
11
+ <step name="initialize" priority="first">
12
+ Load context:
13
+
14
+ ```bash
15
+ INIT=$(node "$GTD_TOOLS_PATH/gtd-tools.cjs" init reconcile "$ARGUMENTS")
16
+ if [[ "$INIT" == @file:* ]]; then INIT=$(cat "${INIT#@file:}"); fi
17
+ ```
18
+
19
+ Parse JSON for: `project_root`, `docs_root`, `config`, `state`, `args`.
20
+
21
+ Parse `--strategy` flag: `code-wins` | `spec-wins` | `interactive` (default: `interactive`).
22
+ </step>
23
+
24
+ <step name="check_drift_report">
25
+ Check if a drift report exists:
26
+
27
+ ```bash
28
+ test -f "$DOCS_ROOT/DRIFT-REPORT.md" && echo "EXISTS" || echo "MISSING"
29
+ ```
30
+
31
+ If MISSING:
32
+ Display:
33
+ ```
34
+ No drift report found. Run /gtd-drift first to detect drift.
35
+ ```
36
+ EXIT — cannot reconcile without drift data.
37
+
38
+ If EXISTS, read the frontmatter to confirm there are drift items:
39
+ - If `total_items` is 0:
40
+ Display:
41
+ ```
42
+ Drift report shows 0 items — everything is in sync.
43
+ No reconciliation needed.
44
+ ```
45
+ EXIT.
46
+ </step>
47
+
48
+ <step name="spawn_reconciliation_planner">
49
+ Spawn `gtd-reconciliation-planner` agent with prompt:
50
+
51
+ ```
52
+ Plan reconciliation for the project at: {project_root}
53
+
54
+ Strategy: {args.strategy or "interactive"}
55
+
56
+ Drift report: {docs_root}/DRIFT-REPORT.md
57
+ Specs root: {project_root}
58
+ Docs root: {docs_root}
59
+
60
+ Follow the process defined in your agent definition.
61
+ Write the reconciliation plan to: {docs_root}/RECONCILIATION-PLAN.md
62
+ ```
63
+
64
+ Wait for agent completion. Verify RECONCILIATION-PLAN.md exists.
65
+ </step>
66
+
67
+ <step name="present_plan">
68
+ Read the generated RECONCILIATION-PLAN.md and present a summary to the user:
69
+
70
+ ```
71
+ Reconciliation Plan ({strategy} strategy)
72
+
73
+ Total actions: {total_actions}
74
+ Needs user decision: {needs_decision}
75
+ Auto-resolvable: {auto}
76
+
77
+ Effort breakdown:
78
+ Trivial: {trivial}
79
+ Small: {small}
80
+ Medium: {medium}
81
+ Large: {large}
82
+
83
+ Estimated total effort: {hours} hours
84
+ ```
85
+
86
+ If strategy is `interactive`, list the items that need a decision:
87
+ ```
88
+ Items requiring your decision:
89
+ 1. [CRITICAL] {description} — recommend: {direction}
90
+ 2. [MAJOR] {description} — recommend: {direction}
91
+ ...
92
+
93
+ Review the full plan at: {docs_root}/RECONCILIATION-PLAN.md
94
+ Run /gtd-sync to execute the plan.
95
+ ```
96
+ </step>
97
+
98
+ <step name="update_state">
99
+ ```bash
100
+ node "$GTD_TOOLS_PATH/gtd-tools.cjs" state update sync.status reconciling
101
+ node "$GTD_TOOLS_PATH/gtd-tools.cjs" state update sync.reconciliation_strategy "{strategy}"
102
+ node "$GTD_TOOLS_PATH/gtd-tools.cjs" state update sync.last_reconciliation "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
103
+ ```
104
+ </step>
105
+
106
+ </process>
107
+
108
+ <error_handling>
109
+ - If reconciliation planner agent fails: report error, suggest checking drift report format
110
+ - If RECONCILIATION-PLAN.md is not produced: report failure, check agent output
111
+ - If drift report is malformed: report error, suggest re-running /gtd-drift
112
+ - If strategy flag is invalid: default to interactive with a warning
113
+ </error_handling>
@@ -0,0 +1,150 @@
1
+ <purpose>
2
+ The auto-sync workflow: detect drift, reconcile, and apply changes to bring specs, docs, and code back into alignment. This is the all-in-one command for keeping a project synchronized.
3
+ </purpose>
4
+
5
+ <available_agent_types>
6
+ - gtd-drift-detector — Compares specs and docs against actual code to detect drift
7
+ - gtd-reconciliation-planner — Plans how to reconcile drift between specs and code
8
+ </available_agent_types>
9
+
10
+ <process>
11
+
12
+ <step name="initialize" priority="first">
13
+ Load context:
14
+
15
+ ```bash
16
+ INIT=$(node "$GTD_TOOLS_PATH/gtd-tools.cjs" init sync "$ARGUMENTS")
17
+ if [[ "$INIT" == @file:* ]]; then INIT=$(cat "${INIT#@file:}"); fi
18
+ ```
19
+
20
+ Parse JSON for: `project_root`, `docs_root`, `config`, `state`, `git`, `args`.
21
+
22
+ Parse flags:
23
+ - `--auto` — Fully automatic mode: use code-wins strategy, auto-approve all actions
24
+ - `--direction` — `forward` (specs to code) | `backward` (code to specs) | `both` (default: both)
25
+ - `--force` — Force re-detection even if recent drift report exists
26
+ </step>
27
+
28
+ <step name="detect_drift">
29
+ Run drift detection (equivalent to /gtd-drift):
30
+
31
+ Check if a recent DRIFT-REPORT.md exists AND `--force` is not set:
32
+ - If exists and less than 1 hour old: reuse it
33
+ - Otherwise: run drift detection
34
+
35
+ ```bash
36
+ DRIFT_CTX=$(node "$GTD_TOOLS_PATH/drift-engine.cjs" context "$ARGUMENTS")
37
+ if [[ "$DRIFT_CTX" == @file:* ]]; then DRIFT_CTX=$(cat "${DRIFT_CTX#@file:}"); fi
38
+ ```
39
+
40
+ Spawn `gtd-drift-detector` agent with the project context.
41
+ Wait for DRIFT-REPORT.md.
42
+
43
+ If no drift found:
44
+ Display:
45
+ ```
46
+ Everything is in sync. No changes needed.
47
+ ```
48
+ Update state to "synced" and EXIT.
49
+ </step>
50
+
51
+ <step name="determine_strategy">
52
+ Determine reconciliation strategy based on flags:
53
+
54
+ - If `--auto` is set: strategy = `code-wins`
55
+ - If `--direction forward`: strategy = `spec-wins` (specs drive code changes)
56
+ - If `--direction backward`: strategy = `code-wins` (code drives spec/doc updates)
57
+ - If `--direction both`: strategy = `interactive` (unless `--auto`, then `code-wins`)
58
+ - Default (no flags): strategy = `interactive`
59
+ </step>
60
+
61
+ <step name="reconcile">
62
+ Spawn `gtd-reconciliation-planner` agent with the determined strategy.
63
+
64
+ Wait for RECONCILIATION-PLAN.md.
65
+
66
+ If strategy is `interactive` (and `--auto` is NOT set):
67
+ Present the plan to the user and wait for approval:
68
+ ```
69
+ Reconciliation plan ready with {total_actions} actions.
70
+ Review: {docs_root}/RECONCILIATION-PLAN.md
71
+
72
+ Approve and apply? (yes/no)
73
+ ```
74
+ If user declines: EXIT with state "reconciling".
75
+ </step>
76
+
77
+ <step name="apply_changes">
78
+ Apply the reconciliation plan:
79
+
80
+ ### For code-wins actions (update specs/docs):
81
+ - Read each affected document
82
+ - Apply the planned changes (update sections, fix paths, correct versions)
83
+ - Write updated documents back
84
+
85
+ ### For spec-wins actions (update code):
86
+ - Create task items in `.planning/SYNC-TASKS.md` for code changes
87
+ - Each task includes: description, affected files, acceptance criteria
88
+ - Display tasks for developer action
89
+
90
+ ### For document regeneration:
91
+ - If a document is too stale (> 50% claims incorrect), trigger full regeneration
92
+ - Use the backward pipeline: /gtd-create-{type} --force
93
+
94
+ ```bash
95
+ node "$GTD_TOOLS_PATH/gtd-tools.cjs" state update sync.status applying
96
+ ```
97
+ </step>
98
+
99
+ <step name="verify_sync">
100
+ After applying changes, run a quick verification:
101
+
102
+ - Re-check critical drift items to confirm they're resolved
103
+ - Count remaining drift items
104
+
105
+ If all resolved:
106
+ ```bash
107
+ node "$GTD_TOOLS_PATH/gtd-tools.cjs" state update sync.status synced
108
+ node "$GTD_TOOLS_PATH/gtd-tools.cjs" state update sync.last_sync "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
109
+ node "$GTD_TOOLS_PATH/gtd-tools.cjs" state update sync.last_sync_commit "$(git rev-parse --short HEAD)"
110
+ ```
111
+
112
+ If some remain:
113
+ ```bash
114
+ node "$GTD_TOOLS_PATH/gtd-tools.cjs" state update sync.status partially_synced
115
+ ```
116
+ </step>
117
+
118
+ <step name="report">
119
+ Display final summary:
120
+
121
+ ```
122
+ Sync complete.
123
+
124
+ Actions applied: {applied} / {total}
125
+ Docs updated: {docs_updated}
126
+ Tasks created: {tasks_created}
127
+ Remaining drift: {remaining}
128
+
129
+ Status: {SYNCED / PARTIALLY_SYNCED}
130
+ ```
131
+
132
+ If tasks were created for code changes:
133
+ ```
134
+ Code tasks pending developer action:
135
+ 1. {task description} — {affected files}
136
+ 2. ...
137
+
138
+ See: {docs_root}/SYNC-TASKS.md
139
+ ```
140
+ </step>
141
+
142
+ </process>
143
+
144
+ <error_handling>
145
+ - If drift detection fails: report error, suggest running /gtd-drift independently
146
+ - If reconciliation fails: report error, suggest running /gtd-reconcile independently
147
+ - If a document update fails: skip that item, continue with others, report at end
148
+ - If --auto mode encounters a CRITICAL spec-wins item: pause and warn user (safety override)
149
+ - If git is dirty (uncommitted changes): warn user before applying changes
150
+ </error_handling>