abelworkflow 0.9.2 → 1.0.0-rc.1
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.
- package/README.md +55 -182
- package/bin/abelworkflow.mjs +5 -3
- package/lib/cli/args.mjs +76 -0
- package/lib/cli/main.mjs +387 -0
- package/lib/cli/prompts.mjs +119 -0
- package/lib/config/dotenv.mjs +102 -0
- package/lib/config/jsonc.mjs +80 -0
- package/lib/config/store.mjs +310 -0
- package/lib/config/toml.mjs +638 -0
- package/lib/installer/assets.mjs +326 -0
- package/lib/installer/install.mjs +167 -0
- package/lib/installer/links.mjs +427 -0
- package/lib/installer/render.mjs +46 -0
- package/lib/installer/state.mjs +182 -0
- package/lib/paths.mjs +99 -0
- package/lib/providers/claude.mjs +388 -0
- package/lib/providers/codex.mjs +433 -0
- package/lib/providers/pi.mjs +362 -0
- package/lib/providers/skills.mjs +164 -0
- package/lib/templates/codex/agents/default.toml +7 -0
- package/lib/templates/codex/agents/explorer.toml +7 -0
- package/lib/templates/codex/agents/planner.toml +7 -0
- package/lib/templates/codex/agents/reviewer.toml +7 -0
- package/lib/templates/codex/agents/worker.toml +7 -0
- package/lib/templates/codex/config-base.toml +11 -3
- package/{AGENTS.md → lib/templates/workflow/AGENTS.md} +8 -3
- package/{commands → lib/templates/workflow/commands}/abel-diagnose.md +5 -5
- package/{commands → lib/templates/workflow/commands}/abel-implement.md +3 -8
- package/{commands → lib/templates/workflow/commands}/abel-init.md +1 -1
- package/{commands → lib/templates/workflow/commands}/abel-plan.md +1 -7
- package/{commands → lib/templates/workflow/commands}/abel-research.md +1 -1
- package/{.gitignore → lib/templates/workflow/gitignore.template} +0 -2
- package/lib/tools/cli-installer.mjs +277 -0
- package/package.json +43 -10
- package/skills/context7-auto-research/SKILL.md +5 -5
- package/skills/context7-auto-research/{context7-api.js → context7-api.cjs} +5 -8
- package/skills/dev-browser/SKILL.md +53 -33
- package/skills/dev-browser/dist/scripts/start.d.ts +2 -0
- package/skills/dev-browser/dist/scripts/start.d.ts.map +1 -0
- package/skills/dev-browser/dist/scripts/start.js +118 -0
- package/skills/dev-browser/dist/scripts/start.js.map +1 -0
- package/skills/dev-browser/dist/src/client.d.ts +93 -0
- package/skills/dev-browser/dist/src/client.d.ts.map +1 -0
- package/skills/dev-browser/dist/src/client.js +310 -0
- package/skills/dev-browser/dist/src/client.js.map +1 -0
- package/skills/dev-browser/dist/src/entrypoint.d.ts +29 -0
- package/skills/dev-browser/dist/src/entrypoint.d.ts.map +1 -0
- package/skills/dev-browser/dist/src/entrypoint.js +106 -0
- package/skills/dev-browser/dist/src/entrypoint.js.map +1 -0
- package/skills/dev-browser/dist/src/index.d.ts +4 -0
- package/skills/dev-browser/dist/src/index.d.ts.map +1 -0
- package/skills/dev-browser/dist/src/index.js +2 -0
- package/skills/dev-browser/dist/src/index.js.map +1 -0
- package/skills/dev-browser/dist/src/page-api.d.ts +25 -0
- package/skills/dev-browser/dist/src/page-api.d.ts.map +1 -0
- package/skills/dev-browser/dist/src/page-api.js +104 -0
- package/skills/dev-browser/dist/src/page-api.js.map +1 -0
- package/skills/dev-browser/dist/src/relay.d.ts +27 -0
- package/skills/dev-browser/dist/src/relay.d.ts.map +1 -0
- package/skills/dev-browser/dist/src/relay.js +521 -0
- package/skills/dev-browser/dist/src/relay.js.map +1 -0
- package/skills/dev-browser/dist/src/runtime.d.ts +45 -0
- package/skills/dev-browser/dist/src/runtime.d.ts.map +1 -0
- package/skills/dev-browser/dist/src/runtime.js +54 -0
- package/skills/dev-browser/dist/src/runtime.js.map +1 -0
- package/skills/dev-browser/dist/src/snapshot/browser-script.d.ts +23 -0
- package/skills/dev-browser/dist/src/snapshot/browser-script.d.ts.map +1 -0
- package/skills/dev-browser/{src/snapshot/browser-script.ts → dist/src/snapshot/browser-script.js} +21 -30
- package/skills/dev-browser/dist/src/snapshot/browser-script.js.map +1 -0
- package/skills/dev-browser/dist/src/snapshot/index.d.ts +14 -0
- package/skills/dev-browser/dist/src/snapshot/index.d.ts.map +1 -0
- package/skills/dev-browser/{src/snapshot/index.ts → dist/src/snapshot/index.js} +2 -2
- package/skills/dev-browser/dist/src/snapshot/index.js.map +1 -0
- package/skills/dev-browser/dist/src/snapshot/inject.d.ts +13 -0
- package/skills/dev-browser/dist/src/snapshot/inject.d.ts.map +1 -0
- package/skills/dev-browser/{src/snapshot/inject.ts → dist/src/snapshot/inject.js} +2 -2
- package/skills/dev-browser/dist/src/snapshot/inject.js.map +1 -0
- package/skills/dev-browser/dist/src/standalone.d.ts +32 -0
- package/skills/dev-browser/dist/src/standalone.d.ts.map +1 -0
- package/skills/dev-browser/dist/src/standalone.js +174 -0
- package/skills/dev-browser/dist/src/standalone.js.map +1 -0
- package/skills/dev-browser/dist/src/startup.d.ts +55 -0
- package/skills/dev-browser/dist/src/startup.d.ts.map +1 -0
- package/skills/dev-browser/dist/src/startup.js +81 -0
- package/skills/dev-browser/dist/src/startup.js.map +1 -0
- package/skills/dev-browser/dist/src/target-registry.d.ts +29 -0
- package/skills/dev-browser/dist/src/target-registry.d.ts.map +1 -0
- package/skills/dev-browser/dist/src/target-registry.js +135 -0
- package/skills/dev-browser/dist/src/target-registry.js.map +1 -0
- package/skills/dev-browser/dist/src/types.d.ts +27 -0
- package/skills/dev-browser/dist/src/types.d.ts.map +1 -0
- package/skills/dev-browser/dist/src/types.js +2 -0
- package/skills/dev-browser/dist/src/types.js.map +1 -0
- package/skills/dev-browser/package-lock.json +67 -1510
- package/skills/dev-browser/package.json +18 -14
- package/skills/dev-browser/references/scraping.md +94 -105
- package/skills/grok-search/defaults.json +3 -0
- package/skills/grok-search/gitignore.template +4 -0
- package/skills/grok-search/scripts/_dotenv.py +5 -1
- package/skills/grok-search/scripts/groksearch_cli.py +15 -33
- package/skills/prompt-enhancer/TEMPLATE.md +0 -4
- package/skills/prompt-enhancer/requirements.txt +0 -1
- package/skills/prompt-enhancer/scripts/_dotenv.py +5 -1
- package/skills/prompt-enhancer/scripts/enhance.py +4 -51
- package/skills/prompt-enhancer/scripts/prompt_enhancer_entry.py +1 -16
- package/.skill-lock.json +0 -29
- package/lib/cli/logic.mjs +0 -213
- package/lib/cli.mjs +0 -3016
- package/skills/confidence-check/SKILL.md +0 -34
- package/skills/confidence-check/confidence.ts +0 -276
- package/skills/dev-browser/bun.lock +0 -460
- package/skills/dev-browser/scripts/start.ts +0 -280
- package/skills/dev-browser/src/client.ts +0 -474
- package/skills/dev-browser/src/entrypoint.ts +0 -157
- package/skills/dev-browser/src/index.ts +0 -289
- package/skills/dev-browser/src/relay.ts +0 -731
- package/skills/dev-browser/src/runtime.test.ts +0 -60
- package/skills/dev-browser/src/runtime.ts +0 -171
- package/skills/dev-browser/src/startup.test.ts +0 -95
- package/skills/dev-browser/src/startup.ts +0 -153
- package/skills/dev-browser/src/types.ts +0 -35
- package/skills/dev-browser/tsconfig.json +0 -36
- package/skills/dev-browser/vitest.config.ts +0 -12
- package/skills/sequential-think/SKILL.md +0 -198
- package/skills/sequential-think/scripts/.env.example +0 -5
- package/skills/sequential-think/scripts/sequential_think_cli.py +0 -253
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: sequential-think
|
|
3
|
-
description: |
|
|
4
|
-
Multi-step reasoning engine for complex analysis and systematic problem solving. Use when: (1) Complex debugging scenarios with multiple layers, (2) Architectural analysis and system design, (3) Problems requiring hypothesis testing and validation, (4) Multi-component failure investigation, (5) Performance bottleneck identification. Triggers: "--think", "--think-hard", "--ultrathink", "analyze step by step", "break down this problem", "systematic analysis". IMPORTANT: Do NOT use for simple single-step tasks.
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Sequential Think
|
|
8
|
-
|
|
9
|
-
Structured iterative thinking for complex problem-solving. Supports both MCP server and standalone CLI.
|
|
10
|
-
|
|
11
|
-
## Execution Methods
|
|
12
|
-
|
|
13
|
-
### Method 1: MCP Tools (if available)
|
|
14
|
-
Use `mcp__sequential-thinking__sequentialthinking` tool directly.
|
|
15
|
-
|
|
16
|
-
### Method 2: CLI Script (no MCP dependency)
|
|
17
|
-
Run `scripts/sequential_think_cli.py` via Bash:
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
# Process a thought
|
|
21
|
-
python scripts/sequential_think_cli.py think \
|
|
22
|
-
--thought "First, let me analyze the problem structure..." \
|
|
23
|
-
--thought-number 1 \
|
|
24
|
-
--total-thoughts 5
|
|
25
|
-
|
|
26
|
-
# Continue thinking chain
|
|
27
|
-
python scripts/sequential_think_cli.py think \
|
|
28
|
-
--thought "Based on step 1, I hypothesize that..." \
|
|
29
|
-
--thought-number 2 \
|
|
30
|
-
--total-thoughts 5
|
|
31
|
-
|
|
32
|
-
# Revise a previous thought
|
|
33
|
-
python scripts/sequential_think_cli.py think \
|
|
34
|
-
--thought "Reconsidering step 1, I realize..." \
|
|
35
|
-
--thought-number 3 \
|
|
36
|
-
--total-thoughts 5 \
|
|
37
|
-
--is-revision \
|
|
38
|
-
--revises-thought 1
|
|
39
|
-
|
|
40
|
-
# Branch into alternative path
|
|
41
|
-
python scripts/sequential_think_cli.py think \
|
|
42
|
-
--thought "Alternative approach: what if we..." \
|
|
43
|
-
--thought-number 4 \
|
|
44
|
-
--total-thoughts 6 \
|
|
45
|
-
--branch-from 2 \
|
|
46
|
-
--branch-id "alt-approach"
|
|
47
|
-
|
|
48
|
-
# Final thought (complete chain)
|
|
49
|
-
python scripts/sequential_think_cli.py think \
|
|
50
|
-
--thought "Conclusion: the solution is..." \
|
|
51
|
-
--thought-number 5 \
|
|
52
|
-
--total-thoughts 5 \
|
|
53
|
-
--no-next
|
|
54
|
-
|
|
55
|
-
# View thought history
|
|
56
|
-
python scripts/sequential_think_cli.py history [--format json|text]
|
|
57
|
-
|
|
58
|
-
# Clear thought history
|
|
59
|
-
python scripts/sequential_think_cli.py clear
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
## Core Principles
|
|
63
|
-
|
|
64
|
-
### Iterative Thinking Process
|
|
65
|
-
- Each tool call = one "thought" in the chain
|
|
66
|
-
- Build upon, question, or revise previous thoughts
|
|
67
|
-
- Express uncertainty when it exists
|
|
68
|
-
|
|
69
|
-
### Dynamic Thought Count
|
|
70
|
-
- Start with initial estimate of `totalThoughts`
|
|
71
|
-
- Adjust up/down as understanding evolves
|
|
72
|
-
- Add more thoughts even after reaching initial end
|
|
73
|
-
|
|
74
|
-
### Hypothesis-Driven Approach
|
|
75
|
-
1. Generate hypotheses as potential solutions emerge
|
|
76
|
-
2. Verify hypotheses based on chain-of-thought steps
|
|
77
|
-
3. Repeat until satisfied with solution
|
|
78
|
-
|
|
79
|
-
### Completion Criteria
|
|
80
|
-
- Only set `nextThoughtNeeded: false` when truly finished
|
|
81
|
-
- Must have satisfactory, verified answer
|
|
82
|
-
- Don't rush to conclusion
|
|
83
|
-
|
|
84
|
-
## When to Use
|
|
85
|
-
|
|
86
|
-
| Scenario | Use Sequential Think |
|
|
87
|
-
|----------|---------------------|
|
|
88
|
-
| Complex debugging (3+ layers) | ✅ Yes |
|
|
89
|
-
| Architectural analysis | ✅ Yes |
|
|
90
|
-
| Multi-component investigation | ✅ Yes |
|
|
91
|
-
| Performance bottleneck analysis | ✅ Yes |
|
|
92
|
-
| Root cause analysis | ✅ Yes |
|
|
93
|
-
| Simple explanation | ❌ No |
|
|
94
|
-
| Single-file change | ❌ No |
|
|
95
|
-
| Straightforward fix | ❌ No |
|
|
96
|
-
|
|
97
|
-
## Parameters
|
|
98
|
-
|
|
99
|
-
| Parameter | Type | Required | Description |
|
|
100
|
-
|-----------|------|----------|-------------|
|
|
101
|
-
| `thought` | string | Yes | Current thinking step content |
|
|
102
|
-
| `thoughtNumber` | int | Yes | Current position in sequence (1-based) |
|
|
103
|
-
| `totalThoughts` | int | Yes | Estimated total thoughts needed |
|
|
104
|
-
| `nextThoughtNeeded` | bool | No | Whether more thinking needed (default: true) |
|
|
105
|
-
| `isRevision` | bool | No | Whether this revises previous thinking |
|
|
106
|
-
| `revisesThought` | int | No | Which thought number is being reconsidered |
|
|
107
|
-
| `branchFromThought` | int | No | Branching point thought number |
|
|
108
|
-
| `branchId` | string | No | Identifier for current branch |
|
|
109
|
-
| `needsMoreThoughts` | bool | No | Signal that more thoughts needed beyond estimate |
|
|
110
|
-
|
|
111
|
-
## Output Format
|
|
112
|
-
|
|
113
|
-
```json
|
|
114
|
-
{
|
|
115
|
-
"thoughtNumber": 3,
|
|
116
|
-
"totalThoughts": 5,
|
|
117
|
-
"nextThoughtNeeded": true,
|
|
118
|
-
"branches": ["alt-approach"],
|
|
119
|
-
"thoughtHistoryLength": 3
|
|
120
|
-
}
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
## Workflow Pattern
|
|
124
|
-
|
|
125
|
-
### Phase 1: Problem Decomposition
|
|
126
|
-
```
|
|
127
|
-
Thought 1: Identify problem scope and constraints
|
|
128
|
-
Thought 2: Break into sub-problems
|
|
129
|
-
Thought 3: Identify dependencies between sub-problems
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
### Phase 2: Hypothesis Generation
|
|
133
|
-
```
|
|
134
|
-
Thought 4: Generate initial hypothesis
|
|
135
|
-
Thought 5: Identify evidence needed to verify
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
### Phase 3: Verification & Iteration
|
|
139
|
-
```
|
|
140
|
-
Thought 6: Test hypothesis against evidence
|
|
141
|
-
Thought 7: Revise if needed (isRevision=true)
|
|
142
|
-
Thought 8: Branch if alternative path promising
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
### Phase 4: Conclusion
|
|
146
|
-
```
|
|
147
|
-
Final Thought: Synthesize findings, provide answer (nextThoughtNeeded=false)
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
## Best Practices
|
|
151
|
-
|
|
152
|
-
1. **Start with estimate, adjust as needed**
|
|
153
|
-
- Initial `totalThoughts` is just a guess
|
|
154
|
-
- Increase if problem more complex than expected
|
|
155
|
-
- Decrease if solution found early
|
|
156
|
-
|
|
157
|
-
2. **Use revisions for course correction**
|
|
158
|
-
- Mark `isRevision=true` when reconsidering
|
|
159
|
-
- Reference `revisesThought` for clarity
|
|
160
|
-
|
|
161
|
-
3. **Branch for alternative approaches**
|
|
162
|
-
- Use `branchFromThought` to explore alternatives
|
|
163
|
-
- Give meaningful `branchId` names
|
|
164
|
-
|
|
165
|
-
4. **Filter irrelevant information**
|
|
166
|
-
- Each thought should advance toward solution
|
|
167
|
-
- Ignore tangential details
|
|
168
|
-
|
|
169
|
-
5. **Don't rush completion**
|
|
170
|
-
- Only `nextThoughtNeeded=false` when truly done
|
|
171
|
-
- Verify hypothesis before concluding
|
|
172
|
-
|
|
173
|
-
## Anti-Patterns
|
|
174
|
-
|
|
175
|
-
| Prohibited | Correct |
|
|
176
|
-
|------------|---------|
|
|
177
|
-
| Use for simple tasks | Reserve for complex multi-step problems |
|
|
178
|
-
| Skip thought numbers | Always increment correctly |
|
|
179
|
-
| Conclude without verification | Verify hypothesis before final thought |
|
|
180
|
-
| Ignore previous thoughts | Build upon or explicitly revise |
|
|
181
|
-
| Fixed totalThoughts | Adjust as understanding evolves |
|
|
182
|
-
|
|
183
|
-
## Integration with Other Tools
|
|
184
|
-
|
|
185
|
-
### With augment-context-engine
|
|
186
|
-
```
|
|
187
|
-
augment-context-engine → align current state → Sequential Think → analyze and plan
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
### With Context7
|
|
191
|
-
```
|
|
192
|
-
Sequential Think → coordinate analysis → Context7 → provide official patterns
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
### With Serena
|
|
196
|
-
```
|
|
197
|
-
Serena → symbol-level exploration → Sequential Think → systematic analysis
|
|
198
|
-
```
|
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""Sequential Think CLI - Standalone iterative thinking engine for complex problem-solving."""
|
|
3
|
-
|
|
4
|
-
import argparse
|
|
5
|
-
import json
|
|
6
|
-
import sys
|
|
7
|
-
from dataclasses import dataclass, field, asdict
|
|
8
|
-
from datetime import datetime
|
|
9
|
-
from pathlib import Path
|
|
10
|
-
from typing import List, Optional, Dict
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
# ============================================================================
|
|
14
|
-
# Data Models
|
|
15
|
-
# ============================================================================
|
|
16
|
-
|
|
17
|
-
@dataclass
|
|
18
|
-
class ThoughtData:
|
|
19
|
-
thought: str
|
|
20
|
-
thought_number: int
|
|
21
|
-
total_thoughts: int
|
|
22
|
-
next_thought_needed: bool = True
|
|
23
|
-
is_revision: bool = False
|
|
24
|
-
revises_thought: Optional[int] = None
|
|
25
|
-
branch_from_thought: Optional[int] = None
|
|
26
|
-
branch_id: Optional[str] = None
|
|
27
|
-
needs_more_thoughts: bool = False
|
|
28
|
-
timestamp: str = field(default_factory=lambda: datetime.now().isoformat())
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
# ============================================================================
|
|
32
|
-
# Thought History Manager
|
|
33
|
-
# ============================================================================
|
|
34
|
-
|
|
35
|
-
class ThoughtHistoryManager:
|
|
36
|
-
_instance = None
|
|
37
|
-
|
|
38
|
-
def __new__(cls):
|
|
39
|
-
if cls._instance is None:
|
|
40
|
-
cls._instance = super().__new__(cls)
|
|
41
|
-
cls._instance._history: List[ThoughtData] = []
|
|
42
|
-
cls._instance._branches: Dict[str, List[ThoughtData]] = {}
|
|
43
|
-
cls._instance._history_file: Optional[Path] = None
|
|
44
|
-
return cls._instance
|
|
45
|
-
|
|
46
|
-
@property
|
|
47
|
-
def history_file(self) -> Path:
|
|
48
|
-
if self._history_file is None:
|
|
49
|
-
config_dir = Path.home() / ".config" / "sequential-think"
|
|
50
|
-
config_dir.mkdir(parents=True, exist_ok=True)
|
|
51
|
-
self._history_file = config_dir / "thought_history.json"
|
|
52
|
-
return self._history_file
|
|
53
|
-
|
|
54
|
-
def _load_history(self) -> None:
|
|
55
|
-
if self.history_file.exists():
|
|
56
|
-
try:
|
|
57
|
-
with open(self.history_file, 'r', encoding='utf-8') as f:
|
|
58
|
-
data = json.load(f)
|
|
59
|
-
self._history = [ThoughtData(**t) for t in data.get("history", [])]
|
|
60
|
-
self._branches = {
|
|
61
|
-
k: [ThoughtData(**t) for t in v]
|
|
62
|
-
for k, v in data.get("branches", {}).items()
|
|
63
|
-
}
|
|
64
|
-
except (json.JSONDecodeError, IOError, TypeError):
|
|
65
|
-
self._history = []
|
|
66
|
-
self._branches = {}
|
|
67
|
-
|
|
68
|
-
def _save_history(self) -> None:
|
|
69
|
-
data = {
|
|
70
|
-
"history": [asdict(t) for t in self._history],
|
|
71
|
-
"branches": {k: [asdict(t) for t in v] for k, v in self._branches.items()}
|
|
72
|
-
}
|
|
73
|
-
with open(self.history_file, 'w', encoding='utf-8') as f:
|
|
74
|
-
json.dump(data, f, ensure_ascii=False, indent=2)
|
|
75
|
-
|
|
76
|
-
def add_thought(self, thought: ThoughtData) -> Dict:
|
|
77
|
-
self._load_history()
|
|
78
|
-
|
|
79
|
-
# Auto-adjust total if thought_number exceeds it
|
|
80
|
-
if thought.thought_number > thought.total_thoughts:
|
|
81
|
-
thought.total_thoughts = thought.thought_number
|
|
82
|
-
|
|
83
|
-
self._history.append(thought)
|
|
84
|
-
|
|
85
|
-
# Track branches
|
|
86
|
-
if thought.branch_from_thought and thought.branch_id:
|
|
87
|
-
if thought.branch_id not in self._branches:
|
|
88
|
-
self._branches[thought.branch_id] = []
|
|
89
|
-
self._branches[thought.branch_id].append(thought)
|
|
90
|
-
|
|
91
|
-
self._save_history()
|
|
92
|
-
|
|
93
|
-
return {
|
|
94
|
-
"thoughtNumber": thought.thought_number,
|
|
95
|
-
"totalThoughts": thought.total_thoughts,
|
|
96
|
-
"nextThoughtNeeded": thought.next_thought_needed,
|
|
97
|
-
"branches": list(self._branches.keys()),
|
|
98
|
-
"thoughtHistoryLength": len(self._history)
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
def get_history(self) -> Dict:
|
|
102
|
-
self._load_history()
|
|
103
|
-
return {
|
|
104
|
-
"history": [asdict(t) for t in self._history],
|
|
105
|
-
"branches": {k: [asdict(t) for t in v] for k, v in self._branches.items()},
|
|
106
|
-
"totalThoughts": len(self._history)
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
def clear_history(self) -> Dict:
|
|
110
|
-
self._history = []
|
|
111
|
-
self._branches = {}
|
|
112
|
-
if self.history_file.exists():
|
|
113
|
-
self.history_file.unlink()
|
|
114
|
-
return {"status": "cleared", "message": "Thought history cleared"}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
manager = ThoughtHistoryManager()
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
# ============================================================================
|
|
121
|
-
# Formatters
|
|
122
|
-
# ============================================================================
|
|
123
|
-
|
|
124
|
-
def format_thought_text(thought: ThoughtData) -> str:
|
|
125
|
-
prefix = ""
|
|
126
|
-
context = ""
|
|
127
|
-
|
|
128
|
-
if thought.is_revision:
|
|
129
|
-
prefix = "🔄 Revision"
|
|
130
|
-
context = f" (revising thought {thought.revises_thought})"
|
|
131
|
-
elif thought.branch_from_thought:
|
|
132
|
-
prefix = "🌿 Branch"
|
|
133
|
-
context = f" (from thought {thought.branch_from_thought}, ID: {thought.branch_id})"
|
|
134
|
-
else:
|
|
135
|
-
prefix = "💭 Thought"
|
|
136
|
-
|
|
137
|
-
header = f"{prefix} {thought.thought_number}/{thought.total_thoughts}{context}"
|
|
138
|
-
border = "─" * max(len(header), min(len(thought.thought), 60)) + "────"
|
|
139
|
-
|
|
140
|
-
return f"""
|
|
141
|
-
┌{border}┐
|
|
142
|
-
│ {header.ljust(len(border) - 2)} │
|
|
143
|
-
├{border}┤
|
|
144
|
-
│ {thought.thought[:len(border) - 2].ljust(len(border) - 2)} │
|
|
145
|
-
└{border}┘"""
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
def format_history_text(history: Dict) -> str:
|
|
149
|
-
if not history["history"]:
|
|
150
|
-
return "No thoughts recorded yet."
|
|
151
|
-
|
|
152
|
-
lines = ["=" * 60, "THOUGHT HISTORY", "=" * 60, ""]
|
|
153
|
-
|
|
154
|
-
for t in history["history"]:
|
|
155
|
-
thought = ThoughtData(**t)
|
|
156
|
-
lines.append(format_thought_text(thought))
|
|
157
|
-
|
|
158
|
-
if history["branches"]:
|
|
159
|
-
lines.extend(["", "-" * 60, "BRANCHES:", "-" * 60])
|
|
160
|
-
for branch_id, thoughts in history["branches"].items():
|
|
161
|
-
lines.append(f"\n[{branch_id}]")
|
|
162
|
-
for t in thoughts:
|
|
163
|
-
lines.append(f" Thought {t['thought_number']}: {t['thought'][:50]}...")
|
|
164
|
-
|
|
165
|
-
return "\n".join(lines)
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
# ============================================================================
|
|
169
|
-
# Commands
|
|
170
|
-
# ============================================================================
|
|
171
|
-
|
|
172
|
-
def cmd_think(args) -> None:
|
|
173
|
-
thought = ThoughtData(
|
|
174
|
-
thought=args.thought,
|
|
175
|
-
thought_number=args.thought_number,
|
|
176
|
-
total_thoughts=args.total_thoughts,
|
|
177
|
-
next_thought_needed=not args.no_next,
|
|
178
|
-
is_revision=args.is_revision,
|
|
179
|
-
revises_thought=args.revises_thought,
|
|
180
|
-
branch_from_thought=args.branch_from,
|
|
181
|
-
branch_id=args.branch_id,
|
|
182
|
-
needs_more_thoughts=args.needs_more
|
|
183
|
-
)
|
|
184
|
-
|
|
185
|
-
result = manager.add_thought(thought)
|
|
186
|
-
|
|
187
|
-
# Print formatted thought to stderr for visibility
|
|
188
|
-
if not args.quiet:
|
|
189
|
-
print(format_thought_text(thought), file=sys.stderr)
|
|
190
|
-
|
|
191
|
-
# Output JSON result
|
|
192
|
-
print(json.dumps(result, ensure_ascii=False, indent=2))
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
def cmd_history(args) -> None:
|
|
196
|
-
history = manager.get_history()
|
|
197
|
-
|
|
198
|
-
if args.format == "json":
|
|
199
|
-
print(json.dumps(history, ensure_ascii=False, indent=2))
|
|
200
|
-
else:
|
|
201
|
-
print(format_history_text(history))
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
def cmd_clear(args) -> None:
|
|
205
|
-
result = manager.clear_history()
|
|
206
|
-
print(json.dumps(result, ensure_ascii=False, indent=2))
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
# ============================================================================
|
|
210
|
-
# Main
|
|
211
|
-
# ============================================================================
|
|
212
|
-
|
|
213
|
-
def main():
|
|
214
|
-
parser = argparse.ArgumentParser(
|
|
215
|
-
prog="sequential_think_cli",
|
|
216
|
-
description="Sequential Think CLI - Iterative thinking engine for complex problem-solving"
|
|
217
|
-
)
|
|
218
|
-
|
|
219
|
-
subparsers = parser.add_subparsers(dest="command", required=True)
|
|
220
|
-
|
|
221
|
-
# think command
|
|
222
|
-
p_think = subparsers.add_parser("think", help="Process a thought in the chain")
|
|
223
|
-
p_think.add_argument("--thought", "-t", required=True, help="Current thinking step content")
|
|
224
|
-
p_think.add_argument("--thought-number", "-n", type=int, required=True, help="Current position (1-based)")
|
|
225
|
-
p_think.add_argument("--total-thoughts", "-T", type=int, required=True, help="Estimated total thoughts")
|
|
226
|
-
p_think.add_argument("--no-next", action="store_true", help="Mark as final thought (no more needed)")
|
|
227
|
-
p_think.add_argument("--is-revision", action="store_true", help="This thought revises previous thinking")
|
|
228
|
-
p_think.add_argument("--revises-thought", type=int, help="Which thought number is being reconsidered")
|
|
229
|
-
p_think.add_argument("--branch-from", type=int, help="Branching point thought number")
|
|
230
|
-
p_think.add_argument("--branch-id", help="Identifier for current branch")
|
|
231
|
-
p_think.add_argument("--needs-more", action="store_true", help="Signal more thoughts needed beyond estimate")
|
|
232
|
-
p_think.add_argument("--quiet", "-q", action="store_true", help="Suppress formatted output to stderr")
|
|
233
|
-
|
|
234
|
-
# history command
|
|
235
|
-
p_history = subparsers.add_parser("history", help="View thought history")
|
|
236
|
-
p_history.add_argument("--format", "-f", choices=["json", "text"], default="text", help="Output format")
|
|
237
|
-
|
|
238
|
-
# clear command
|
|
239
|
-
subparsers.add_parser("clear", help="Clear thought history")
|
|
240
|
-
|
|
241
|
-
args = parser.parse_args()
|
|
242
|
-
|
|
243
|
-
commands = {
|
|
244
|
-
"think": cmd_think,
|
|
245
|
-
"history": cmd_history,
|
|
246
|
-
"clear": cmd_clear,
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
commands[args.command](args)
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
if __name__ == "__main__":
|
|
253
|
-
main()
|