@garyr/pt-cli 0.40.0 → 0.41.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/.test-home-remote/.pt/config.yaml +10 -0
- package/README.md +85 -65
- package/dist/commands/initCommand.js +4 -4
- package/dist/commands/learnCommand.js +120 -432
- package/dist/commands/template-detection.js +256 -0
- package/dist/commands/template-prompts.js +332 -0
- package/dist/commands/template-utils.js +565 -0
- package/dist/commands/updateCommand.js +94 -547
- package/dist/config.js +2 -5
- package/dist/safety.js +203 -42
- package/doc/security.md +96 -36
- package/package.json +1 -1
- package/skills/agency-pt-operator/SKILL.md +54 -9
- package/src/commands/initCommand.ts +9 -9
- package/src/commands/learnCommand.ts +157 -423
- package/src/commands/template-detection.ts +269 -0
- package/src/commands/template-prompts.ts +406 -0
- package/src/commands/template-utils.ts +651 -0
- package/src/commands/updateCommand.ts +146 -582
- package/src/config.ts +2 -5
- package/src/safety.ts +239 -53
- package/tests/remote.test.ts +110 -0
- package/tests/safety.test.ts +296 -0
- package/tests/update.test.ts +417 -0
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# pt - Project Template CLI
|
|
2
2
|
|
|
3
|
-
A CLI tool to record directory structures as templates and initialize new projects from them.
|
|
3
|
+
A lightweight, cross-platform CLI tool to record existing directory structures as reusable templates and quickly initialize new projects from them.
|
|
4
4
|
|
|
5
5
|
```mermaid
|
|
6
6
|
graph LR
|
|
@@ -8,14 +8,14 @@ graph LR
|
|
|
8
8
|
Existing[Existing Project]
|
|
9
9
|
Config[(Template Config)]
|
|
10
10
|
end
|
|
11
|
-
|
|
11
|
+
|
|
12
12
|
Engine[[pt-cli]]
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
subgraph Outputs ["Generated Scaffolding"]
|
|
15
15
|
RSA[Replicated Structure A]
|
|
16
16
|
RSB[Replicated Structure B]
|
|
17
17
|
end
|
|
18
|
-
|
|
18
|
+
|
|
19
19
|
%% Flow logic
|
|
20
20
|
Existing -- Learn --> Engine
|
|
21
21
|
Config <-- Read/Write --> Engine
|
|
@@ -23,50 +23,77 @@ graph LR
|
|
|
23
23
|
Engine -- Initialize --> RSB
|
|
24
24
|
|
|
25
25
|
%% Separate the Update logic to avoid crossing lines
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
RSA -. Update .-> Engine
|
|
27
|
+
|
|
28
28
|
style Engine fill:#f9f,stroke:#333,stroke-width:2px,color:#000
|
|
29
|
+
|
|
29
30
|
```
|
|
30
31
|
|
|
31
|
-
|
|
32
|
+
<!-- TOC -->
|
|
33
|
+
|
|
34
|
+
- [pt - Project Template CLI](#pt---project-template-cli)
|
|
35
|
+
- [Why pt-cli?](#why-pt-cli)
|
|
36
|
+
- [Core Benefits & Uses](#core-benefits--uses)
|
|
37
|
+
- [🚀 Low-Friction Templating](#-low-friction-templating)
|
|
38
|
+
- [🧠 Reduces Cognitive Load](#-reduces-cognitive-load)
|
|
39
|
+
- [📦 Sharing is Caring](#-sharing-is-caring)
|
|
40
|
+
- [🤖 Agentic and API Friendly](#-agentic-and-api-friendly)
|
|
41
|
+
- [Features at a Glance](#features-at-a-glance)
|
|
42
|
+
- [Quick Start](#quick-start)
|
|
43
|
+
- [Installation](#installation)
|
|
44
|
+
- [Basic Commands](#basic-commands)
|
|
45
|
+
- [Agent Integration](#agent-integration)
|
|
46
|
+
- [Documentation](#documentation)
|
|
47
|
+
- [Development](#development)
|
|
48
|
+
- [Where are the Templates?](#where-are-the-templates)
|
|
49
|
+
|
|
50
|
+
<!-- /TOC -->
|
|
51
|
+
|
|
52
|
+
## Why pt-cli?
|
|
53
|
+
|
|
54
|
+
Traditional project templating often tightly couples logic and configuration, meaning every new template requires code changes. `pt-cli` breaks that ceiling by separating project definitions from the underlying logic.
|
|
55
|
+
|
|
56
|
+
Instead of writing complex, hard-coded configuration files to scaffold new work, `pt-cli` allows you to **"learn"** from your existing project directories and turn them into templates. It doesn't enforce a specific folder structure; it supports *your* existing patterns.
|
|
57
|
+
|
|
58
|
+
## Core Benefits & Uses
|
|
59
|
+
|
|
60
|
+
### 🚀 Low-Friction Templating
|
|
61
|
+
|
|
62
|
+
Stop recreating folder structures manually or editing shell scripts. `pt learn` saves the exact shape of any existing project. If you have a workspace organized the way you like it, `pt-cli` can help you turn it into a reusable template.
|
|
63
|
+
|
|
64
|
+
### 🧠 Reduces Cognitive Load
|
|
65
|
+
|
|
66
|
+
Standardization is key to lowering the friction of starting new work. By ensuring a predictable architecture, you can rely on downstream automation. When your folder layout is consistent, scripts for tasks like image conversion, generating dailies, or compiling documentation run flawlessly.
|
|
32
67
|
|
|
33
|
-
|
|
68
|
+
### 📦 Sharing is Caring
|
|
69
|
+
|
|
70
|
+
Templates can be exported as plain-text JSON files (`.pt-template.json`). This makes them completely self-describing, easy to share with your team, version control, or pull directly from remote repositories without vendor lock-in.
|
|
71
|
+
|
|
72
|
+
### 🤖 Agentic and API Friendly
|
|
73
|
+
|
|
74
|
+
`pt-cli` fully supports headless operation via non-interactive flags (`--yes`, `--vars`). It includes an official operator skill, allowing AI agents to autonomously lay down standardized boilerplate and capture new architectures you develop together.
|
|
75
|
+
|
|
76
|
+
Prefer a graphical interface, an [official GUI](https://garylritchie.gumroad.com/l/pt-gui) is available.
|
|
34
77
|
|
|
35
|
-
- **Instantly replicating proven architectures:** Stop recreating folder structures manually. `pt learn` saves the shape of any project.
|
|
36
|
-
- **Automating the setup grind:** With post-config tasks, `pt init` can run commands like `npm install`, `git init`, or setup python virtual environments for you.
|
|
37
|
-
- **Global post-config:** Configure shared tasks (e.g. `git init`, `git lfs install`) once in `~/.pt/config.yaml` and have them apply to every new project automatically.
|
|
38
|
-
- **Agentic automation:** Fully supports headless operation via non-interactive flags and includes a skill for integration with AI agents.
|
|
39
|
-
- **File copying & templating:** Beyond directories, it allows injecting variables into key files (`package.json`, `README.md`, etc.) and automatically ports over executable scripts.
|
|
40
78
|
|
|
41
79
|
## Features at a Glance
|
|
42
80
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
- **Parent Directory `.env` File Scanning:** Automatically scans parent directories for `.env` files and uses their values as defaults
|
|
50
|
-
- Auto-detect and suggest post-config setup tasks
|
|
51
|
-
- Configure global post-config tasks in `~/.pt/config.yaml` (apply to all projects)
|
|
52
|
-
- Baked-in defaults for common project types (javascript, python, godot, etc.)
|
|
53
|
-
- Share templates or use as an API with JSON export/import
|
|
54
|
-
- **Direct JSON scaffolding:** Initialize projects from a JSON file without registering in `config.yaml`
|
|
55
|
-
- **Portable template configs:** `.pt-template.json` files make shared directories fully self-describing
|
|
56
|
-
- Fully supports non-interactive mode (`--yes`, `--vars`, `--name`, `--desc`) for AI agent automation
|
|
81
|
+
* **Learn Any Structure:** Learn any directory structure and save it as a reusable template.
|
|
82
|
+
* **Remote Templates:** Learn templates directly from a remote repository or archive URL.
|
|
83
|
+
* **Variable Injection:** Define template variables for dynamic file customization. Automatically scans text files for `{{ var }}` syntax during `learn`/`update`.
|
|
84
|
+
* **Automated Setup:** Auto-detect and suggest post-config setup tasks (e.g., `npm install`, `git init`, Python virtual environments).
|
|
85
|
+
* **Global Configuration:** Configure global post-config tasks in `~/.pt/config.yaml` to apply them to all projects automatically.
|
|
86
|
+
* **Direct Scaffolding:** Initialize projects directly from a JSON file without registering them in your config.
|
|
57
87
|
|
|
58
88
|
## Quick Start
|
|
59
89
|
|
|
60
90
|
### Installation
|
|
61
91
|
|
|
62
92
|
```bash
|
|
63
|
-
npm i @garyr/pt-cli
|
|
64
|
-
|
|
93
|
+
npm i -g @garyr/pt-cli
|
|
65
94
|
# ...or clone this repository, then:
|
|
66
|
-
cd pt-cli
|
|
67
|
-
|
|
68
|
-
npm run build
|
|
69
|
-
npm link
|
|
95
|
+
# cd pt-cli && npm install && npm run build && npm link
|
|
96
|
+
|
|
70
97
|
```
|
|
71
98
|
|
|
72
99
|
### Basic Commands
|
|
@@ -75,10 +102,10 @@ npm link
|
|
|
75
102
|
# Learn an existing local project structure
|
|
76
103
|
pt learn /path/to/PROJECT
|
|
77
104
|
|
|
78
|
-
# Learn a template from a remote repository (GitHub, Gitea, or tarball
|
|
105
|
+
# Learn a template from a remote repository (e.g. GitHub, Gitea, or path to tarball)
|
|
79
106
|
pt learn https://github.com/garyritchie/pt_godot
|
|
80
107
|
|
|
81
|
-
# Scaffold a new project from a template
|
|
108
|
+
# Scaffold a new project from a learned template
|
|
82
109
|
pt init <template_name> /path/to/NEW_PROJECT
|
|
83
110
|
|
|
84
111
|
# List available templates and configurations
|
|
@@ -90,49 +117,42 @@ pt config my-template --json > my-template.json
|
|
|
90
117
|
# Import a template from JSON
|
|
91
118
|
pt add my-new-template --file my-new-template.json
|
|
92
119
|
|
|
93
|
-
# Scaffold directly from a JSON file (no config registration)
|
|
120
|
+
# Scaffold directly from a JSON file (no config registration required)
|
|
94
121
|
pt init ./new-project --file my-template.json --yes
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
## Documentation
|
|
98
|
-
|
|
99
|
-
- [Detailed Usage](doc/usage.md) - Learn, Initialize, Update, and Remove commands.
|
|
100
|
-
- [Configuration Guide](doc/configuration.md) - Template variables, post-config tasks, file copying, and more.
|
|
101
|
-
- [Exclusions](doc/exclusions.md) - Learn about default ignored files and how to set custom patterns.
|
|
102
122
|
|
|
103
|
-
|
|
123
|
+
```
|
|
104
124
|
|
|
105
|
-
|
|
125
|
+
## Agent Integration
|
|
106
126
|
|
|
107
|
-
-
|
|
108
|
-
- `src/commands/`: Individual command handler modules.
|
|
109
|
-
- `src/config.ts`: Configuration loading, saving, and type definitions.
|
|
127
|
+
`pt-cli` is fully compatible with AI agents. By utilizing non-interactive flags (`--yes`, `--vars`, `--name`, `--desc`), agents can autonomously scaffold and learn projects without hanging on interactive terminal prompts.
|
|
110
128
|
|
|
111
|
-
|
|
129
|
+
An official agent skill is included in this repository: [`skills/agency-pt-operator/SKILL.md`](skills/agency-pt-operator/SKILL.md).
|
|
112
130
|
|
|
113
|
-
|
|
114
|
-
- **Development Tooling**: Use `tsx` for running `.ts` files directly (`npm run dev`).
|
|
115
|
-
- **Building**: Use `tsc` to compile to `dist/`.
|
|
131
|
+
Equipping your agent with this skill allows it to automatically use `pt-cli` to construct standardized workspaces and record new architectures as you build them.
|
|
116
132
|
|
|
117
|
-
##
|
|
118
|
-
|
|
119
|
-
`pt-cli` is compatible with AI agents. By utilizing the non-interactive flags (`--yes`, `--vars`, `--name`, `--desc`), agents can autonomously scaffold and learn projects without hanging on interactive terminal prompts.
|
|
133
|
+
## Documentation
|
|
120
134
|
|
|
121
|
-
|
|
135
|
+
* **[Detailed Usage](doc/usage.md)** - Learn, Initialize, Update, and Remove commands.
|
|
136
|
+
* **[Configuration Guide](doc/configuration.md)** - Template variables, post-config tasks, file copying, and more.
|
|
137
|
+
* **[Exclusions](doc/exclusions.md)** - Learn about default ignored files and how to set custom patterns.
|
|
122
138
|
|
|
123
|
-
|
|
139
|
+
## Development
|
|
124
140
|
|
|
125
|
-
|
|
141
|
+
* `src/index.ts`: Entry point and command registration.
|
|
142
|
+
* `src/commands/`: Individual command handler modules.
|
|
143
|
+
* `src/config.ts`: Configuration loading, saving, and type definitions.
|
|
126
144
|
|
|
127
|
-
|
|
145
|
+
**Technical Notes:**
|
|
128
146
|
|
|
129
|
-
|
|
147
|
+
* **ESM Migration:** The project is now pure ESM. All internal imports must use the `.js` extension.
|
|
148
|
+
* **Development Tooling:** Use `tsx` for running `.ts` files directly (`npm run dev`).
|
|
149
|
+
* **Building:** Use `tsc` to compile to `dist/`.
|
|
130
150
|
|
|
131
|
-
|
|
132
|
-
- **Windows**: `%USERPROFILE%\.pt\` (typically `C:\Users\Username\.pt\`)
|
|
151
|
+
## Where are the Templates?
|
|
133
152
|
|
|
134
|
-
|
|
153
|
+
The way you organize your workspace is highly personal. A folder hierarchy that makes perfect sense for a VFX pipeline might look entirely backwards for a company branding project.
|
|
135
154
|
|
|
136
|
-
|
|
155
|
+
Because `pt-cli` is built around flexibility, the app purposefully avoids imposing [strong opinions](https://lyonritchie.com/lab/project-template-cli) or hardcoded structures out of the box. Instead, it empowers you to learn and share exactly what works for your specific needs.
|
|
137
156
|
|
|
138
|
-
[Example
|
|
157
|
+
* **[Example Templates](https://github.com/search?q=topic%3Atemplate-project+org%3Agaryritchie&type=Repositories):** We have provided a few templates based on our own workflows to get you started. These include helpful Python scripts for streamlining common tasks, such as downloading the latest version of Blender or pruning unused folders from a project.
|
|
158
|
+
* **[Share Your Own](https://github.com/garyritchie/pt-cli/discussions):** Have you built a project structure that works perfectly for your niche? Join us in GitHub Discussions to share your templates and see how others are organizing their work.
|
|
@@ -296,16 +296,16 @@ export async function init(targetName, destPath, options = {}) {
|
|
|
296
296
|
}
|
|
297
297
|
else if (options.dryRun) {
|
|
298
298
|
// In dry-run, select all (for display)
|
|
299
|
-
selectedTaskNames = allTasks.map(t => t.command || t.script || '');
|
|
299
|
+
selectedTaskNames = allTasks.map(t => t.command || `./${t.script}` || '');
|
|
300
300
|
console.log(chalk.yellow(`\n[DRY RUN] Applicable post-config tasks:`));
|
|
301
301
|
for (const t of allTasks) {
|
|
302
302
|
const desc = t.description ? ` (${t.description})` : '';
|
|
303
|
-
console.log(chalk.gray(` [template] - ${t.command || t.script}${desc}`));
|
|
303
|
+
console.log(chalk.gray(` [template] - ${t.command || `./${t.script}`}${desc}`));
|
|
304
304
|
}
|
|
305
305
|
}
|
|
306
306
|
else if (options.yes) {
|
|
307
307
|
// All tasks selected
|
|
308
|
-
selectedTaskNames = allTasks.map(t => t.command || t.script || '');
|
|
308
|
+
selectedTaskNames = allTasks.map(t => t.command || `./${t.script}` || '');
|
|
309
309
|
}
|
|
310
310
|
else if (allTasks.length === 0) {
|
|
311
311
|
selectedTaskNames = [];
|
|
@@ -314,7 +314,7 @@ export async function init(targetName, destPath, options = {}) {
|
|
|
314
314
|
// Checkbox prompt
|
|
315
315
|
const choices = [];
|
|
316
316
|
for (const t of allTasks) {
|
|
317
|
-
const cmd = t.command || t.script || '(no command)';
|
|
317
|
+
const cmd = t.command || `./${t.script}` || '(no command)';
|
|
318
318
|
const desc = t.description ? ` (${t.description})` : '';
|
|
319
319
|
choices.push({
|
|
320
320
|
name: `${cmd}${desc}`,
|