agent-threader 2.0.5

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 (172) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +126 -0
  3. package/compiled/claude/agent-threader/SKILL.md +361 -0
  4. package/compiled/codex/agent-threader/SKILL.md +361 -0
  5. package/compiled/cursor/rules/agent-threader.mdc +367 -0
  6. package/compiled/cursor/skills/agent-threader/SKILL.md +361 -0
  7. package/compiled/opencode/agent-threader.md +361 -0
  8. package/compiled/windsurf/rules/agent-threader.md +361 -0
  9. package/compiled/windsurf/skills/agent-threader/SKILL.md +361 -0
  10. package/dist/cli/commands/doctor.d.ts +6 -0
  11. package/dist/cli/commands/doctor.d.ts.map +1 -0
  12. package/dist/cli/commands/doctor.js +7 -0
  13. package/dist/cli/commands/doctor.js.map +1 -0
  14. package/dist/cli/commands/explain-error.d.ts +12 -0
  15. package/dist/cli/commands/explain-error.d.ts.map +1 -0
  16. package/dist/cli/commands/explain-error.js +23 -0
  17. package/dist/cli/commands/explain-error.js.map +1 -0
  18. package/dist/cli/commands/init-state.d.ts +6 -0
  19. package/dist/cli/commands/init-state.d.ts.map +1 -0
  20. package/dist/cli/commands/init-state.js +10 -0
  21. package/dist/cli/commands/init-state.js.map +1 -0
  22. package/dist/cli/commands/logs.d.ts +6 -0
  23. package/dist/cli/commands/logs.d.ts.map +1 -0
  24. package/dist/cli/commands/logs.js +9 -0
  25. package/dist/cli/commands/logs.js.map +1 -0
  26. package/dist/cli/commands/parse-heal.d.ts +6 -0
  27. package/dist/cli/commands/parse-heal.d.ts.map +1 -0
  28. package/dist/cli/commands/parse-heal.js +5 -0
  29. package/dist/cli/commands/parse-heal.js.map +1 -0
  30. package/dist/cli/commands/parse-result.d.ts +6 -0
  31. package/dist/cli/commands/parse-result.d.ts.map +1 -0
  32. package/dist/cli/commands/parse-result.js +5 -0
  33. package/dist/cli/commands/parse-result.js.map +1 -0
  34. package/dist/cli/commands/status.d.ts +6 -0
  35. package/dist/cli/commands/status.d.ts.map +1 -0
  36. package/dist/cli/commands/status.js +5 -0
  37. package/dist/cli/commands/status.js.map +1 -0
  38. package/dist/cli/commands/validate-manifest.d.ts +6 -0
  39. package/dist/cli/commands/validate-manifest.d.ts.map +1 -0
  40. package/dist/cli/commands/validate-manifest.js +5 -0
  41. package/dist/cli/commands/validate-manifest.js.map +1 -0
  42. package/dist/cli/index.d.ts +6 -0
  43. package/dist/cli/index.d.ts.map +1 -0
  44. package/dist/cli/index.js +360 -0
  45. package/dist/cli/index.js.map +1 -0
  46. package/dist/cli/output-formatter.d.ts +6 -0
  47. package/dist/cli/output-formatter.d.ts.map +1 -0
  48. package/dist/cli/output-formatter.js +19 -0
  49. package/dist/cli/output-formatter.js.map +1 -0
  50. package/dist/index.d.ts +3 -0
  51. package/dist/index.d.ts.map +1 -0
  52. package/dist/index.js +5 -0
  53. package/dist/index.js.map +1 -0
  54. package/dist/lib/adapters/types.d.ts +40 -0
  55. package/dist/lib/adapters/types.d.ts.map +1 -0
  56. package/dist/lib/adapters/types.js +3 -0
  57. package/dist/lib/adapters/types.js.map +1 -0
  58. package/dist/lib/contracts/schema-validator.d.ts +15 -0
  59. package/dist/lib/contracts/schema-validator.d.ts.map +1 -0
  60. package/dist/lib/contracts/schema-validator.js +63 -0
  61. package/dist/lib/contracts/schema-validator.js.map +1 -0
  62. package/dist/lib/contracts/types.d.ts +91 -0
  63. package/dist/lib/contracts/types.d.ts.map +1 -0
  64. package/dist/lib/contracts/types.js +15 -0
  65. package/dist/lib/contracts/types.js.map +1 -0
  66. package/dist/lib/contracts/validate-manifest.d.ts +16 -0
  67. package/dist/lib/contracts/validate-manifest.d.ts.map +1 -0
  68. package/dist/lib/contracts/validate-manifest.js +123 -0
  69. package/dist/lib/contracts/validate-manifest.js.map +1 -0
  70. package/dist/lib/diagnostics/doctor.d.ts +17 -0
  71. package/dist/lib/diagnostics/doctor.d.ts.map +1 -0
  72. package/dist/lib/diagnostics/doctor.js +131 -0
  73. package/dist/lib/diagnostics/doctor.js.map +1 -0
  74. package/dist/lib/errors/explain-error.d.ts +10 -0
  75. package/dist/lib/errors/explain-error.d.ts.map +1 -0
  76. package/dist/lib/errors/explain-error.js +73 -0
  77. package/dist/lib/errors/explain-error.js.map +1 -0
  78. package/dist/lib/errors/types.d.ts +16 -0
  79. package/dist/lib/errors/types.d.ts.map +1 -0
  80. package/dist/lib/errors/types.js +50 -0
  81. package/dist/lib/errors/types.js.map +1 -0
  82. package/dist/lib/index.d.ts +29 -0
  83. package/dist/lib/index.d.ts.map +1 -0
  84. package/dist/lib/index.js +25 -0
  85. package/dist/lib/index.js.map +1 -0
  86. package/dist/lib/orchestrator/batch-strategy.d.ts +9 -0
  87. package/dist/lib/orchestrator/batch-strategy.d.ts.map +1 -0
  88. package/dist/lib/orchestrator/batch-strategy.js +34 -0
  89. package/dist/lib/orchestrator/batch-strategy.js.map +1 -0
  90. package/dist/lib/orchestrator/healing-policy.d.ts +47 -0
  91. package/dist/lib/orchestrator/healing-policy.d.ts.map +1 -0
  92. package/dist/lib/orchestrator/healing-policy.js +104 -0
  93. package/dist/lib/orchestrator/healing-policy.js.map +1 -0
  94. package/dist/lib/orchestrator/index.d.ts +11 -0
  95. package/dist/lib/orchestrator/index.d.ts.map +1 -0
  96. package/dist/lib/orchestrator/index.js +11 -0
  97. package/dist/lib/orchestrator/index.js.map +1 -0
  98. package/dist/lib/orchestrator/patch-validation.d.ts +9 -0
  99. package/dist/lib/orchestrator/patch-validation.d.ts.map +1 -0
  100. package/dist/lib/orchestrator/patch-validation.js +58 -0
  101. package/dist/lib/orchestrator/patch-validation.js.map +1 -0
  102. package/dist/lib/orchestrator/scheduling.d.ts +12 -0
  103. package/dist/lib/orchestrator/scheduling.d.ts.map +1 -0
  104. package/dist/lib/orchestrator/scheduling.js +74 -0
  105. package/dist/lib/orchestrator/scheduling.js.map +1 -0
  106. package/dist/lib/orchestrator/write-safety.d.ts +14 -0
  107. package/dist/lib/orchestrator/write-safety.d.ts.map +1 -0
  108. package/dist/lib/orchestrator/write-safety.js +44 -0
  109. package/dist/lib/orchestrator/write-safety.js.map +1 -0
  110. package/dist/lib/parser/parse-heal.d.ts +12 -0
  111. package/dist/lib/parser/parse-heal.d.ts.map +1 -0
  112. package/dist/lib/parser/parse-heal.js +9 -0
  113. package/dist/lib/parser/parse-heal.js.map +1 -0
  114. package/dist/lib/parser/parse-result.d.ts +12 -0
  115. package/dist/lib/parser/parse-result.d.ts.map +1 -0
  116. package/dist/lib/parser/parse-result.js +9 -0
  117. package/dist/lib/parser/parse-result.js.map +1 -0
  118. package/dist/lib/parser/parser.d.ts +8 -0
  119. package/dist/lib/parser/parser.d.ts.map +1 -0
  120. package/dist/lib/parser/parser.js +167 -0
  121. package/dist/lib/parser/parser.js.map +1 -0
  122. package/dist/lib/state/init-state.d.ts +15 -0
  123. package/dist/lib/state/init-state.d.ts.map +1 -0
  124. package/dist/lib/state/init-state.js +50 -0
  125. package/dist/lib/state/init-state.js.map +1 -0
  126. package/dist/lib/state/logs.d.ts +19 -0
  127. package/dist/lib/state/logs.d.ts.map +1 -0
  128. package/dist/lib/state/logs.js +25 -0
  129. package/dist/lib/state/logs.js.map +1 -0
  130. package/dist/lib/state/state.d.ts +7 -0
  131. package/dist/lib/state/state.d.ts.map +1 -0
  132. package/dist/lib/state/state.js +72 -0
  133. package/dist/lib/state/state.js.map +1 -0
  134. package/dist/lib/state/status.d.ts +22 -0
  135. package/dist/lib/state/status.d.ts.map +1 -0
  136. package/dist/lib/state/status.js +34 -0
  137. package/dist/lib/state/status.js.map +1 -0
  138. package/dist/lib/state/types.d.ts +55 -0
  139. package/dist/lib/state/types.d.ts.map +1 -0
  140. package/dist/lib/state/types.js +14 -0
  141. package/dist/lib/state/types.js.map +1 -0
  142. package/install-local.sh +239 -0
  143. package/install.sh +36 -0
  144. package/package.json +55 -0
  145. package/site/CNAME +1 -0
  146. package/site/index.html +141 -0
  147. package/site/install.sh +36 -0
  148. package/site/style.css +319 -0
  149. package/skill/SKILL.md +127 -0
  150. package/skill/SPEC.md +1189 -0
  151. package/skill/build/compile.mjs +237 -0
  152. package/skill/build/manifest.json +21 -0
  153. package/skill/fragments/common/model-selection.md +11 -0
  154. package/skill/fragments/common/portability-rules.md +16 -0
  155. package/skill/fragments/common/workflow.md +12 -0
  156. package/skill/fragments/domain/adapter-model.md +42 -0
  157. package/skill/fragments/domain/architecture-overview.md +36 -0
  158. package/skill/fragments/domain/contracts.md +31 -0
  159. package/skill/fragments/domain/pbh-healing.md +47 -0
  160. package/skill/fragments/domain/state-resume.md +34 -0
  161. package/skill/fragments/domain/verification-safety.md +33 -0
  162. package/skill/fragments/meta/schemas-reference.md +13 -0
  163. package/skill/fragments/meta/templates-reference.md +11 -0
  164. package/skill/schemas/heal_decision.v2.json +100 -0
  165. package/skill/schemas/manifest.v2.json +91 -0
  166. package/skill/schemas/state.v2.json +183 -0
  167. package/skill/schemas/task_result.v2.json +104 -0
  168. package/skill/schemas/verify_profile.v2.json +61 -0
  169. package/skill/skills/agent-threader/agent-threader.md +85 -0
  170. package/skill/templates/orchestrator.ts +38 -0
  171. package/skill/templates/parser.ts +384 -0
  172. package/skill/templates/types.ts +282 -0
@@ -0,0 +1,91 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "manifest.v2.json",
4
+ "title": "AgentThreader Manifest v2",
5
+ "description": "Declares the set of tasks, their dependencies, timeouts, and verification profiles for a runner invocation.",
6
+ "type": "object",
7
+ "required": ["manifest_version", "run_id", "tasks"],
8
+ "properties": {
9
+ "manifest_version": {
10
+ "type": "string",
11
+ "const": "2.0",
12
+ "description": "Contract version. MUST be \"2.0\"."
13
+ },
14
+ "run_id": {
15
+ "type": "string",
16
+ "minLength": 1,
17
+ "description": "Logical run identifier."
18
+ },
19
+ "tasks": {
20
+ "type": "array",
21
+ "minItems": 1,
22
+ "items": { "$ref": "#/$defs/task" },
23
+ "description": "Ordered list of task definitions."
24
+ }
25
+ },
26
+ "additionalProperties": false,
27
+ "$defs": {
28
+ "task": {
29
+ "type": "object",
30
+ "required": ["id", "prompt_ref", "depends_on", "timeout_sec", "verify_profile"],
31
+ "properties": {
32
+ "id": {
33
+ "type": "string",
34
+ "minLength": 1,
35
+ "description": "Stable, unique task identifier."
36
+ },
37
+ "prompt_ref": {
38
+ "type": "string",
39
+ "minLength": 1,
40
+ "description": "Relative path or logical reference to the task prompt."
41
+ },
42
+ "depends_on": {
43
+ "type": "array",
44
+ "items": { "type": "string" },
45
+ "description": "Upstream task IDs that must be DONE before execution."
46
+ },
47
+ "timeout_sec": {
48
+ "type": "number",
49
+ "minimum": 1,
50
+ "description": "Task timeout in seconds."
51
+ },
52
+ "verify_profile": {
53
+ "type": "string",
54
+ "minLength": 1,
55
+ "description": "Name of the project-defined verification profile."
56
+ },
57
+ "context_refs": {
58
+ "type": "array",
59
+ "items": { "type": "string" },
60
+ "description": "Shared context references applied to the task."
61
+ },
62
+ "priority": {
63
+ "type": "number",
64
+ "description": "Lower number means earlier scheduling within the same dependency depth."
65
+ },
66
+ "retry_policy": { "$ref": "#/$defs/retry_policy" },
67
+ "metadata": {
68
+ "type": "object",
69
+ "description": "Arbitrary task metadata for reporting or filtering."
70
+ }
71
+ },
72
+ "additionalProperties": false
73
+ },
74
+ "retry_policy": {
75
+ "type": "object",
76
+ "properties": {
77
+ "max_attempts": {
78
+ "type": "number",
79
+ "minimum": 1,
80
+ "description": "Maximum worker attempts for this task. Defaults to global policy if omitted."
81
+ },
82
+ "retry_on": {
83
+ "type": "array",
84
+ "items": { "type": "string" },
85
+ "description": "Failure classes eligible for retry."
86
+ }
87
+ },
88
+ "additionalProperties": false
89
+ }
90
+ }
91
+ }
@@ -0,0 +1,183 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "state.v2.json",
4
+ "title": "Run State v2",
5
+ "description": "Persistent orchestrator state for resume, convergence tracking, and reporting.",
6
+ "type": "object",
7
+ "required": ["state_version", "run_id", "run_status", "abort_reason", "manifest_digest", "policy", "tasks", "healing_rounds"],
8
+ "properties": {
9
+ "state_version": {
10
+ "type": "string",
11
+ "const": "2.0"
12
+ },
13
+ "run_id": {
14
+ "type": "string",
15
+ "minLength": 1
16
+ },
17
+ "run_status": {
18
+ "type": "string",
19
+ "enum": ["RUNNING", "COMPLETED", "ABORTED"]
20
+ },
21
+ "abort_reason": {
22
+ "type": ["string", "null"],
23
+ "description": "Human-readable abort reason when run_status is ABORTED."
24
+ },
25
+ "manifest_digest": {
26
+ "type": "string",
27
+ "minLength": 1,
28
+ "description": "Hash of the normalized manifest used for resume validation."
29
+ },
30
+ "policy": { "$ref": "#/$defs/policy" },
31
+ "tasks": {
32
+ "type": "object",
33
+ "additionalProperties": { "$ref": "#/$defs/task_state" },
34
+ "description": "Per-task state keyed by task ID."
35
+ },
36
+ "healing_rounds": {
37
+ "type": "array",
38
+ "items": { "$ref": "#/$defs/healing_round" }
39
+ }
40
+ },
41
+ "additionalProperties": false,
42
+ "$defs": {
43
+ "policy": {
44
+ "type": "object",
45
+ "required": [
46
+ "heal_schedule",
47
+ "batch_strategy",
48
+ "current_batch_size",
49
+ "failure_threshold",
50
+ "max_worker_attempts_per_task",
51
+ "max_heal_rounds_per_window",
52
+ "max_total_heal_rounds",
53
+ "signature_repeat_limit"
54
+ ],
55
+ "properties": {
56
+ "heal_schedule": {
57
+ "type": "string",
58
+ "enum": ["auto", "off", "task", "batch", "epoch"]
59
+ },
60
+ "batch_strategy": {
61
+ "type": "string",
62
+ "enum": ["fibonacci", "fixed"]
63
+ },
64
+ "current_batch_size": {
65
+ "type": "number",
66
+ "minimum": 1
67
+ },
68
+ "failure_threshold": {
69
+ "type": "number",
70
+ "minimum": 0,
71
+ "maximum": 1
72
+ },
73
+ "max_worker_attempts_per_task": {
74
+ "type": "number",
75
+ "minimum": 1
76
+ },
77
+ "max_heal_rounds_per_window": {
78
+ "type": "number",
79
+ "minimum": 0
80
+ },
81
+ "max_total_heal_rounds": {
82
+ "type": "number",
83
+ "minimum": 0
84
+ },
85
+ "signature_repeat_limit": {
86
+ "type": "number",
87
+ "minimum": 1
88
+ }
89
+ },
90
+ "additionalProperties": false
91
+ },
92
+ "task_state": {
93
+ "type": "object",
94
+ "required": [
95
+ "status",
96
+ "worker_attempts",
97
+ "healer_attempts",
98
+ "last_failure_class",
99
+ "last_failure_signature",
100
+ "applied_patch_ids",
101
+ "history"
102
+ ],
103
+ "properties": {
104
+ "status": {
105
+ "type": "string",
106
+ "enum": ["PENDING", "RUNNING", "DONE", "BLOCKED", "FAILED", "ESCALATED"]
107
+ },
108
+ "worker_attempts": { "type": "number", "minimum": 0 },
109
+ "healer_attempts": { "type": "number", "minimum": 0 },
110
+ "last_failure_class": { "type": ["string", "null"] },
111
+ "last_failure_signature": { "type": ["string", "null"] },
112
+ "applied_patch_ids": {
113
+ "type": "array",
114
+ "items": { "type": "string" }
115
+ },
116
+ "history": {
117
+ "type": "array",
118
+ "items": { "$ref": "#/$defs/history_entry" }
119
+ }
120
+ },
121
+ "additionalProperties": false
122
+ },
123
+ "history_entry": {
124
+ "type": "object",
125
+ "required": ["task_id", "phase", "attempt_number", "log_path", "timestamp"],
126
+ "properties": {
127
+ "task_id": { "type": "string" },
128
+ "phase": {
129
+ "type": "string",
130
+ "enum": ["worker", "verify", "healer", "rollback"]
131
+ },
132
+ "attempt_number": { "type": "number", "minimum": 1 },
133
+ "log_path": { "type": "string" },
134
+ "verify_log_path": { "type": ["string", "null"] },
135
+ "exit_code": { "type": ["number", "null"] },
136
+ "failure_class": { "type": ["string", "null"] },
137
+ "failure_signature": { "type": ["string", "null"] },
138
+ "applied_patch_ids": {
139
+ "type": "array",
140
+ "items": { "type": "string" }
141
+ },
142
+ "duration_sec": { "type": ["number", "null"] },
143
+ "timestamp": {
144
+ "type": "string",
145
+ "format": "date-time"
146
+ }
147
+ },
148
+ "additionalProperties": false
149
+ },
150
+ "healing_round": {
151
+ "type": "object",
152
+ "required": ["round_number", "scope", "window_task_ids", "failed_task_ids", "decision", "applied_patch_ids", "timestamp"],
153
+ "properties": {
154
+ "round_number": { "type": "number", "minimum": 1 },
155
+ "scope": {
156
+ "type": "string",
157
+ "enum": ["task", "batch", "epoch"]
158
+ },
159
+ "window_task_ids": {
160
+ "type": "array",
161
+ "items": { "type": "string" }
162
+ },
163
+ "failed_task_ids": {
164
+ "type": "array",
165
+ "items": { "type": "string" }
166
+ },
167
+ "decision": {
168
+ "type": "string",
169
+ "enum": ["RETRY", "ESCALATE", "NOT_FIXABLE"]
170
+ },
171
+ "applied_patch_ids": {
172
+ "type": "array",
173
+ "items": { "type": "string" }
174
+ },
175
+ "timestamp": {
176
+ "type": "string",
177
+ "format": "date-time"
178
+ }
179
+ },
180
+ "additionalProperties": false
181
+ }
182
+ }
183
+ }
@@ -0,0 +1,104 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "task_result.v2.json",
4
+ "title": "Task Result v2",
5
+ "description": "Worker output contract. Emitted inside <<<TASK_RESULT_V2>>> fences.",
6
+ "type": "object",
7
+ "required": ["contract_version", "task_id", "status", "summary"],
8
+ "properties": {
9
+ "contract_version": {
10
+ "type": "string",
11
+ "const": "2.0"
12
+ },
13
+ "task_id": {
14
+ "type": "string",
15
+ "minLength": 1,
16
+ "description": "Task ID matching the current manifest task."
17
+ },
18
+ "status": {
19
+ "type": "string",
20
+ "enum": ["DONE", "BLOCKED", "FAILED", "CONTRACT_ERROR"],
21
+ "description": "Worker-declared outcome."
22
+ },
23
+ "summary": {
24
+ "type": "string",
25
+ "minLength": 1,
26
+ "description": "Short human-readable summary of what happened."
27
+ },
28
+ "changed_files": {
29
+ "type": "array",
30
+ "items": { "type": "string" },
31
+ "description": "Relative file paths changed by the proposed work."
32
+ },
33
+ "writes": {
34
+ "type": "array",
35
+ "items": { "$ref": "#/$defs/write_entry" },
36
+ "description": "Proposed file write operations applied by the orchestrator."
37
+ },
38
+ "evidence": { "$ref": "#/$defs/evidence" },
39
+ "failure_class": {
40
+ "type": "string",
41
+ "description": "Optional worker-supplied hint. The orchestrator still owns final classification."
42
+ }
43
+ },
44
+ "additionalProperties": false,
45
+ "$defs": {
46
+ "write_entry": {
47
+ "type": "object",
48
+ "required": ["path", "op", "encoding"],
49
+ "properties": {
50
+ "path": {
51
+ "type": "string",
52
+ "minLength": 1,
53
+ "description": "Relative normalized path. MUST NOT escape the workspace root."
54
+ },
55
+ "op": {
56
+ "type": "string",
57
+ "enum": ["create", "replace", "append"]
58
+ },
59
+ "encoding": {
60
+ "type": "string",
61
+ "const": "utf8"
62
+ },
63
+ "content": {
64
+ "type": "string",
65
+ "description": "Inline file content to be applied by the orchestrator."
66
+ },
67
+ "content_ref": {
68
+ "type": "string",
69
+ "description": "Path to staged content written by the worker tooling instead of inline content."
70
+ },
71
+ "sha256_before": {
72
+ "type": "string",
73
+ "description": "Optional precondition hash for conflict detection."
74
+ }
75
+ },
76
+ "additionalProperties": false,
77
+ "anyOf": [
78
+ { "required": ["content"] },
79
+ { "required": ["content_ref"] }
80
+ ]
81
+ },
82
+ "evidence": {
83
+ "type": "object",
84
+ "properties": {
85
+ "commands": {
86
+ "type": "array",
87
+ "items": { "type": "string" },
88
+ "description": "Commands the worker claims to have run."
89
+ },
90
+ "log_refs": {
91
+ "type": "array",
92
+ "items": { "type": "string" },
93
+ "description": "Relative log references produced by the worker."
94
+ },
95
+ "notes": {
96
+ "type": "array",
97
+ "items": { "type": "string" },
98
+ "description": "Additional structured evidence notes."
99
+ }
100
+ },
101
+ "additionalProperties": false
102
+ }
103
+ }
104
+ }
@@ -0,0 +1,61 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "verify_profile.v2.json",
4
+ "title": "AgentThreader v2 Verification Profile Registry",
5
+ "description": "Operator-defined verification profiles resolved by the orchestrator.",
6
+ "type": "object",
7
+ "required": ["profiles"],
8
+ "additionalProperties": false,
9
+ "properties": {
10
+ "profiles": {
11
+ "type": "object",
12
+ "additionalProperties": { "$ref": "#/$defs/profile" },
13
+ "description": "Profile definitions keyed by profile name."
14
+ }
15
+ },
16
+ "$defs": {
17
+ "profile": {
18
+ "type": "object",
19
+ "required": ["steps"],
20
+ "additionalProperties": false,
21
+ "properties": {
22
+ "steps": {
23
+ "type": "array",
24
+ "items": { "$ref": "#/$defs/step" },
25
+ "minItems": 1
26
+ },
27
+ "rollback_on_failure": {
28
+ "type": "boolean",
29
+ "default": true,
30
+ "description": "Whether to rollback applied writes when any verification step fails."
31
+ }
32
+ }
33
+ },
34
+ "step": {
35
+ "type": "object",
36
+ "required": ["name", "cmd"],
37
+ "additionalProperties": false,
38
+ "properties": {
39
+ "name": {
40
+ "type": "string",
41
+ "minLength": 1,
42
+ "description": "Human-readable step name for logging."
43
+ },
44
+ "cmd": {
45
+ "type": "string",
46
+ "minLength": 1,
47
+ "description": "Shell command to execute."
48
+ },
49
+ "cwd": {
50
+ "type": "string",
51
+ "description": "Working directory for the command. Defaults to workspace root."
52
+ },
53
+ "timeout_sec": {
54
+ "type": "number",
55
+ "minimum": 1,
56
+ "description": "Step timeout in seconds."
57
+ }
58
+ }
59
+ }
60
+ }
61
+ }
@@ -0,0 +1,85 @@
1
+ ---
2
+ name: agent-threader
3
+ version: "2.0"
4
+ description: "AgentThreader -- build or review manifest-driven agentic CLI orchestration with structured JSON contracts, schema-validated parsing, resumable state, dependency-aware scheduling, bounded self-healing, and orchestrator-owned verification."
5
+ ---
6
+
7
+ # AgentThreader
8
+
9
+ ## When To Use This Skill
10
+
11
+ Use this skill when manual chat execution no longer scales and the right answer is a repeatable runner around an agentic CLI.
12
+
13
+ Matching requests include:
14
+
15
+ - batch prompt runners over tasks, manifests, components, stories, or tickets
16
+ - looping an agentic CLI (`agent`, `opencode`, `claude`) across many items
17
+ - resumable or checkpointed agent loops with per-task logs
18
+ - self-healing outer loops that diagnose failures and patch prompts
19
+ - overnight or unattended batch runs with verification gates
20
+ - stage-based workflows where items pass through multiple prompt phases
21
+ - log triage followed by targeted recheck runs
22
+
23
+ ## Architecture
24
+
25
+ {{include:domain/architecture-overview.md}}
26
+
27
+ ---
28
+
29
+ ## Contracts
30
+
31
+ {{include:domain/contracts.md}}
32
+
33
+ ---
34
+
35
+ ## Healing Model
36
+
37
+ {{include:domain/pbh-healing.md}}
38
+
39
+ ---
40
+
41
+ ## Verification and Safety
42
+
43
+ {{include:domain/verification-safety.md}}
44
+
45
+ ---
46
+
47
+ ## Adapter Model
48
+
49
+ {{include:domain/adapter-model.md}}
50
+
51
+ ---
52
+
53
+ ## State and Resume
54
+
55
+ {{include:domain/state-resume.md}}
56
+
57
+ ---
58
+
59
+ ## Normative Specification
60
+
61
+ The full architecture, contracts, schemas, and behavioral rules are defined in `SPEC.md`. That document is the single source of truth. Read it when you need the end-to-end control flow, complete schema field definitions, or edge-case behavioral rules.
62
+
63
+ ## Canonical Source Of Truth
64
+
65
+ {{include:meta/schemas-reference.md}}
66
+
67
+ {{include:meta/templates-reference.md}}
68
+
69
+ ---
70
+
71
+ ## Model Selection
72
+
73
+ {{include:common/model-selection.md}}
74
+
75
+ ---
76
+
77
+ ## Portability
78
+
79
+ {{include:common/portability-rules.md}}
80
+
81
+ ---
82
+
83
+ ## Workflow
84
+
85
+ {{include:common/workflow.md}}
@@ -0,0 +1,38 @@
1
+ import fs from "node:fs/promises";
2
+ import path from "node:path";
3
+
4
+ interface AtomicWriteOptions {
5
+ filePath: string;
6
+ value: unknown;
7
+ }
8
+
9
+ export async function writeAtomicJson(options: AtomicWriteOptions): Promise<void> {
10
+ const dir = path.dirname(options.filePath);
11
+ const base = path.basename(options.filePath);
12
+ const tmpPath = path.join(dir, `.${base}.tmp`);
13
+
14
+ await fs.mkdir(dir, { recursive: true });
15
+ await fs.writeFile(tmpPath, `${JSON.stringify(options.value, null, 2)}\n`, "utf8");
16
+ await fs.rename(tmpPath, options.filePath);
17
+ }
18
+
19
+ export function stableFailureSignature(failureClass: string, primarySignal: string): string {
20
+ const cleaned = primarySignal
21
+ .toLowerCase()
22
+ .replace(/\b\d{4}-\d{2}-\d{2}[t\s]\d{2}:\d{2}:\d{2}(?:\.\d+)?z?\b/g, "")
23
+ .replace(/\/[^\s]+/g, "")
24
+ .replace(/\b\d+\b/g, "")
25
+ .replace(/\s+/g, " ")
26
+ .trim()
27
+ .slice(0, 120)
28
+ .replace(/\s+/g, "_");
29
+
30
+ return `${failureClass.toLowerCase()}:${cleaned || "unknown"}`;
31
+ }
32
+
33
+ export function shouldEscalateRepeatedSignature(
34
+ repeatCount: number,
35
+ signatureRepeatLimit: number,
36
+ ): boolean {
37
+ return repeatCount >= signatureRepeatLimit;
38
+ }