proj-track 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.
- package/README.md +253 -0
- package/dist/commands/clear.d.ts +5 -0
- package/dist/commands/clear.d.ts.map +1 -0
- package/dist/commands/clear.js +15 -0
- package/dist/commands/clear.js.map +1 -0
- package/dist/commands/init.d.ts +6 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +57 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/list.d.ts +5 -0
- package/dist/commands/list.d.ts.map +1 -0
- package/dist/commands/list.js +34 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/pause.d.ts +6 -0
- package/dist/commands/pause.d.ts.map +1 -0
- package/dist/commands/pause.js +24 -0
- package/dist/commands/pause.js.map +1 -0
- package/dist/commands/remove.d.ts +7 -0
- package/dist/commands/remove.d.ts.map +1 -0
- package/dist/commands/remove.js +37 -0
- package/dist/commands/remove.js.map +1 -0
- package/dist/commands/resume.d.ts +6 -0
- package/dist/commands/resume.d.ts.map +1 -0
- package/dist/commands/resume.js +24 -0
- package/dist/commands/resume.js.map +1 -0
- package/dist/commands/run.d.ts +5 -0
- package/dist/commands/run.d.ts.map +1 -0
- package/dist/commands/run.js +39 -0
- package/dist/commands/run.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +78 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +8 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +42 -0
- package/dist/logger.js.map +1 -0
- package/dist/utils/file-handler.d.ts +36 -0
- package/dist/utils/file-handler.d.ts.map +1 -0
- package/dist/utils/file-handler.js +97 -0
- package/dist/utils/file-handler.js.map +1 -0
- package/dist/utils/project-detector.d.ts +17 -0
- package/dist/utils/project-detector.d.ts.map +1 -0
- package/dist/utils/project-detector.js +30 -0
- package/dist/utils/project-detector.js.map +1 -0
- package/dist/utils/security-filter.d.ts +10 -0
- package/dist/utils/security-filter.d.ts.map +1 -0
- package/dist/utils/security-filter.js +79 -0
- package/dist/utils/security-filter.js.map +1 -0
- package/dist/utils/shell-installer.d.ts +16 -0
- package/dist/utils/shell-installer.d.ts.map +1 -0
- package/dist/utils/shell-installer.js +232 -0
- package/dist/utils/shell-installer.js.map +1 -0
- package/package.json +78 -0
- package/scripts/preuninstall.js +97 -0
- package/scripts/release.sh +59 -0
- package/src/hooks/bash-hook.sh +67 -0
- package/src/hooks/zsh-hook.sh +54 -0
package/README.md
ADDED
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://img.shields.io/npm/v/proj-track?style=for-the-badge&color=blue&label=proj-track" alt="version" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">proj-track</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<strong>Silently track every terminal command per project — auto-captured, filtered, and instantly replayable.</strong><br/>
|
|
9
|
+
Auto-capture CLI command history per-project with zero terminal interference.
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
<p align="center">
|
|
13
|
+
<img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="license" />
|
|
14
|
+
<img src="https://img.shields.io/badge/node-%3E%3D18-brightgreen" alt="node" />
|
|
15
|
+
<img src="https://img.shields.io/badge/TypeScript-5.x-blue" alt="typescript" />
|
|
16
|
+
<img src="https://img.shields.io/badge/tests-passing-green" alt="tests" />
|
|
17
|
+
<a href="https://codecov.io/gh/Ali-Raza-Arain/proj-track"><img src="https://codecov.io/gh/Ali-Raza-Arain/proj-track/branch/main/graph/badge.svg" alt="codecov" /></a>
|
|
18
|
+
</p>
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## The Problem
|
|
23
|
+
|
|
24
|
+
Your shell history is global. It mixes commands from every project into one giant, unsearchable list. When you switch between projects, you can't remember the exact `docker-compose` flags, the migration command, or the deployment script you used last week.
|
|
25
|
+
|
|
26
|
+
Existing solutions require you to manually type `track "your command"` every time — adding friction to your workflow and guaranteeing you'll forget.
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Why proj-track?
|
|
31
|
+
|
|
32
|
+
- **Zero-config auto-capture** — Commands are captured when you press Enter. No wrapping, no prefixes.
|
|
33
|
+
- **Per-project isolation** — Each project gets its own history in `.proj-track.json`.
|
|
34
|
+
- **Zero terminal interference** — No `[1]+ Done` messages, no broken arrow keys, no Ctrl+C conflicts.
|
|
35
|
+
- **Smart filtering** — Noise commands (cd, ls, clear) and sensitive data (passwords, tokens, API keys) are automatically skipped.
|
|
36
|
+
- **Instant replay** — Re-run any tracked command by its ID.
|
|
37
|
+
- **Bash + Zsh** — Works with both shells out of the box.
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Table of Contents
|
|
42
|
+
|
|
43
|
+
- [How It Works](#how-it-works)
|
|
44
|
+
- [Installation](#installation)
|
|
45
|
+
- [Quick Start](#quick-start)
|
|
46
|
+
- [Commands](#commands)
|
|
47
|
+
- [Smart Filtering](#smart-filtering)
|
|
48
|
+
- [Zero Interference Guarantee](#zero-interference-guarantee)
|
|
49
|
+
- [Data Storage](#data-storage)
|
|
50
|
+
- [Comparison with Alternatives](#comparison-with-alternatives)
|
|
51
|
+
- [Running Tests](#running-tests)
|
|
52
|
+
- [Contributing](#contributing)
|
|
53
|
+
- [Security](#security)
|
|
54
|
+
- [Support](#support)
|
|
55
|
+
- [License](#license)
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## How It Works
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
┌──────────────┐ ┌─────────────────────┐ ┌───────────────────┐
|
|
63
|
+
│ You type a │────>│ Shell hook fires │────>│ Silent logger │
|
|
64
|
+
│ command │ │ (PROMPT_COMMAND / │ │ saves to │
|
|
65
|
+
│ │ │ preexec) │ │ .proj-track.json │
|
|
66
|
+
└──────────────┘ └─────────────────────┘ └───────────────────┘
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
| Shell | Hook | Why |
|
|
70
|
+
| :--- | :--- | :--- |
|
|
71
|
+
| **Bash** | `PROMPT_COMMAND` | Fires AFTER each command, doesn't intercept input |
|
|
72
|
+
| **Zsh** | `preexec` | Native Zsh hook, fires before command execution |
|
|
73
|
+
|
|
74
|
+
**Why not `DEBUG` trap?** The `DEBUG` trap fires on every keystroke/expansion and breaks arrow keys in VS Code Terminal. `PROMPT_COMMAND` only fires once after the command completes — no interference.
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Installation
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
npm install -g proj-track
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## Quick Start
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
# 1. Initialize in your project directory
|
|
90
|
+
cd ~/my-project
|
|
91
|
+
proj-track init
|
|
92
|
+
|
|
93
|
+
# 2. Reload your shell
|
|
94
|
+
source ~/.bashrc # or source ~/.zshrc
|
|
95
|
+
|
|
96
|
+
# 3. Just work normally — commands are captured automatically!
|
|
97
|
+
docker-compose up
|
|
98
|
+
npm run build
|
|
99
|
+
git push origin main
|
|
100
|
+
|
|
101
|
+
# 4. View your history
|
|
102
|
+
proj-track list
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
That's it. No `track "command"` needed. Everything is captured silently in the background.
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## Commands
|
|
110
|
+
|
|
111
|
+
| Command | Alias | Description |
|
|
112
|
+
| :--- | :--- | :--- |
|
|
113
|
+
| `proj-track init` | `tinit` | Initialize tracking in current project |
|
|
114
|
+
| `proj-track list` | `thistory` | Show tracked commands |
|
|
115
|
+
| `proj-track run <id>` | `trun <id>` | Re-run a command by its ID |
|
|
116
|
+
| `proj-track clear` | `tclear` | Clear command history |
|
|
117
|
+
| `proj-track pause` | `tpause` | Pause auto-capture |
|
|
118
|
+
| `proj-track resume` | `tresume` | Resume auto-capture |
|
|
119
|
+
| `proj-track remove` | `tremove` | Remove tracking (saves history as `.txt`) |
|
|
120
|
+
| `proj-track install` | — | Install shell hook to `.bashrc`/`.zshrc` |
|
|
121
|
+
| `proj-track uninstall` | — | Remove shell hook |
|
|
122
|
+
|
|
123
|
+
### Pause / Resume
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
proj-track pause # Stops auto-capture, preserves history
|
|
127
|
+
proj-track resume # Resumes auto-capture
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Remove
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
proj-track remove # Converts history to .proj-track.txt and disables tracking
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## Smart Filtering
|
|
139
|
+
|
|
140
|
+
### Project Detection
|
|
141
|
+
|
|
142
|
+
| Marker | Example |
|
|
143
|
+
| :--- | :--- |
|
|
144
|
+
| `.git/` directory | Any git repository |
|
|
145
|
+
| `package.json` file | Any Node.js project |
|
|
146
|
+
| `.proj-track.json` file | Created via `proj-track init` |
|
|
147
|
+
|
|
148
|
+
If none of these exist, proj-track silently does nothing.
|
|
149
|
+
|
|
150
|
+
### Noise Commands (skipped automatically)
|
|
151
|
+
|
|
152
|
+
`cd`, `ls`, `clear`, `echo`, `cat`, `pwd`, `exit`, `history`, `which`, `whoami`
|
|
153
|
+
|
|
154
|
+
### Sensitive Commands (never saved)
|
|
155
|
+
|
|
156
|
+
- Commands containing `password`, `secret`, `token`, `api_key`, `credential`
|
|
157
|
+
- Inline assignments like `PASSWORD=123 ./run.sh`
|
|
158
|
+
- MySQL password flags (`-p`)
|
|
159
|
+
|
|
160
|
+
### Internal Commands (filtered)
|
|
161
|
+
|
|
162
|
+
- VS Code's `__vsc_*` terminal commands
|
|
163
|
+
- Any `__proj_*` or `__git_*` internal commands
|
|
164
|
+
|
|
165
|
+
### Deduplication
|
|
166
|
+
|
|
167
|
+
Running the same command consecutively only creates one history entry. Maximum 50 commands per project.
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## Zero Interference Guarantee
|
|
172
|
+
|
|
173
|
+
| Concern | How proj-track handles it |
|
|
174
|
+
| :--- | :--- |
|
|
175
|
+
| `[1]+ Done` messages | Background logging uses subshell + `disown` |
|
|
176
|
+
| Arrow keys (up/down/left/right) | Uses `PROMPT_COMMAND`, NOT `DEBUG` trap |
|
|
177
|
+
| Ctrl+C | No signal handlers installed |
|
|
178
|
+
| Ctrl+V | No clipboard interference |
|
|
179
|
+
| Command echoing | Logger suppresses all stdout/stderr |
|
|
180
|
+
| Shell startup time | One function + aliases, minimal overhead |
|
|
181
|
+
| Existing PROMPT_COMMAND | Chains with existing value, doesn't overwrite |
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## Data Storage
|
|
186
|
+
|
|
187
|
+
All data is stored locally in `.proj-track.json` in each project directory:
|
|
188
|
+
|
|
189
|
+
```json
|
|
190
|
+
{
|
|
191
|
+
"projectName": "my-project",
|
|
192
|
+
"commands": [
|
|
193
|
+
{
|
|
194
|
+
"id": 1710864000000,
|
|
195
|
+
"command": "docker-compose up -d",
|
|
196
|
+
"timestamp": "3/19/2026, 8:00:00 PM"
|
|
197
|
+
}
|
|
198
|
+
]
|
|
199
|
+
}
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
No data leaves your machine. No cloud. No telemetry.
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## Comparison with Alternatives
|
|
207
|
+
|
|
208
|
+
| Feature | proj-track | Manual `history \| grep` | Custom bash scripts |
|
|
209
|
+
| :--- | :---: | :---: | :---: |
|
|
210
|
+
| Auto-capture | Yes | No | Varies |
|
|
211
|
+
| Per-project isolation | Yes | No | Manual |
|
|
212
|
+
| Zero terminal interference | Yes | N/A | No |
|
|
213
|
+
| Noise filtering | Yes | No | Manual |
|
|
214
|
+
| Sensitive data filtering | Yes | No | No |
|
|
215
|
+
| Instant replay | Yes | No | No |
|
|
216
|
+
| Bash + Zsh | Yes | Bash only | Varies |
|
|
217
|
+
| No config needed | Yes | N/A | No |
|
|
218
|
+
|
|
219
|
+
For a detailed comparison, see the [docs](https://Ali-Raza-Arain.github.io/proj-track/guide/comparison).
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## Running Tests
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
npm test
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
## Contributing
|
|
232
|
+
|
|
233
|
+
Contributions are welcome! Please read the [Contributing Guide](CONTRIBUTING.md) and follow our [Code of Conduct](CODE_OF_CONDUCT.md).
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## Security
|
|
238
|
+
|
|
239
|
+
To report vulnerabilities, please see our [Security Policy](SECURITY.md).
|
|
240
|
+
|
|
241
|
+
---
|
|
242
|
+
|
|
243
|
+
## Support
|
|
244
|
+
|
|
245
|
+
- [Documentation](https://Ali-Raza-Arain.github.io/proj-track/)
|
|
246
|
+
- [GitHub Issues](https://github.com/Ali-Raza-Arain/proj-track/issues)
|
|
247
|
+
- [Buy Me a Coffee](https://buymeacoffee.com/alirazaarain)
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
## License
|
|
252
|
+
|
|
253
|
+
[MIT](https://opensource.org/licenses/MIT) — Made by [Ali Raza](https://github.com/Ali-Raza-Arain)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clear.d.ts","sourceRoot":"","sources":["../../src/commands/clear.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAQlD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { clearHistory } from '../utils/file-handler.js';
|
|
3
|
+
import { isProjectDirectory } from '../utils/project-detector.js';
|
|
4
|
+
/**
|
|
5
|
+
* Clear all tracked command history for the current project.
|
|
6
|
+
*/
|
|
7
|
+
export async function clearCommand() {
|
|
8
|
+
if (!isProjectDirectory()) {
|
|
9
|
+
console.log(chalk.yellow('Not a project directory.'));
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
clearHistory();
|
|
13
|
+
console.log(chalk.green('✓ Command history cleared.'));
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=clear.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clear.js","sourceRoot":"","sources":["../../src/commands/clear.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAElE;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY;IAChC,IAAI,CAAC,kBAAkB,EAAE,EAAE,CAAC;QAC1B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,0BAA0B,CAAC,CAAC,CAAC;QACtD,OAAO;IACT,CAAC;IAED,YAAY,EAAE,CAAC;IACf,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC,CAAC;AACzD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,wBAAsB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAqDjD"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import { readHistory, writeHistory } from '../utils/file-handler.js';
|
|
5
|
+
import { installShellFunction, isShellFunctionInstalled } from '../utils/shell-installer.js';
|
|
6
|
+
/**
|
|
7
|
+
* Initialize proj-track in the current project.
|
|
8
|
+
* Creates .proj-track.json and installs auto-capture hook if needed.
|
|
9
|
+
*/
|
|
10
|
+
export async function initCommand() {
|
|
11
|
+
const configPath = path.join(process.cwd(), '.proj-track.json');
|
|
12
|
+
if (fs.existsSync(configPath)) {
|
|
13
|
+
console.log(chalk.yellow('proj-track is already initialized in this project.'));
|
|
14
|
+
// Check if hook is missing from shell config
|
|
15
|
+
if (!isShellFunctionInstalled()) {
|
|
16
|
+
console.log(chalk.red(' But the shell hook is NOT installed in your .bashrc/.zshrc!'));
|
|
17
|
+
console.log(chalk.cyan(' Run: ') + chalk.white('proj-track install'));
|
|
18
|
+
}
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
// Check for paused state
|
|
22
|
+
const pausedPath = configPath + '.paused';
|
|
23
|
+
if (fs.existsSync(pausedPath)) {
|
|
24
|
+
console.log(chalk.yellow('proj-track is paused in this project. Use `proj-track resume` to resume.'));
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
// Remove disabled marker if re-initializing after a remove
|
|
28
|
+
const disabledPath = path.join(process.cwd(), '.proj-track-disabled');
|
|
29
|
+
if (fs.existsSync(disabledPath)) {
|
|
30
|
+
fs.unlinkSync(disabledPath);
|
|
31
|
+
}
|
|
32
|
+
// Create initial history file
|
|
33
|
+
const history = readHistory();
|
|
34
|
+
writeHistory(history);
|
|
35
|
+
console.log(chalk.green('✓ proj-track initialized in this project.'));
|
|
36
|
+
console.log(chalk.dim(` Created ${configPath}`));
|
|
37
|
+
// Install shell hook if not already installed
|
|
38
|
+
if (!isShellFunctionInstalled()) {
|
|
39
|
+
const modified = installShellFunction();
|
|
40
|
+
if (modified.length > 0) {
|
|
41
|
+
console.log(chalk.green('✓ Auto-capture hook installed.'));
|
|
42
|
+
modified.forEach(f => console.log(chalk.dim(` Updated ${f}`)));
|
|
43
|
+
console.log('');
|
|
44
|
+
console.log(chalk.cyan('Run the following to activate:'));
|
|
45
|
+
console.log(chalk.white(` source ${modified[0]}`));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
console.log(chalk.dim(' Auto-capture hook already installed.'));
|
|
50
|
+
}
|
|
51
|
+
console.log('');
|
|
52
|
+
console.log(chalk.cyan('Commands are now auto-captured when you press Enter.'));
|
|
53
|
+
console.log(chalk.dim(' proj-track list') + chalk.dim(' — view history'));
|
|
54
|
+
console.log(chalk.dim(' proj-track clear') + chalk.dim(' — clear history'));
|
|
55
|
+
console.log(chalk.dim(' proj-track pause') + chalk.dim(' — pause tracking'));
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AAE7F;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW;IAC/B,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,kBAAkB,CAAC,CAAC;IAEhE,IAAI,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,oDAAoD,CAAC,CAAC,CAAC;QAEhF,6CAA6C;QAC7C,IAAI,CAAC,wBAAwB,EAAE,EAAE,CAAC;YAChC,OAAO,CAA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{ readHistory } from '../utils/file-handler.js';
|
|
3
|
+
import { isProjectDirectory, isTrackingPaused } from '../utils/project-detector.js';
|
|
4
|
+
/**
|
|
5
|
+
* List all tracked commands for the current project.
|
|
6
|
+
*/
|
|
7
|
+
export async function listCommand() {
|
|
8
|
+
if (!isProjectDirectory()) {
|
|
9
|
+
console.log(chalk.yellow('Not a project directory. Run `proj-track init` to enable tracking.'));
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
if (isTrackingPaused()) {
|
|
13
|
+
console.log(chalk.yellow('Tracking is paused. Run `proj-track resume` to resume.'));
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const history = readHistory();
|
|
17
|
+
if (history.commands.length === 0) {
|
|
18
|
+
console.log(chalk.dim('No commands tracked yet.'));
|
|
19
|
+
console.log(chalk.dim('Commands are auto-captured as you work. Try running some commands!'));
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
console.log('');
|
|
23
|
+
console.log(chalk.bold(` Tracked Commands (${history.commands.length})`));
|
|
24
|
+
console.log(chalk.dim(' ID Timestamp Command'));
|
|
25
|
+
console.log(chalk.dim(' ' + '─'.repeat(60)));
|
|
26
|
+
for (const entry of history.commands) {
|
|
27
|
+
const id = chalk.cyan(String(entry.id).padEnd(14));
|
|
28
|
+
const ts = chalk.dim(entry.timestamp.padEnd(22));
|
|
29
|
+
const cmd = chalk.white(entry.command);
|
|
30
|
+
console.log(` ${id}${ts}${cmd}`);
|
|
31
|
+
}
|
|
32
|
+
console.log('');
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../src/commands/list.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,8BAA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AAC,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;QACjD,MAAM,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACvC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,GAAG,EAAE,CAAC,CAAC;IACpC,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pause.d.ts","sourceRoot":"","sources":["../../src/commands/pause.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAkBlD"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
/**
|
|
5
|
+
* Pause tracking in the current project.
|
|
6
|
+
* Renames .proj-track.json → .proj-track.json.paused
|
|
7
|
+
*/
|
|
8
|
+
export async function pauseCommand() {
|
|
9
|
+
const configPath = path.join(process.cwd(), '.proj-track.json');
|
|
10
|
+
const pausedPath = configPath + '.paused';
|
|
11
|
+
if (fs.existsSync(pausedPath)) {
|
|
12
|
+
console.log(chalk.yellow('Tracking is already paused.'));
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (!fs.existsSync(configPath)) {
|
|
16
|
+
console.log(chalk.yellow('No proj-track history found in this project.'));
|
|
17
|
+
console.log(chalk.dim('Run `proj-track init` first.'));
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
fs.renameSync(configPath, pausedPath);
|
|
21
|
+
console.log(chalk.green('✓ Tracking paused.'));
|
|
22
|
+
console.log(chalk.dim(' Run `proj-track resume` to resume tracking.'));
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=pause.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pause.js","sourceRoot":"","sources":["../../src/commands/pause.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY;IAChC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,kBAAkB,CAAC,CAAC;IAChE,MAAM,UAAU,GAAG,UAAU,GAAG,SAAS,CAAC;IAE1C,IAAI,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,6BAA6B,CAAC,CAAC,CAAC;QACzD,OAAO;IACT,CAAC;IAED,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC/B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,8CAA8C,CAAC,CAAC,CAAC;QAC1E,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC,CAAC;QACvD,OAAO;IACT,CAAC;IAED,EAAE,CAAC,UAAU,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IACtC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC,CAAC;IAC/C,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,+CAA+C,CAAC,CAAC,CAAC;AAC1E,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remove proj-track from the current project.
|
|
3
|
+
* Converts .proj-track.json → .proj-track.txt (plain text backup).
|
|
4
|
+
* Creates .proj-track-disabled marker to stop all future capture.
|
|
5
|
+
*/
|
|
6
|
+
export declare function removeCommand(): Promise<void>;
|
|
7
|
+
//# sourceMappingURL=remove.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove.d.ts","sourceRoot":"","sources":["../../src/commands/remove.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,wBAAsB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CA8BnD"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import { convertToTxt } from '../utils/file-handler.js';
|
|
5
|
+
/**
|
|
6
|
+
* Remove proj-track from the current project.
|
|
7
|
+
* Converts .proj-track.json → .proj-track.txt (plain text backup).
|
|
8
|
+
* Creates .proj-track-disabled marker to stop all future capture.
|
|
9
|
+
*/
|
|
10
|
+
export async function removeCommand() {
|
|
11
|
+
const cwd = process.cwd();
|
|
12
|
+
const configPath = path.join(cwd, '.proj-track.json');
|
|
13
|
+
const pausedPath = configPath + '.paused';
|
|
14
|
+
const disabledPath = path.join(cwd, '.proj-track-disabled');
|
|
15
|
+
// Handle paused state — rename back so convertToTxt can read it
|
|
16
|
+
if (fs.existsSync(pausedPath)) {
|
|
17
|
+
fs.renameSync(pausedPath, configPath);
|
|
18
|
+
}
|
|
19
|
+
if (!fs.existsSync(configPath)) {
|
|
20
|
+
// Already removed but maybe they want to ensure it stays disabled
|
|
21
|
+
if (fs.existsSync(disabledPath)) {
|
|
22
|
+
console.log(chalk.yellow('proj-track is already removed from this project.'));
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
console.log(chalk.yellow('No proj-track history found in this project.'));
|
|
26
|
+
}
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
// Convert history to plain text backup
|
|
30
|
+
convertToTxt();
|
|
31
|
+
// Create disabled marker to permanently stop capture in this project
|
|
32
|
+
fs.writeFileSync(disabledPath, `Tracking disabled on ${new Date().toLocaleString()}\nRun "proj-track init" to re-enable.\n`, 'utf-8');
|
|
33
|
+
console.log(chalk.green('✓ proj-track removed from this project.'));
|
|
34
|
+
console.log(chalk.dim(' History saved to .proj-track.txt'));
|
|
35
|
+
console.log(chalk.dim(' Auto-capture stopped. Run `proj-track init` to re-enable.'));
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=remove.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove.js","sourceRoot":"","sources":["../../src/commands/remove.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa;IACjC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAC1B,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,kBAAkB,CAAC,CAAC;IACtD,MAAM,UAAU,GAAG,UAAU,GAAG,SAAS,CAAC;IAC1C,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,sBAAsB,CAAC,CAAC;IAE5D,gEAAgE;IAChE,IAAI,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9B,EAAE,CAAC,UAAU,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IACxC,CAAC;IAED,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC/B,kEAAkE;QAClE,IAAI,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;YAChC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,kDAAkD,CAAC,CAAC,CAAC;QAChF,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,8CAA8C,CAAC,CAAC,CAAC;QAC5E,CAAC;QACD,OAAO;IACT,CAAC;IAED,uCAAuC;IACvC,YAAY,EAAE,CAAC;IAEf,qEAAqE;IACrE,EAAE,CAAC,aAAa,CAAC,YAAY,EAAE,wBAAwB,IAAI,IAAI,EAAE,CAAC,cAAc,EAAE,yCAAyC,EAAE,OAAO,CAAC,CAAC;IAEtI,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,yCAAyC,CAAC,CAAC,CAAC;IACpE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC,CAAC;IAC7D,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,6DAA6D,CAAC,CAAC,CAAC;AACxF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resume.d.ts","sourceRoot":"","sources":["../../src/commands/resume.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,wBAAsB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAgBnD"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
/**
|
|
5
|
+
* Resume tracking in the current project.
|
|
6
|
+
* Renames .proj-track.json.paused → .proj-track.json
|
|
7
|
+
*/
|
|
8
|
+
export async function resumeCommand() {
|
|
9
|
+
const configPath = path.join(process.cwd(), '.proj-track.json');
|
|
10
|
+
const pausedPath = configPath + '.paused';
|
|
11
|
+
if (!fs.existsSync(pausedPath)) {
|
|
12
|
+
if (fs.existsSync(configPath)) {
|
|
13
|
+
console.log(chalk.yellow('Tracking is not paused.'));
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
console.log(chalk.yellow('No proj-track history found in this project.'));
|
|
17
|
+
console.log(chalk.dim('Run `proj-track init` first.'));
|
|
18
|
+
}
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
fs.renameSync(pausedPath, configPath);
|
|
22
|
+
console.log(chalk.green('✓ Tracking resumed.'));
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=resume.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resume.js","sourceRoot":"","sources":["../../src/commands/resume.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa;IACjC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,kBAAkB,CAAC,CAAC;IAChE,MAAM,UAAU,GAAG,UAAU,GAAG,SAAS,CAAC;IAE1C,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC/B,IAAI,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YAC9B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,yBAAyB,CAAC,CAAC,CAAC;QACvD,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,8CAA8C,CAAC,CAAC,CAAC;YAC1E,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC,CAAC;QACzD,CAAC;QACD,OAAO;IACT,CAAC;IAED,EAAE,CAAC,UAAU,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IACtC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/commands/run.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,wBAAsB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAiC7D"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { execSync } from 'node:child_process';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { findCommandById } from '../utils/file-handler.js';
|
|
4
|
+
import { isProjectDirectory } from '../utils/project-detector.js';
|
|
5
|
+
/**
|
|
6
|
+
* Re-run a previously tracked command by its ID.
|
|
7
|
+
*/
|
|
8
|
+
export async function runCommand(idStr) {
|
|
9
|
+
if (!isProjectDirectory()) {
|
|
10
|
+
console.log(chalk.yellow('Not a project directory.'));
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const id = parseInt(idStr, 10);
|
|
14
|
+
if (isNaN(id)) {
|
|
15
|
+
console.log(chalk.red('Invalid command ID. Use `track` to see available commands.'));
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const entry = findCommandById(id);
|
|
19
|
+
if (!entry) {
|
|
20
|
+
console.log(chalk.red(`Command with ID ${id} not found.`));
|
|
21
|
+
console.log(chalk.dim('Use `track` to see available commands.'));
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
console.log(chalk.cyan(`▶ Running: ${entry.command}`));
|
|
25
|
+
console.log('');
|
|
26
|
+
try {
|
|
27
|
+
execSync(entry.command, {
|
|
28
|
+
stdio: 'inherit',
|
|
29
|
+
cwd: process.cwd(),
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
const exitCode = error.status ?? 1;
|
|
34
|
+
console.log('');
|
|
35
|
+
console.log(chalk.red(`Command exited with code ${exitCode}`));
|
|
36
|
+
process.exitCode = exitCode;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=run.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.js","source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