@hivecommons/promptargs 0.6.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/LICENSE +190 -0
- package/README.md +423 -0
- package/dist/autodetect.d.ts +6 -0
- package/dist/autodetect.js +62 -0
- package/dist/autodetect.js.map +1 -0
- package/dist/cli.d.ts +12 -0
- package/dist/cli.js +245 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/loader.d.ts +11 -0
- package/dist/loader.js +36 -0
- package/dist/loader.js.map +1 -0
- package/dist/parser.d.ts +11 -0
- package/dist/parser.js +41 -0
- package/dist/parser.js.map +1 -0
- package/dist/parser.test.d.ts +1 -0
- package/dist/parser.test.js +56 -0
- package/dist/parser.test.js.map +1 -0
- package/dist/resolver.d.ts +10 -0
- package/dist/resolver.js +133 -0
- package/dist/resolver.js.map +1 -0
- package/dist/status.d.ts +9 -0
- package/dist/status.js +22 -0
- package/dist/status.js.map +1 -0
- package/dist/ui.d.ts +1 -0
- package/dist/ui.html +1065 -0
- package/dist/ui.js +85 -0
- package/dist/ui.js.map +1 -0
- package/package.json +51 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding any notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2024 hivecommons Contributors
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
# promptargs 🏴☠️
|
|
2
|
+
|
|
3
|
+
**Template arguments for AI prompts.**
|
|
4
|
+
|
|
5
|
+
You write a prompt with blanks (`{{like_this}}`), and promptargs fills them in.
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
Review {{file}} for {{focus}} issues.
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
becomes...
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
Review src/app.ts for security issues.
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
That's it. That's the whole idea.
|
|
18
|
+
|
|
19
|
+
Works as a **CLI** and as a **skill** in Claude Code, Copilot, Goose, and Bob.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Install
|
|
24
|
+
|
|
25
|
+
### CLI
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install -g @hivecommons/promptargs
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Or just run it without installing:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npx @hivecommons/promptargs help
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### As a Slash Command / Skill
|
|
38
|
+
|
|
39
|
+
This repo ships skill files for multiple AI coding tools. Install the one(s) you use:
|
|
40
|
+
|
|
41
|
+
**Claude Code:**
|
|
42
|
+
```bash
|
|
43
|
+
mkdir -p ~/.claude/commands
|
|
44
|
+
curl -o ~/.claude/commands/promptargs.md \
|
|
45
|
+
https://raw.githubusercontent.com/hivecommons/promptargs/main/.claude/commands/promptargs.md
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
**Goose:**
|
|
49
|
+
```bash
|
|
50
|
+
mkdir -p ~/.config/goose/skills
|
|
51
|
+
curl -o ~/.config/goose/skills/promptargs.md \
|
|
52
|
+
https://raw.githubusercontent.com/hivecommons/promptargs/main/.goose/agents/promptargs.md
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
**Bob (IBM):**
|
|
56
|
+
```bash
|
|
57
|
+
mkdir -p ~/.bob/skills
|
|
58
|
+
curl -o ~/.bob/skills/promptargs.md \
|
|
59
|
+
https://raw.githubusercontent.com/hivecommons/promptargs/main/.bob/skills/promptargs.md
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
**Copilot:** Automatically detected from `.github/copilot-instructions.md` when you clone this repo.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Quick Start (3 steps)
|
|
67
|
+
|
|
68
|
+
### Step 1: Make some templates
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
promptargs init
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
This creates a `.prompts/` folder with 3 starter templates. Done!
|
|
75
|
+
|
|
76
|
+
### Step 2: See what you have
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
promptargs list
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
Available templates:
|
|
84
|
+
|
|
85
|
+
review
|
|
86
|
+
vars: {{file}} {{focus=correctness}} {{tone=concise}}
|
|
87
|
+
|
|
88
|
+
explain
|
|
89
|
+
vars: {{file}} {{style=simple}} {{audience=junior developer}}
|
|
90
|
+
|
|
91
|
+
fix
|
|
92
|
+
vars: {{issue}} {{file}} {{expected}} {{actual}}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Step 3: Use a template
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
promptargs review --file=src/app.ts
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
Review src/app.ts for correctness issues.
|
|
103
|
+
Be concise in your feedback.
|
|
104
|
+
Focus on real bugs, not style nitpicks.
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Variables with `=something` already have a default. Variables without one will ask you to fill them in.
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## How Blanks Work
|
|
112
|
+
|
|
113
|
+
Powered by [Mustache](https://mustache.github.io/) — a logic-less template language available in every major language.
|
|
114
|
+
|
|
115
|
+
A blank looks like this: `{{name}}`
|
|
116
|
+
|
|
117
|
+
A blank with a default looks like this: `{{name=hello}}` (promptargs extension)
|
|
118
|
+
|
|
119
|
+
That's the basics. You also get the full Mustache spec — comments (`{{! ignore me}}`), sections, partials, and more.
|
|
120
|
+
|
|
121
|
+
### Red means "you need to fill this in"
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
promptargs show review
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Shows the template with **red** blanks (required) and **yellow** blanks (has a default).
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## Fill Blanks Your Way
|
|
132
|
+
|
|
133
|
+
### From the command line
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
promptargs review --file=main.go --focus=security --tone=detailed
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Interactively (just run it, it asks you)
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
promptargs review
|
|
143
|
+
file: main.go
|
|
144
|
+
focus: (correctness) ← press Enter to keep default
|
|
145
|
+
tone: detailed
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Inline (no template file needed)
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
promptargs "Explain {{thing}} to a {{audience=5-year-old}}" --thing=recursion
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
```
|
|
155
|
+
Explain recursion to a 5-year-old
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## The Fun Part: Arrays! 🎰
|
|
161
|
+
|
|
162
|
+
Want to review 5 files? Don't run the command 5 times. Use a comma:
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
promptargs review --file=api.go,auth.go,db.go,cache.go,main.go
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
promptargs runs the template **once for each value** and prints each expanded result separated by `---`:
|
|
169
|
+
|
|
170
|
+
```
|
|
171
|
+
Review api.go for correctness issues.
|
|
172
|
+
Be concise in your feedback.
|
|
173
|
+
Focus on real bugs, not style nitpicks.
|
|
174
|
+
---
|
|
175
|
+
Review auth.go for correctness issues.
|
|
176
|
+
Be concise in your feedback.
|
|
177
|
+
Focus on real bugs, not style nitpicks.
|
|
178
|
+
---
|
|
179
|
+
Review db.go for correctness issues.
|
|
180
|
+
...
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Status lines showing iteration progress go to stderr:
|
|
184
|
+
|
|
185
|
+
```
|
|
186
|
+
✅ review [1/5]: file=api.go focus=correctness tone=concise
|
|
187
|
+
✅ review [2/5]: file=auth.go focus=correctness tone=concise
|
|
188
|
+
...
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Three ways to pass arrays
|
|
192
|
+
|
|
193
|
+
| Syntax | What it does |
|
|
194
|
+
|--------|-------------|
|
|
195
|
+
| `--file=a.go,b.go,c.go` | Comma-separated list |
|
|
196
|
+
| `--file="src/*.go"` | Glob pattern (expands to matching files) |
|
|
197
|
+
| `--file=@list.txt` | Reads one value per line from a file |
|
|
198
|
+
|
|
199
|
+
### Multiple arrays: zip vs cross-product
|
|
200
|
+
|
|
201
|
+
**Zip mode (default):** arrays pair up 1:1:
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
promptargs "Review {{file}} for {{focus}}" \
|
|
205
|
+
--file=api.go,auth.go,db.go \
|
|
206
|
+
--focus=security,perf,correctness
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
```
|
|
210
|
+
✅ [1/3]: file=api.go focus=security
|
|
211
|
+
✅ [2/3]: file=auth.go focus=perf
|
|
212
|
+
✅ [3/3]: file=db.go focus=correctness
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
**Cross-product mode (`--cross`):** every combination of every value:
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
promptargs "Review {{file}} for {{focus}}" \
|
|
219
|
+
--file=api.go,auth.go,db.go \
|
|
220
|
+
--focus=security,perf,correctness \
|
|
221
|
+
--cross
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
```
|
|
225
|
+
✅ [1/9]: file=api.go focus=security
|
|
226
|
+
✅ [2/9]: file=api.go focus=perf
|
|
227
|
+
✅ [3/9]: file=api.go focus=correctness
|
|
228
|
+
✅ [4/9]: file=auth.go focus=security
|
|
229
|
+
✅ [5/9]: file=auth.go focus=perf
|
|
230
|
+
✅ [6/9]: file=auth.go focus=correctness
|
|
231
|
+
✅ [7/9]: file=db.go focus=security
|
|
232
|
+
✅ [8/9]: file=db.go focus=perf
|
|
233
|
+
✅ [9/9]: file=db.go focus=correctness
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
3 files × 3 focuses = 9 runs. Use `--cross` when you want the full matrix.
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
## Where Templates Live
|
|
241
|
+
|
|
242
|
+
| Location | What it's for |
|
|
243
|
+
|----------|--------------|
|
|
244
|
+
| `.prompts/` | Your project's templates (commit these!) |
|
|
245
|
+
| `~/.prompts/` | Your personal templates (available everywhere) |
|
|
246
|
+
|
|
247
|
+
Project templates override personal ones with the same name.
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
## Auto-Magic Variables ✨
|
|
252
|
+
|
|
253
|
+
promptargs discovers variables from two sources:
|
|
254
|
+
|
|
255
|
+
### 1. Git context (always detected)
|
|
256
|
+
|
|
257
|
+
These variable names fill themselves automatically when you're in a git repo:
|
|
258
|
+
|
|
259
|
+
| Variable | Auto-fills with |
|
|
260
|
+
|----------|----------------|
|
|
261
|
+
| `{{branch}}` | Current git branch |
|
|
262
|
+
| `{{repo}}` | Repository name |
|
|
263
|
+
| `{{org}}` | GitHub org/user |
|
|
264
|
+
| `{{user}}` | Git config user name |
|
|
265
|
+
| `{{date}}` | Today's date |
|
|
266
|
+
| `{{diff}}` | Staged or unstaged diff |
|
|
267
|
+
| `{{pr}}` | Current PR number |
|
|
268
|
+
|
|
269
|
+
### 2. Terminal environment (any env var)
|
|
270
|
+
|
|
271
|
+
Any environment variable in your terminal is available as a template variable. Use the same name:
|
|
272
|
+
|
|
273
|
+
```bash
|
|
274
|
+
# If your terminal has DATABASE_URL and AWS_REGION set:
|
|
275
|
+
promptargs "Connect to {{DATABASE_URL}} in {{AWS_REGION}}"
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
In the **Builder UI** (`promptargs ui`), click "Show terminal env" to see all available env vars from your shell. Click any one to insert it at the cursor.
|
|
279
|
+
|
|
280
|
+
Common useful env vars: `NODE_ENV`, `AWS_REGION`, `DATABASE_URL`, `GITHUB_TOKEN`, `CI`, `USER`, `EDITOR`, `PATH`.
|
|
281
|
+
|
|
282
|
+
### Priority
|
|
283
|
+
|
|
284
|
+
You can always override any auto-detected value with a flag. The order is:
|
|
285
|
+
|
|
286
|
+
1. `--flag=value` (explicit, always wins)
|
|
287
|
+
2. Interactive prompt (if no flag and not `--no-interactive`)
|
|
288
|
+
3. Auto-detect from environment
|
|
289
|
+
4. Template default (`{{name=fallback}}`)
|
|
290
|
+
|
|
291
|
+
---
|
|
292
|
+
|
|
293
|
+
## Output Formats
|
|
294
|
+
|
|
295
|
+
### Plain text (default)
|
|
296
|
+
|
|
297
|
+
```bash
|
|
298
|
+
promptargs review --file=main.go
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
### JSON
|
|
302
|
+
|
|
303
|
+
```bash
|
|
304
|
+
promptargs review --file=main.go --json
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
### Status line (for IDE integration)
|
|
308
|
+
|
|
309
|
+
```bash
|
|
310
|
+
promptargs review --file=main.go --status
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
```
|
|
314
|
+
✅ review: file=main.go focus=correctness(default) tone=concise(default)
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
---
|
|
318
|
+
|
|
319
|
+
## Builder UI
|
|
320
|
+
|
|
321
|
+
Don't want to memorize flags? Open the visual builder:
|
|
322
|
+
|
|
323
|
+
```bash
|
|
324
|
+
promptargs ui
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
Opens a browser at `http://localhost:3700` with:
|
|
328
|
+
|
|
329
|
+
- **Preset examples** — 8 clickable templates (review, explain, fix, test, migrate, security, docs, refactor)
|
|
330
|
+
- **Template editor** — type your template, variables auto-populate below
|
|
331
|
+
- **Variable table** — set values, arrays (comma-separated), and sources (manual, glob, @file)
|
|
332
|
+
- **Environment panel** — git context vars + all terminal env vars, click any to insert `{{var}}` at cursor
|
|
333
|
+
- **Mustache cheatsheet** — collapsible syntax reference for template features
|
|
334
|
+
- **Zip / Cross toggle** — switch array iteration mode
|
|
335
|
+
- **Live preview** — see expanded output update as you type
|
|
336
|
+
- **CLI command** — copy the generated command with one click
|
|
337
|
+
|
|
338
|
+
Use `--port=N` if 3700 is taken:
|
|
339
|
+
|
|
340
|
+
```bash
|
|
341
|
+
promptargs ui --port=4000
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
---
|
|
345
|
+
|
|
346
|
+
## Write Your Own Template
|
|
347
|
+
|
|
348
|
+
Create a file in `.prompts/` with any name ending in `.md`:
|
|
349
|
+
|
|
350
|
+
**.prompts/buddy.md**
|
|
351
|
+
```
|
|
352
|
+
Hey {{name=buddy}}! Can you help me understand {{topic}}?
|
|
353
|
+
I learn best with {{style=examples and analogies}}.
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
Now use it:
|
|
357
|
+
|
|
358
|
+
```bash
|
|
359
|
+
promptargs buddy --topic="async/await"
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
```
|
|
363
|
+
Hey buddy! Can you help me understand async/await?
|
|
364
|
+
I learn best with examples and analogies.
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
---
|
|
368
|
+
|
|
369
|
+
## Use with AI Coding Tools
|
|
370
|
+
|
|
371
|
+
### Pipe to any CLI
|
|
372
|
+
|
|
373
|
+
promptargs works with any AI tool that accepts piped input:
|
|
374
|
+
|
|
375
|
+
```bash
|
|
376
|
+
# Claude
|
|
377
|
+
promptargs review --file=src/main.ts --no-interactive | claude -p "do this review"
|
|
378
|
+
|
|
379
|
+
# Goose
|
|
380
|
+
promptargs review --file=src/main.ts --no-interactive | goose run
|
|
381
|
+
|
|
382
|
+
# Copilot
|
|
383
|
+
promptargs review --file=src/main.ts --no-interactive | gh copilot explain
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
### As a skill inside your AI tool
|
|
387
|
+
|
|
388
|
+
If you installed the skill (see [Install](#as-a-skill)), use it directly inside your session:
|
|
389
|
+
|
|
390
|
+
**Claude Code:**
|
|
391
|
+
```
|
|
392
|
+
/promptargs review --file=src/api.ts
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
**Goose / Bob:** The skill is automatically available after install — ask your agent to "use promptargs" or run a template.
|
|
396
|
+
|
|
397
|
+
**Copilot:** The instructions in `.github/copilot-instructions.md` teach Copilot about promptargs when you're in a repo that has it.
|
|
398
|
+
|
|
399
|
+
---
|
|
400
|
+
|
|
401
|
+
## Cheat Sheet
|
|
402
|
+
|
|
403
|
+
| Command | What it does |
|
|
404
|
+
|---------|-------------|
|
|
405
|
+
| `promptargs ui` | Open the visual builder in your browser |
|
|
406
|
+
| `promptargs init` | Create `.prompts/` with examples |
|
|
407
|
+
| `promptargs list` | Show all available templates |
|
|
408
|
+
| `promptargs show review` | Preview template with highlighted blanks |
|
|
409
|
+
| `promptargs review --file=x` | Run template with flags |
|
|
410
|
+
| `promptargs review` | Run template interactively |
|
|
411
|
+
| `promptargs "inline {{var}}"` | Use inline template |
|
|
412
|
+
| `--no-interactive` | Skip questions, use defaults only |
|
|
413
|
+
| `--cross` | Cross-product mode (all combinations) |
|
|
414
|
+
| `--json` | Output as JSON |
|
|
415
|
+
| `--status` | Output status line only |
|
|
416
|
+
| `... \| claude -p "do this"` | Pipe to Claude |
|
|
417
|
+
| `... \| goose run` | Pipe to Goose |
|
|
418
|
+
|
|
419
|
+
---
|
|
420
|
+
|
|
421
|
+
## License
|
|
422
|
+
|
|
423
|
+
Apache-2.0
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-detect variable values from the current environment.
|
|
3
|
+
*/
|
|
4
|
+
export declare const AUTODETECT_VARS: string[];
|
|
5
|
+
export declare function autodetect(varName: string): string | undefined;
|
|
6
|
+
export declare function autodetectAll(varNames: string[]): Record<string, string>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-detect variable values from the current environment.
|
|
3
|
+
*/
|
|
4
|
+
import { execSync } from 'node:child_process';
|
|
5
|
+
function git(cmd) {
|
|
6
|
+
try {
|
|
7
|
+
return execSync(`git ${cmd}`, { encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe'] }).trim();
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
const DETECTORS = {
|
|
14
|
+
branch: () => git('branch --show-current'),
|
|
15
|
+
repo: () => {
|
|
16
|
+
const remote = git('remote get-url origin');
|
|
17
|
+
if (!remote)
|
|
18
|
+
return undefined;
|
|
19
|
+
const match = remote.match(/\/([^/]+?)(?:\.git)?$/);
|
|
20
|
+
return match?.[1];
|
|
21
|
+
},
|
|
22
|
+
org: () => {
|
|
23
|
+
const remote = git('remote get-url origin');
|
|
24
|
+
if (!remote)
|
|
25
|
+
return undefined;
|
|
26
|
+
const match = remote.match(/[/:]([\w.-]+)\/[\w.-]+?(?:\.git)?$/);
|
|
27
|
+
return match?.[1];
|
|
28
|
+
},
|
|
29
|
+
diff: () => git('diff --staged') || git('diff'),
|
|
30
|
+
pr: () => {
|
|
31
|
+
try {
|
|
32
|
+
const out = execSync('gh pr view --json number --jq .number', {
|
|
33
|
+
encoding: 'utf8',
|
|
34
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
35
|
+
}).trim();
|
|
36
|
+
return out || undefined;
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
user: () => git('config user.name'),
|
|
43
|
+
date: () => new Date().toISOString().split('T')[0],
|
|
44
|
+
};
|
|
45
|
+
export const AUTODETECT_VARS = Object.keys(DETECTORS);
|
|
46
|
+
export function autodetect(varName) {
|
|
47
|
+
const detector = DETECTORS[varName];
|
|
48
|
+
if (detector)
|
|
49
|
+
return detector();
|
|
50
|
+
// Fall back to terminal environment variables
|
|
51
|
+
return process.env[varName] ?? undefined;
|
|
52
|
+
}
|
|
53
|
+
export function autodetectAll(varNames) {
|
|
54
|
+
const result = {};
|
|
55
|
+
for (const name of varNames) {
|
|
56
|
+
const value = autodetect(name);
|
|
57
|
+
if (value !== undefined)
|
|
58
|
+
result[name] = value;
|
|
59
|
+
}
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=autodetect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autodetect.js","sourceRoot":"","sources":["../src/autodetect.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,SAAS,GAAG,CAAC,GAAW;IACtB,IAAI,CAAC;QACH,OAAO,QAAQ,CAAC,OAAO,GAAG,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAC9F,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,MAAM,SAAS,GAA6C;IAC1D,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,uBAAuB,CAAC;IAC1C,IAAI,EAAE,GAAG,EAAE;QACT,MAAM,MAAM,GAAG,GAAG,CAAC,uBAAuB,CAAC,CAAC;QAC5C,IAAI,CAAC,MAAM;YAAE,OAAO,SAAS,CAAC;QAC9B,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;QACpD,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;IACD,GAAG,EAAE,GAAG,EAAE;QACR,MAAM,MAAM,GAAG,GAAG,CAAC,uBAAuB,CAAC,CAAC;QAC5C,IAAI,CAAC,MAAM;YAAE,OAAO,SAAS,CAAC;QAC9B,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAC;QACjE,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;IACD,IAAI,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC;IAC/C,EAAE,EAAE,GAAG,EAAE;QACP,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,QAAQ,CAAC,uCAAuC,EAAE;gBAC5D,QAAQ,EAAE,MAAM;gBAChB,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;aAChC,CAAC,CAAC,IAAI,EAAE,CAAC;YACV,OAAO,GAAG,IAAI,SAAS,CAAC;QAC1B,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;IACD,IAAI,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,kBAAkB,CAAC;IACnC,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACnD,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AAEtD,MAAM,UAAU,UAAU,CAAC,OAAe;IACxC,MAAM,QAAQ,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;IACpC,IAAI,QAAQ;QAAE,OAAO,QAAQ,EAAE,CAAC;IAChC,8CAA8C;IAC9C,OAAO,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,SAAS,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,QAAkB;IAC9C,MAAM,MAAM,GAA2B,EAAE,CAAC;IAC1C,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;QAC5B,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;QAC/B,IAAI,KAAK,KAAK,SAAS;YAAE,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;IAChD,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* promptargs CLI — Template arguments for AI prompts.
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* promptargs <template> # interactive mode
|
|
7
|
+
* promptargs <template> --var=value # fill from flags
|
|
8
|
+
* promptargs list # show available templates
|
|
9
|
+
* promptargs init # create .prompts/ with examples
|
|
10
|
+
* promptargs show <template> # show template with vars highlighted
|
|
11
|
+
*/
|
|
12
|
+
export {};
|