executant 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.
@@ -0,0 +1,304 @@
1
+ # ============================================================================
2
+ # RETROSPECTIVE ANALYSIS PROMPT
3
+ # ============================================================================
4
+ # Purpose: Analyzes task execution highlights and generates improved task YAML
5
+ # Used by: src/retrospective.ts runRetrospective()
6
+ # Triggered when: A task completes with self_improve: true and has highlights
7
+ #
8
+ # Placeholders:
9
+ # {{TASK_NAME}} - Name of the task that was executed
10
+ # {{ORIGINAL_GOAL}} - The original goal statement (must be preserved)
11
+ # {{ORIGINAL_YAML}} - Complete original task YAML for reference
12
+ # {{HIGHLIGHTS}} - Aggregated highlight markdown files from execution
13
+ # {{METRICS}} - Execution metrics summary (failures, retries, etc.)
14
+ # ============================================================================
15
+
16
+ You are analyzing the execution of an Executant task to identify improvement opportunities.
17
+
18
+ # Task Information
19
+
20
+ **Task Name:** {{TASK_NAME}}
21
+
22
+ **Original Goal:** {{ORIGINAL_GOAL}}
23
+
24
+ # Execution Metrics
25
+
26
+ {{METRICS}}
27
+
28
+ # Execution Highlights
29
+
30
+ The following highlights were captured during execution. Each highlight represents a moment where the system encountered challenges:
31
+
32
+ {{HIGHLIGHTS}}
33
+
34
+ # Original Task YAML
35
+
36
+ ```yaml
37
+ {{ORIGINAL_YAML}}
38
+ ```
39
+
40
+ # Your Task
41
+
42
+ Analyze the execution highlights and generate an improved version of the task YAML that addresses the problems encountered during execution.
43
+
44
+ ## Analysis Guidelines
45
+
46
+ ### Interpreting Judge Failures (llm_as_judge: true)
47
+
48
+ Judge failures indicate that Claude's output didn't meet quality standards. Common causes:
49
+
50
+ **Unclear prompts** - The step instructions were too vague
51
+ - Fix: Add specific numbered sub-steps
52
+ - Fix: Define clear success criteria
53
+ - Fix: Specify what to check and how to verify it
54
+
55
+ **Missing criteria** - The prompt didn't explain what "good" looks like
56
+ - Fix: Add examples of expected output
57
+ - Fix: Specify quality thresholds (test coverage %, file count, etc.)
58
+ - Fix: Include validation steps
59
+
60
+ **Steps too large** - One step tried to do too much
61
+ - Fix: Break into smaller, focused steps
62
+ - Fix: Each step should have one clear objective
63
+
64
+ **Example Fix:**
65
+ ```
66
+ BEFORE:
67
+ - name: "validate results"
68
+ llm_as_judge: true
69
+ prompt: "Validate the conversion results"
70
+
71
+ AFTER:
72
+ - name: "validate results"
73
+ llm_as_judge: true
74
+ prompt: |
75
+ Validate the TypeScript conversion by checking:
76
+ 1. Read the generated .ts file
77
+ 2. Verify all functions have type annotations
78
+ 3. Check that tests pass (npm test)
79
+ 4. Confirm no compilation errors (tsc --noEmit)
80
+
81
+ Success criteria: All 4 checks pass without errors.
82
+ ```
83
+
84
+ ### Interpreting Self-Healing Events (self_healing: true)
85
+
86
+ Self-healing activations indicate brittle script steps that failed during execution. Common causes:
87
+
88
+ **Missing dependencies** - Command not found, package not installed
89
+ - Fix: Add a script step to install/check dependencies first
90
+ - Fix: Use explicit paths instead of assuming commands are in PATH
91
+
92
+ **Wrong assumptions** - Script assumed files/directories exist
93
+ - Fix: Add checks or create directories in the script
94
+ - Fix: Use `mkdir -p` instead of `mkdir`
95
+ - Fix: Check file existence before operating on it
96
+
97
+ **Environment issues** - PWD, env vars, or paths incorrect
98
+ - Fix: Use absolute paths instead of relative
99
+ - Fix: cd to correct directory in the script
100
+ - Fix: Set required environment variables
101
+
102
+ **Race conditions** - Script ran before previous step completed
103
+ - Fix: Add wait/check logic
104
+ - Fix: Combine dependent commands with && in one script step
105
+
106
+ **Example Fix:**
107
+ ```
108
+ BEFORE:
109
+ - name: "run tests"
110
+ type: script
111
+ self_healing: true
112
+ command: npm test
113
+
114
+ AFTER:
115
+ - name: "install dependencies"
116
+ type: script
117
+ command: npm install
118
+
119
+ - name: "run tests"
120
+ type: script
121
+ self_healing: true
122
+ command: npm test
123
+ ```
124
+
125
+ ### Interpreting Complex Tool Sequences
126
+
127
+ Complex tool sequences (3+ tools) indicate that Claude had to work hard to complete a step. Common causes:
128
+
129
+ **Vague instructions** - Step didn't specify what files to operate on
130
+ - Fix: List specific file paths to read/edit
131
+ - Fix: Specify glob patterns for file discovery
132
+ - Fix: Break discovery and operation into separate steps
133
+
134
+ **Exploratory work needed** - Claude had to search to understand the codebase
135
+ - Fix: Add a separate discovery/analysis step first
136
+ - Fix: Provide file paths in the prompt
137
+ - Fix: Include relevant code snippets in the prompt
138
+
139
+ **Multi-phase operations** - One step tried to do research + implementation
140
+ - Fix: Split into "research" step and "implementation" step
141
+ - Fix: First step outputs findings, second step acts on them
142
+
143
+ **Example Fix:**
144
+ ```
145
+ BEFORE:
146
+ - name: "update imports"
147
+ prompt: "Update all imports to use the new module structure"
148
+
149
+ AFTER:
150
+ - name: "analyze imports"
151
+ prompt: |
152
+ Search the codebase for all import statements:
153
+ 1. Use grep to find all imports in src/
154
+ 2. List files that import from old modules
155
+ 3. Create a plan for updating each file
156
+
157
+ - name: "update imports"
158
+ prompt: |
159
+ Update imports in the following files based on the analysis:
160
+ - src/components/Button.tsx
161
+ - src/utils/helpers.ts
162
+ - src/services/api.ts
163
+
164
+ Change: import from './old/' to import from '@/new/'
165
+ ```
166
+
167
+ ## Improvement Principles
168
+
169
+ 1. **Preserve the original goal** - The task succeeded, so the goal is correct
170
+ 2. **Fix problems shown in highlights** - Only address issues that actually occurred
171
+ 3. **Be specific** - Add numbered steps, file paths, and clear criteria
172
+ 4. **Break down large steps** - If a step caused many retries or complex tool sequences
173
+ 5. **Add prerequisite steps** - If self-healing had to install deps or create files
174
+ 6. **Keep self_improve: true** - Allow recursive improvement in future runs
175
+ 7. **Document changes** - Explain what you changed and why in the changelog
176
+
177
+ ## Improvement Patterns
178
+
179
+ ### Pattern: Split Vague Prompt into Specific Sub-Steps
180
+
181
+ When a judge fails or complex tools are needed, make the prompt more specific:
182
+
183
+ ```yaml
184
+ # BEFORE: Vague, requires exploration
185
+ - name: "refactor authentication"
186
+ llm_as_judge: true
187
+ prompt: "Refactor the authentication code"
188
+
189
+ # AFTER: Specific numbered steps
190
+ - name: "refactor authentication"
191
+ llm_as_judge: true
192
+ prompt: |
193
+ Refactor authentication by:
194
+ 1. Reading src/auth/login.ts and src/auth/session.ts
195
+ 2. Extracting common logic into src/auth/helpers.ts
196
+ 3. Updating imports in both files
197
+ 4. Running tests to verify: npm test src/auth/
198
+
199
+ Success: Tests pass, no code duplication between login.ts and session.ts
200
+ ```
201
+
202
+ ### Pattern: Add Prerequisite Step
203
+
204
+ When self-healing installs deps or fixes environment:
205
+
206
+ ```yaml
207
+ # BEFORE: Brittle, assumes deps installed
208
+ steps:
209
+ - name: "build"
210
+ type: script
211
+ self_healing: true
212
+ command: npm run build
213
+
214
+ # AFTER: Explicit dependency step
215
+ steps:
216
+ - name: "install dependencies"
217
+ type: script
218
+ command: npm install
219
+
220
+ - name: "build"
221
+ type: script
222
+ command: npm run build
223
+ ```
224
+
225
+ ### Pattern: Split Research from Implementation
226
+
227
+ When complex tool sequences suggest exploratory work:
228
+
229
+ ```yaml
230
+ # BEFORE: Combined research + work
231
+ - name: "fix bugs"
232
+ prompt: "Find and fix all bugs in the payment flow"
233
+
234
+ # AFTER: Separated discovery and fixing
235
+ - name: "identify payment bugs"
236
+ prompt: |
237
+ Analyze the payment flow for bugs:
238
+ 1. Read src/payment/*.ts files
239
+ 2. Check for error handling gaps
240
+ 3. List files that need fixes
241
+
242
+ - name: "fix payment bugs"
243
+ llm_as_judge: true
244
+ prompt: |
245
+ Fix bugs identified in previous step:
246
+ - Add error handling in src/payment/checkout.ts
247
+ - Validate input in src/payment/process.ts
248
+ - Update tests in src/payment/__tests__/
249
+
250
+ Success: All payment tests pass
251
+ ```
252
+
253
+ ### Pattern: Add Explicit Success Criteria
254
+
255
+ When judge fails due to unclear expectations:
256
+
257
+ ```yaml
258
+ # BEFORE: No clear success criteria
259
+ - name: "improve test coverage"
260
+ llm_as_judge: true
261
+ prompt: "Improve test coverage for the API module"
262
+
263
+ # AFTER: Explicit threshold and verification
264
+ - name: "improve test coverage"
265
+ llm_as_judge: true
266
+ prompt: |
267
+ Improve test coverage for src/api/ to at least 80%:
268
+ 1. Run: npm test -- --coverage src/api/
269
+ 2. Identify files with <80% coverage
270
+ 3. Write tests for uncovered code paths
271
+ 4. Re-run coverage and verify ≥80%
272
+
273
+ Success criteria: Coverage report shows ≥80% for all files in src/api/
274
+ ```
275
+
276
+ # Output Format
277
+
278
+ Respond with a single JSON object:
279
+ {
280
+ "improved_yaml": "<complete improved task YAML — no markdown fences, raw YAML only>",
281
+ "changelog": "<markdown: Problems Identified / Changes Applied / Expected Impact>"
282
+ }
283
+
284
+ Output only the JSON object — no prose before or after.
285
+
286
+ # Important Requirements
287
+
288
+ 1. **Always preserve the original goal** - Do not change the goal statement
289
+ 2. **Keep self_improve: true** - This enables recursive improvement
290
+ 3. **Only fix problems shown in highlights** - Don't add unnecessary changes
291
+ 4. **Be specific in improvements** - Vague fixes won't help
292
+ 5. **Generate valid YAML** - The improved task must be parseable
293
+ 6. **Explain all changes** - The changelog should justify each modification
294
+
295
+ # Example Response
296
+
297
+ ```json
298
+ {
299
+ "improved_yaml": "goal: \"Convert CoffeeScript to TypeScript with validation\"\nself_improve: true\n\nsteps:\n - name: \"install dependencies\"\n type: script\n command: npm install\n\n - name: \"convert to TypeScript\"\n type: script\n command: coffee2ts convert app.coffee\n\n - name: \"validate conversion\"\n llm_as_judge: true\n prompt: |\n Validate the TypeScript conversion by:\n 1. Reading app.ts and checking all functions have type annotations\n 2. Running: tsc --noEmit to check for type errors\n 3. Running: npm test to verify functionality\n\n Success criteria: No type errors, all tests pass",
300
+ "changelog": "## Problems Identified\n- Judge failure in \"validate conversion\": Instructions were too vague\n- Self-healing activation: npm dependencies were missing\n\n## Changes Applied\n\n### Step 1: install dependencies (NEW)\n- Before: Not present\n- After: Added explicit npm install step\n- Rationale: Self-healing had to install deps, do it upfront\n\n### Step 3: validate conversion (MODIFIED)\n- Before: \"Validate the results\"\n- After: Specific 3-step validation with success criteria\n- Rationale: Judge failed because unclear what to validate and how\n\n## Expected Impact\n- Judge retries: 1 → 0 (clearer validation steps)\n- Self-healing activations: 1 → 0 (deps installed first)"
301
+ }
302
+ ```
303
+
304
+ Now analyze the highlights and generate the improved task YAML with detailed changelog.
@@ -0,0 +1,54 @@
1
+ # ============================================================================
2
+ # SELF-HEALING FIX
3
+ # ============================================================================
4
+ # Purpose: Multi-pass repair agent for command failures with iterative fixes
5
+ # Used by: src/runner.ts runCommandWithHealing()
6
+ # Triggered when: A command step fails (self_healing defaults to true)
7
+ #
8
+ # Placeholders:
9
+ # {{COMMAND}} - The bash command that failed
10
+ # {{EXIT_CODE}} - The non-zero exit code
11
+ # {{OUTPUT}} - The last 3000 chars of stdout/stderr
12
+ # {{ATTEMPT_HISTORY}} - Structured log of prior fix attempts (empty on first try)
13
+ # ============================================================================
14
+
15
+ You are a self-healing repair agent. A command has failed and you must diagnose and fix the issue.
16
+
17
+ FAILED COMMAND:
18
+ ```bash
19
+ {{COMMAND}}
20
+ ```
21
+
22
+ EXIT CODE: {{EXIT_CODE}}
23
+
24
+ LATEST OUTPUT (last 3000 chars):
25
+ ```
26
+ {{OUTPUT}}
27
+ ```
28
+
29
+ {{ATTEMPT_HISTORY}}
30
+
31
+ Your job:
32
+ 1. Analyse the latest error output carefully. Identify the ROOT CAUSE — not just the symptom.
33
+ 2. Review the attempt history above (if any). DO NOT repeat a fix that already failed.
34
+ Each prior attempt describes what was tried and what happened. Learn from those failures.
35
+ 3. Use your Bash/Read/Write/Edit/Grep/Glob tools to investigate the codebase and apply a fix.
36
+ 4. After applying your fix, run the failing command yourself to verify it passes before finishing.
37
+ 5. Report concisely: what the root cause was and what you changed.
38
+
39
+ Think step by step. If the error is a test failure, read the test file and the implementation
40
+ it tests. Understand what the test expects before changing code.
41
+
42
+ ## Required Output Format
43
+
44
+ Your response MUST end with these four sections in order:
45
+
46
+ **Diagnosis:** One short paragraph identifying the root cause of the failure.
47
+
48
+ **Fix:** One short paragraph describing what you changed and why it resolves the issue.
49
+
50
+ (Apply the fix using your available tools before writing the sections above.)
51
+
52
+ **Verification:** Confirm the command passed after your fix, or note if it still fails.
53
+
54
+ RETRY: <updated command to re-execute, or the original command if unchanged>
package/package.json ADDED
@@ -0,0 +1,89 @@
1
+ {
2
+ "name": "executant",
3
+ "version": "1.0.0",
4
+ "description": "TypeScript TUI workflow runner",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "bin": {
8
+ "executant": "./dist/index.js"
9
+ },
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "scripts": {
14
+ "bundle": "esbuild src/index.ts --bundle --platform=node --format=esm --packages=external --outfile=dist/index.js && rm -rf dist/prompts && cp -r src/prompts dist/prompts",
15
+ "dev": "tsx src/index.ts",
16
+ "start": "node dist/index.js",
17
+ "test": "env -u NODE_TEST_CONTEXT node --import tsx/esm --test src/tests/*.test.ts",
18
+ "lint": "eslint src",
19
+ "knip": "knip"
20
+ },
21
+ "dependencies": {
22
+ "@coston/design-tokens": "^0.9.2",
23
+ "ink": "^5.0.1",
24
+ "js-yaml": "^4.1.0",
25
+ "react": "^18.3.1",
26
+ "zod": "^3.23.8",
27
+ "zod-to-json-schema": "^3.25.2"
28
+ },
29
+ "devDependencies": {
30
+ "@commitlint/cli": "^20.5.0",
31
+ "@commitlint/config-conventional": "^20.5.0",
32
+ "@semantic-release/git": "^10.0.1",
33
+ "@semantic-release/npm": "^13.1.5",
34
+ "@types/js-yaml": "^4.0.9",
35
+ "@types/node": "^20.14.0",
36
+ "@types/react": "^18.3.3",
37
+ "esbuild": "^0.28.0",
38
+ "eslint": "^9.39.4",
39
+ "husky": "^9.1.7",
40
+ "knip": "^5.88.1",
41
+ "lint-staged": "^16.4.0",
42
+ "semantic-release": "^24.2.9",
43
+ "tsx": "^4.15.7",
44
+ "typescript": "^5.4.5",
45
+ "typescript-eslint": "^8.58.0"
46
+ },
47
+ "commitlint": {
48
+ "extends": [
49
+ "@commitlint/config-conventional"
50
+ ]
51
+ },
52
+ "lint-staged": {
53
+ "*.{ts,tsx}": "eslint --fix"
54
+ },
55
+ "release": {
56
+ "branches": [
57
+ "main"
58
+ ],
59
+ "plugins": [
60
+ "@semantic-release/commit-analyzer",
61
+ "@semantic-release/release-notes-generator",
62
+ [
63
+ "@semantic-release/npm",
64
+ {
65
+ "npmPublish": true
66
+ }
67
+ ],
68
+ [
69
+ "@semantic-release/git",
70
+ {
71
+ "assets": [
72
+ "package.json"
73
+ ],
74
+ "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
75
+ }
76
+ ],
77
+ "@semantic-release/github"
78
+ ]
79
+ },
80
+ "knip": {
81
+ "entry": [
82
+ "src/index.ts"
83
+ ],
84
+ "project": [
85
+ "src/**/*.ts",
86
+ "src/**/*.tsx"
87
+ ]
88
+ }
89
+ }