deepflow 0.1.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.
- package/.claude/agents/reasoner.md +60 -0
- package/.claude/commands/df/execute.md +190 -0
- package/.claude/commands/df/plan.md +171 -0
- package/.claude/commands/df/spec.md +99 -0
- package/.claude/commands/df/verify.md +169 -0
- package/.claude/skills/atomic-commits/SKILL.md +64 -0
- package/.claude/skills/code-completeness/SKILL.md +63 -0
- package/.claude/skills/gap-discovery/SKILL.md +45 -0
- package/LICENSE +21 -0
- package/README.md +138 -0
- package/VERSION +1 -0
- package/bin/install.js +187 -0
- package/hooks/df-check-update.js +129 -0
- package/hooks/df-statusline.js +111 -0
- package/package.json +40 -0
- package/templates/config-template.yaml +42 -0
- package/templates/plan-template.md +41 -0
- package/templates/spec-template.md +40 -0
- package/templates/state-template.md +47 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: atomic-commits
|
|
3
|
+
description: Makes atomic commits with clean messages. Use when committing code, implementing tasks, or preparing git history. Ensures one logical change per commit for easy review and rollback.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Atomic Commits
|
|
7
|
+
|
|
8
|
+
One task = one commit. Clean history, easy rollback.
|
|
9
|
+
|
|
10
|
+
## Format
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
{type}({scope}): {description}
|
|
14
|
+
|
|
15
|
+
- {detail}
|
|
16
|
+
- {detail}
|
|
17
|
+
|
|
18
|
+
Task: {id}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Types
|
|
22
|
+
|
|
23
|
+
| Type | Use |
|
|
24
|
+
|------|-----|
|
|
25
|
+
| `feat` | New feature |
|
|
26
|
+
| `fix` | Bug fix |
|
|
27
|
+
| `refactor` | Code change (no behavior change) |
|
|
28
|
+
| `test` | Adding/fixing tests |
|
|
29
|
+
| `docs` | Documentation |
|
|
30
|
+
|
|
31
|
+
### Example
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
feat(image-upload): create upload API endpoint
|
|
35
|
+
|
|
36
|
+
- Add POST /api/upload route
|
|
37
|
+
- Implement multer middleware
|
|
38
|
+
- Add file type validation
|
|
39
|
+
|
|
40
|
+
Task: T1
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Process
|
|
44
|
+
|
|
45
|
+
1. Implement task completely
|
|
46
|
+
2. Verify it works (tests, types, lint)
|
|
47
|
+
3. Stage specific files (`git add {files}`, not `-A`)
|
|
48
|
+
4. Commit with proper format
|
|
49
|
+
5. Return hash
|
|
50
|
+
|
|
51
|
+
## Pre-Commit
|
|
52
|
+
|
|
53
|
+
- [ ] Code runs without errors
|
|
54
|
+
- [ ] No debug logs left
|
|
55
|
+
- [ ] No commented code
|
|
56
|
+
- [ ] No TODO added
|
|
57
|
+
- [ ] Tests pass
|
|
58
|
+
|
|
59
|
+
## Rules
|
|
60
|
+
|
|
61
|
+
- Never commit broken code
|
|
62
|
+
- Never commit partial work
|
|
63
|
+
- Never commit unrelated changes
|
|
64
|
+
- One logical change per commit
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: code-completeness
|
|
3
|
+
description: Finds incomplete code in codebase. Use when analyzing for TODOs, stubs, placeholders, skipped tests, or missing implementations. Helps compare specs against actual code state.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Code Completeness
|
|
7
|
+
|
|
8
|
+
Find incomplete work in codebase.
|
|
9
|
+
|
|
10
|
+
## Explicit Markers
|
|
11
|
+
|
|
12
|
+
| Pattern | Meaning |
|
|
13
|
+
|---------|---------|
|
|
14
|
+
| `TODO` | Planned, not done |
|
|
15
|
+
| `FIXME` | Known broken |
|
|
16
|
+
| `HACK` | Temporary workaround |
|
|
17
|
+
| `XXX` | Needs attention |
|
|
18
|
+
|
|
19
|
+
## Implicit Incompleteness
|
|
20
|
+
|
|
21
|
+
| Pattern | Example |
|
|
22
|
+
|---------|---------|
|
|
23
|
+
| Stub return | `return null`, `return []` |
|
|
24
|
+
| Not implemented | `throw new Error('not implemented')` |
|
|
25
|
+
| Empty body | `function foo() {}` |
|
|
26
|
+
| Hardcoded | `return "test"`, `return 42` |
|
|
27
|
+
|
|
28
|
+
## Test Markers
|
|
29
|
+
|
|
30
|
+
| Pattern | Language |
|
|
31
|
+
|---------|----------|
|
|
32
|
+
| `it.skip`, `test.skip` | JavaScript |
|
|
33
|
+
| `describe.skip` | JavaScript |
|
|
34
|
+
| `@pytest.mark.skip` | Python |
|
|
35
|
+
| `t.Skip()` | Go |
|
|
36
|
+
|
|
37
|
+
## Classification
|
|
38
|
+
|
|
39
|
+
| Status | Criteria | Action |
|
|
40
|
+
|--------|----------|--------|
|
|
41
|
+
| **DONE** | Fully implemented | None |
|
|
42
|
+
| **PARTIAL** | Has TODO/stub | Task to complete |
|
|
43
|
+
| **MISSING** | Not in codebase | Task to create |
|
|
44
|
+
| **CONFLICT** | Contradicts spec | Flag for review |
|
|
45
|
+
|
|
46
|
+
## Report Format
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
REQ-1: {requirement}
|
|
50
|
+
Status: PARTIAL
|
|
51
|
+
Found: src/api/upload.ts:45 — `// TODO: validation`
|
|
52
|
+
Action: Complete validation
|
|
53
|
+
|
|
54
|
+
REQ-2: {requirement}
|
|
55
|
+
Status: MISSING
|
|
56
|
+
Action: Create src/services/storage.ts
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Rules
|
|
60
|
+
|
|
61
|
+
- Search before assuming missing
|
|
62
|
+
- Check test files too
|
|
63
|
+
- Note file:line for findings
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: gap-discovery
|
|
3
|
+
description: Discovers requirement gaps during ideation. Use when user describes features, planning specs, or requirements seem incomplete. Asks clarifying questions about scope, constraints, edge cases, success criteria.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Gap Discovery
|
|
7
|
+
|
|
8
|
+
Proactively identify missing requirements before implementation.
|
|
9
|
+
|
|
10
|
+
## Gap Categories
|
|
11
|
+
|
|
12
|
+
| Category | Example Question |
|
|
13
|
+
|----------|------------------|
|
|
14
|
+
| **Scope** | "Should this handle X, or is that separate?" |
|
|
15
|
+
| **Edge cases** | "What happens if user uploads 50MB file?" |
|
|
16
|
+
| **Constraints** | "Max size? Performance needs? Mobile support?" |
|
|
17
|
+
| **Dependencies** | "Does this need auth? Existing API?" |
|
|
18
|
+
| **Success criteria** | "How will you know this works?" |
|
|
19
|
+
| **Anti-goals** | "What should this explicitly NOT do?" |
|
|
20
|
+
|
|
21
|
+
## Process
|
|
22
|
+
|
|
23
|
+
1. Listen to user's description
|
|
24
|
+
2. Identify categories lacking clarity
|
|
25
|
+
3. Ask 3-5 targeted questions (not overwhelming)
|
|
26
|
+
4. Wait for answers
|
|
27
|
+
5. Follow up if answers reveal new gaps
|
|
28
|
+
6. Signal when ready: "Requirements clear. Ready to proceed."
|
|
29
|
+
|
|
30
|
+
## Question Quality
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
BAD: "Any other requirements?"
|
|
34
|
+
GOOD: "Max file size for uploads?"
|
|
35
|
+
|
|
36
|
+
BAD: "What about errors?"
|
|
37
|
+
GOOD: "If upload fails, retry automatically or show error to user?"
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Rules
|
|
41
|
+
|
|
42
|
+
- Max 5 questions per round
|
|
43
|
+
- Be specific, offer choices when possible
|
|
44
|
+
- Don't assume - ask
|
|
45
|
+
- Stop when gaps are covered
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
```
|
|
2
|
+
_ __ _
|
|
3
|
+
__| | ___ ___ _ __ / _| | _____ __
|
|
4
|
+
/ _` |/ _ \/ _ \ '_ \ | |_| |/ _ \ \ /\ / /
|
|
5
|
+
| (_| | __/ __/ |_) | | _| | (_) \ V V /
|
|
6
|
+
\__,_|\___|\___| .__/ |_| |_|\___/ \_/\_/
|
|
7
|
+
|_|
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
<p align="center">
|
|
11
|
+
<strong>Stay in flow state — spec-driven task orchestration for Claude Code</strong>
|
|
12
|
+
</p>
|
|
13
|
+
|
|
14
|
+
<p align="center">
|
|
15
|
+
<a href="#quick-start">Quick Start</a> •
|
|
16
|
+
<a href="#the-flow">The Flow</a> •
|
|
17
|
+
<a href="#commands">Commands</a> •
|
|
18
|
+
<a href="docs/getting-started.md">Docs</a>
|
|
19
|
+
</p>
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Philosophy
|
|
24
|
+
|
|
25
|
+
- **Stay in flow** — Minimize context switches, maximize deep work
|
|
26
|
+
- **Conversational ideation** with proactive gap discovery
|
|
27
|
+
- **Specs define intent**, tasks close reality gaps
|
|
28
|
+
- **Parallel execution** with dependency awareness
|
|
29
|
+
- **Atomic commits** for clean rollback
|
|
30
|
+
- **Minimal ceremony** — 4 commands, not 27
|
|
31
|
+
|
|
32
|
+
## Quick Start
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# Install
|
|
36
|
+
npx deepflow
|
|
37
|
+
|
|
38
|
+
# In your project
|
|
39
|
+
claude
|
|
40
|
+
|
|
41
|
+
# 1. Discuss what you want to build (conversation)
|
|
42
|
+
# 2. Generate spec when ready
|
|
43
|
+
/df:spec image-upload
|
|
44
|
+
|
|
45
|
+
# 3. Compare specs to code, generate tasks
|
|
46
|
+
/df:plan
|
|
47
|
+
|
|
48
|
+
# 4. Execute tasks with parallel agents
|
|
49
|
+
/df:execute
|
|
50
|
+
|
|
51
|
+
# 5. Verify specs are satisfied
|
|
52
|
+
/df:verify
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## The Flow
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
CONVERSATION
|
|
59
|
+
│ Describe what you want
|
|
60
|
+
│ LLM asks gap questions (scope, edge cases, constraints)
|
|
61
|
+
▼
|
|
62
|
+
/df:spec <name>
|
|
63
|
+
│ Generates specs/{name}.md
|
|
64
|
+
▼
|
|
65
|
+
/df:plan
|
|
66
|
+
│ Compares specs to codebase
|
|
67
|
+
│ Finds TODOs, stubs, missing implementations
|
|
68
|
+
│ Outputs PLAN.md with prioritized tasks
|
|
69
|
+
▼
|
|
70
|
+
/df:execute
|
|
71
|
+
│ Runs tasks respecting dependencies
|
|
72
|
+
│ Parallel for independent tasks
|
|
73
|
+
│ Atomic commit per task
|
|
74
|
+
▼
|
|
75
|
+
/df:verify
|
|
76
|
+
│ Checks spec requirements met
|
|
77
|
+
│ Updates PLAN.md status
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## File Structure
|
|
81
|
+
|
|
82
|
+
After running deepflow, your project will have:
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
your-project/
|
|
86
|
+
├── specs/
|
|
87
|
+
│ ├── feature-a.md
|
|
88
|
+
│ └── feature-b.md
|
|
89
|
+
├── PLAN.md # Task checklist
|
|
90
|
+
└── STATE.md # Decisions & learnings
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Commands
|
|
94
|
+
|
|
95
|
+
| Command | Purpose |
|
|
96
|
+
|---------|---------|
|
|
97
|
+
| `/df:spec <name>` | Generate spec from conversation |
|
|
98
|
+
| `/df:plan` | Compare specs to code, create tasks |
|
|
99
|
+
| `/df:execute` | Run tasks with parallel agents |
|
|
100
|
+
| `/df:verify` | Check specs satisfied |
|
|
101
|
+
|
|
102
|
+
## Configuration
|
|
103
|
+
|
|
104
|
+
Create `.deepflow/config.yaml` in your project:
|
|
105
|
+
|
|
106
|
+
```yaml
|
|
107
|
+
project:
|
|
108
|
+
source_dir: src/
|
|
109
|
+
specs_dir: specs/
|
|
110
|
+
|
|
111
|
+
planning:
|
|
112
|
+
search_patterns:
|
|
113
|
+
- "TODO"
|
|
114
|
+
- "FIXME"
|
|
115
|
+
- "stub"
|
|
116
|
+
- "placeholder"
|
|
117
|
+
|
|
118
|
+
parallelism:
|
|
119
|
+
max_search_agents: 50
|
|
120
|
+
max_write_agents: 5
|
|
121
|
+
|
|
122
|
+
models:
|
|
123
|
+
search: sonnet
|
|
124
|
+
implement: sonnet
|
|
125
|
+
reason: opus
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Principles
|
|
129
|
+
|
|
130
|
+
1. **Stay in flow** — Uninterrupted deep work
|
|
131
|
+
2. **Confirm before assume** — Search code before creating "missing" tasks
|
|
132
|
+
3. **Complete implementations** — No stubs, no placeholders
|
|
133
|
+
4. **Atomic commits** — One task = one commit
|
|
134
|
+
5. **Single writer per file** — Avoid race conditions
|
|
135
|
+
|
|
136
|
+
## License
|
|
137
|
+
|
|
138
|
+
MIT
|
package/VERSION
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.1.0
|
package/bin/install.js
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* deepflow installer
|
|
4
|
+
* Usage: npx deepflow
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
const path = require('path');
|
|
9
|
+
const os = require('os');
|
|
10
|
+
const readline = require('readline');
|
|
11
|
+
|
|
12
|
+
// Colors
|
|
13
|
+
const c = {
|
|
14
|
+
reset: '\x1b[0m',
|
|
15
|
+
green: '\x1b[32m',
|
|
16
|
+
yellow: '\x1b[33m',
|
|
17
|
+
cyan: '\x1b[36m',
|
|
18
|
+
dim: '\x1b[2m'
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// Paths
|
|
22
|
+
const CLAUDE_DIR = path.join(os.homedir(), '.claude');
|
|
23
|
+
const PACKAGE_DIR = path.resolve(__dirname, '..');
|
|
24
|
+
|
|
25
|
+
async function main() {
|
|
26
|
+
console.log('');
|
|
27
|
+
console.log(`${c.cyan}Installing deepflow...${c.reset}`);
|
|
28
|
+
console.log('');
|
|
29
|
+
|
|
30
|
+
// Create directories
|
|
31
|
+
const dirs = [
|
|
32
|
+
'commands/df',
|
|
33
|
+
'skills',
|
|
34
|
+
'agents',
|
|
35
|
+
'hooks',
|
|
36
|
+
'deepflow'
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
for (const dir of dirs) {
|
|
40
|
+
fs.mkdirSync(path.join(CLAUDE_DIR, dir), { recursive: true });
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Copy commands
|
|
44
|
+
copyDir(
|
|
45
|
+
path.join(PACKAGE_DIR, '.claude', 'commands', 'df'),
|
|
46
|
+
path.join(CLAUDE_DIR, 'commands', 'df')
|
|
47
|
+
);
|
|
48
|
+
log('Commands installed');
|
|
49
|
+
|
|
50
|
+
// Copy skills
|
|
51
|
+
copyDir(
|
|
52
|
+
path.join(PACKAGE_DIR, '.claude', 'skills'),
|
|
53
|
+
path.join(CLAUDE_DIR, 'skills')
|
|
54
|
+
);
|
|
55
|
+
log('Skills installed');
|
|
56
|
+
|
|
57
|
+
// Copy agents
|
|
58
|
+
copyDir(
|
|
59
|
+
path.join(PACKAGE_DIR, '.claude', 'agents'),
|
|
60
|
+
path.join(CLAUDE_DIR, 'agents')
|
|
61
|
+
);
|
|
62
|
+
log('Agents installed');
|
|
63
|
+
|
|
64
|
+
// Copy hooks
|
|
65
|
+
const hooksDir = path.join(PACKAGE_DIR, 'hooks');
|
|
66
|
+
if (fs.existsSync(hooksDir)) {
|
|
67
|
+
for (const file of fs.readdirSync(hooksDir)) {
|
|
68
|
+
if (file.endsWith('.js')) {
|
|
69
|
+
fs.copyFileSync(
|
|
70
|
+
path.join(hooksDir, file),
|
|
71
|
+
path.join(CLAUDE_DIR, 'hooks', file)
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
log('Hooks installed');
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Copy VERSION
|
|
79
|
+
const versionFile = path.join(PACKAGE_DIR, 'VERSION');
|
|
80
|
+
if (fs.existsSync(versionFile)) {
|
|
81
|
+
fs.copyFileSync(versionFile, path.join(CLAUDE_DIR, 'deepflow', 'VERSION'));
|
|
82
|
+
log('Version file installed');
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Configure statusline
|
|
86
|
+
await configureStatusline();
|
|
87
|
+
|
|
88
|
+
// Trigger background update check
|
|
89
|
+
const updateChecker = path.join(CLAUDE_DIR, 'hooks', 'df-check-update.js');
|
|
90
|
+
if (fs.existsSync(updateChecker)) {
|
|
91
|
+
const { spawn } = require('child_process');
|
|
92
|
+
const child = spawn(process.execPath, [updateChecker], {
|
|
93
|
+
detached: true,
|
|
94
|
+
stdio: 'ignore'
|
|
95
|
+
});
|
|
96
|
+
child.unref();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
console.log('');
|
|
100
|
+
console.log(`${c.green}Installation complete!${c.reset}`);
|
|
101
|
+
console.log('');
|
|
102
|
+
console.log(`Installed to ${CLAUDE_DIR}:`);
|
|
103
|
+
console.log(' commands/df/ — /df:spec, /df:plan, /df:execute, /df:verify');
|
|
104
|
+
console.log(' skills/ — gap-discovery, atomic-commits, code-completeness');
|
|
105
|
+
console.log(' agents/ — reasoner');
|
|
106
|
+
console.log(' hooks/ — statusline, update checker');
|
|
107
|
+
console.log('');
|
|
108
|
+
console.log('Quick start:');
|
|
109
|
+
console.log(' 1. cd your-project');
|
|
110
|
+
console.log(' 2. claude');
|
|
111
|
+
console.log(' 3. Describe what you want to build');
|
|
112
|
+
console.log(' 4. /df:spec feature-name');
|
|
113
|
+
console.log('');
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function copyDir(src, dest) {
|
|
117
|
+
if (!fs.existsSync(src)) return;
|
|
118
|
+
|
|
119
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
120
|
+
|
|
121
|
+
for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
|
|
122
|
+
const srcPath = path.join(src, entry.name);
|
|
123
|
+
const destPath = path.join(dest, entry.name);
|
|
124
|
+
|
|
125
|
+
if (entry.isDirectory()) {
|
|
126
|
+
copyDir(srcPath, destPath);
|
|
127
|
+
} else {
|
|
128
|
+
fs.copyFileSync(srcPath, destPath);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
async function configureStatusline() {
|
|
134
|
+
const settingsPath = path.join(CLAUDE_DIR, 'settings.json');
|
|
135
|
+
const hookCmd = `node "${path.join(CLAUDE_DIR, 'hooks', 'df-statusline.js')}"`;
|
|
136
|
+
|
|
137
|
+
let settings = {};
|
|
138
|
+
|
|
139
|
+
if (fs.existsSync(settingsPath)) {
|
|
140
|
+
try {
|
|
141
|
+
settings = JSON.parse(fs.readFileSync(settingsPath, 'utf8'));
|
|
142
|
+
} catch (e) {
|
|
143
|
+
settings = {};
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (settings.statusLine) {
|
|
147
|
+
const answer = await ask(
|
|
148
|
+
` ${c.yellow}!${c.reset} Existing statusLine found. Replace with deepflow? [y/N] `
|
|
149
|
+
);
|
|
150
|
+
if (answer.toLowerCase() !== 'y') {
|
|
151
|
+
console.log(` ${c.yellow}!${c.reset} Skipped statusline configuration`);
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
settings.statusLine = {
|
|
158
|
+
type: 'command',
|
|
159
|
+
command: hookCmd
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
|
|
163
|
+
log('Statusline configured');
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function ask(question) {
|
|
167
|
+
const rl = readline.createInterface({
|
|
168
|
+
input: process.stdin,
|
|
169
|
+
output: process.stdout
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
return new Promise(resolve => {
|
|
173
|
+
rl.question(question, answer => {
|
|
174
|
+
rl.close();
|
|
175
|
+
resolve(answer);
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function log(msg) {
|
|
181
|
+
console.log(` ${c.green}✓${c.reset} ${msg}`);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
main().catch(err => {
|
|
185
|
+
console.error('Installation failed:', err.message);
|
|
186
|
+
process.exit(1);
|
|
187
|
+
});
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* deepflow update checker
|
|
4
|
+
* Runs in background, checks npm for newer versions
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const { spawn } = require('child_process');
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
const os = require('os');
|
|
11
|
+
|
|
12
|
+
const PACKAGE_NAME = 'deepflow';
|
|
13
|
+
const CACHE_DIR = path.join(os.homedir(), '.claude', 'cache');
|
|
14
|
+
const CACHE_FILE = path.join(CACHE_DIR, 'df-update-check.json');
|
|
15
|
+
const CHECK_INTERVAL = 24 * 60 * 60 * 1000; // 24 hours
|
|
16
|
+
|
|
17
|
+
// If called directly, spawn background process and exit
|
|
18
|
+
if (process.argv[2] !== '--background') {
|
|
19
|
+
const child = spawn(process.execPath, [__filename, '--background'], {
|
|
20
|
+
detached: true,
|
|
21
|
+
stdio: 'ignore'
|
|
22
|
+
});
|
|
23
|
+
child.unref();
|
|
24
|
+
process.exit(0);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Background process
|
|
28
|
+
async function checkForUpdate() {
|
|
29
|
+
try {
|
|
30
|
+
// Ensure cache directory exists
|
|
31
|
+
if (!fs.existsSync(CACHE_DIR)) {
|
|
32
|
+
fs.mkdirSync(CACHE_DIR, { recursive: true });
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Check if we've checked recently
|
|
36
|
+
if (fs.existsSync(CACHE_FILE)) {
|
|
37
|
+
const cache = JSON.parse(fs.readFileSync(CACHE_FILE, 'utf8'));
|
|
38
|
+
const age = Date.now() - (cache.timestamp || 0);
|
|
39
|
+
if (age < CHECK_INTERVAL) {
|
|
40
|
+
process.exit(0);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Get current version
|
|
45
|
+
const currentVersion = getCurrentVersion();
|
|
46
|
+
if (!currentVersion) {
|
|
47
|
+
process.exit(0);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Get latest version from npm (with timeout)
|
|
51
|
+
const latestVersion = await getLatestVersion();
|
|
52
|
+
if (!latestVersion) {
|
|
53
|
+
process.exit(0);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Compare and cache result
|
|
57
|
+
const updateAvailable = isNewerVersion(latestVersion, currentVersion);
|
|
58
|
+
|
|
59
|
+
const result = {
|
|
60
|
+
updateAvailable,
|
|
61
|
+
currentVersion,
|
|
62
|
+
latestVersion,
|
|
63
|
+
timestamp: Date.now()
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
fs.writeFileSync(CACHE_FILE, JSON.stringify(result, null, 2));
|
|
67
|
+
|
|
68
|
+
} catch (e) {
|
|
69
|
+
// Fail silently
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
process.exit(0);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function getCurrentVersion() {
|
|
76
|
+
// Check deepflow VERSION file
|
|
77
|
+
const dfLocalPath = path.join(process.cwd(), '.claude', 'deepflow', 'VERSION');
|
|
78
|
+
const dfGlobalPath = path.join(os.homedir(), '.claude', 'deepflow', 'VERSION');
|
|
79
|
+
|
|
80
|
+
for (const versionPath of [dfLocalPath, dfGlobalPath]) {
|
|
81
|
+
if (fs.existsSync(versionPath)) {
|
|
82
|
+
return fs.readFileSync(versionPath, 'utf8').trim();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function getLatestVersion() {
|
|
90
|
+
return new Promise((resolve) => {
|
|
91
|
+
const timeout = setTimeout(() => resolve(null), 10000);
|
|
92
|
+
|
|
93
|
+
const child = spawn('npm', ['view', PACKAGE_NAME, 'version'], {
|
|
94
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
95
|
+
shell: true
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
let output = '';
|
|
99
|
+
child.stdout.on('data', data => output += data);
|
|
100
|
+
|
|
101
|
+
child.on('close', (code) => {
|
|
102
|
+
clearTimeout(timeout);
|
|
103
|
+
if (code === 0 && output.trim()) {
|
|
104
|
+
resolve(output.trim());
|
|
105
|
+
} else {
|
|
106
|
+
resolve(null);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
child.on('error', () => {
|
|
111
|
+
clearTimeout(timeout);
|
|
112
|
+
resolve(null);
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function isNewerVersion(latest, current) {
|
|
118
|
+
const latestParts = latest.split('.').map(Number);
|
|
119
|
+
const currentParts = current.split('.').map(Number);
|
|
120
|
+
|
|
121
|
+
for (let i = 0; i < 3; i++) {
|
|
122
|
+
if ((latestParts[i] || 0) > (currentParts[i] || 0)) return true;
|
|
123
|
+
if ((latestParts[i] || 0) < (currentParts[i] || 0)) return false;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
checkForUpdate();
|