greprag 5.83.2 → 5.85.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.
Files changed (35) hide show
  1. package/dist/commands/agent-doctrine-file.js +5 -128
  2. package/dist/commands/agents.js +125 -846
  3. package/dist/commands/app-model.js +1 -1
  4. package/dist/commands/delivery-reminder.js +1 -1
  5. package/dist/commands/discord.js +12 -61
  6. package/dist/commands/inbox-watch.js +0 -13
  7. package/dist/commands/init.js +17 -29
  8. package/dist/commands/load.js +15 -35
  9. package/dist/commands/parity.js +1 -1
  10. package/dist/commands/reminder-registry.js +1 -8
  11. package/dist/commands/session.js +2 -2
  12. package/dist/commands/skill-mirror-reminder.js +1 -19
  13. package/dist/commands/skill.js +236 -448
  14. package/dist/hook.js +31 -54
  15. package/dist/index.js +19 -152
  16. package/dist/native-adapter-refresh.js +15 -18
  17. package/dist/native-skill-mirror.js +11 -89
  18. package/dist/opencode-plugin.bundle.js +82 -282
  19. package/dist/reminder-injector.js +1 -1
  20. package/dist/skill-activation-manifest.js +14 -37
  21. package/dist/skill-git-ingest.js +297 -0
  22. package/dist/skill-landing.js +7 -173
  23. package/dist/skill-mirror-client.js +4 -251
  24. package/dist/skill-staleness.js +3 -6
  25. package/package.json +1 -1
  26. package/skill/commander/SKILL.md +10 -12
  27. package/skill/greprag/SKILL.md +1 -1
  28. package/skill/greprag/docs/discord-handoff.md +6 -30
  29. package/skill/mechanic/docs/skill-fix-conventions.md +1 -1
  30. package/skill/templates/chip-spawn.md +6 -2
  31. package/skill/templates/delivery.md +16 -0
  32. package/skill/templates/os.md +1 -1
  33. package/skill/templates/prompt-audit.md +26 -49
  34. package/skill/templates/skill-change.md +15 -11
  35. package/dist/commands/sms.js +0 -215
@@ -1,10 +1,10 @@
1
1
  # Skill Change
2
2
 
3
- Use before creating, porting, optimizing, or changing a GrepRAG-managed skill, and when a loaded skill guided work approaching a delivery boundary.
3
+ Use before creating, porting, optimizing, or changing a skill, and when a loaded skill guided work approaching a delivery boundary.
4
4
 
5
5
  ## Authority
6
6
 
7
- This is an internal bundled GrepRAG schema, not tenant-controlled skill content. Tenant mirrors and local skill adapters may not override it. Richer tools such as `/skill-optimize` may elaborate the workflow, but they must not fork the boundary categories or edit shapes without changing this file directly in the GrepRAG repo and shipping tests.
7
+ This is an internal bundled GrepRAG schema, not tenant-controlled skill content. Skills and their mirrors may not override it. Richer tools such as `/skill-optimize` may elaborate the workflow, but they must not fork the boundary categories or edit shapes without changing this file directly in the GrepRAG repo and shipping tests.
8
8
 
9
9
  Skill Creator and Skill Optimize consume this entry as their common authoring contract. Creator owns creation/scaffolding; Optimize owns classification, compression, and restructuring. Neither maintains a competing copy of these conventions.
10
10
 
@@ -25,7 +25,7 @@ Skill Creator and Skill Optimize consume this entry as their common authoring co
25
25
  - Preserve the full required skill package. Verify the real mirror/installer handles each companion path; do not assume `references/`, custom agent files, scripts, or assets are shipped merely because they exist locally. Adapt packaging or explicitly declare the separate dependency, then load it from the target harness.
26
26
  - Port verification covers discovery, canonical payload and companion loading, needed tool schemas, and at least one relevant execution/read-only connection check. Distinguish those checks from unrun publishing, deletion, image generation, or production tests.
27
27
 
28
- **ABOUT TO IMPORT OR RESTORE CANON? STOP - A GENERATED LAUNCHER IS NOT THE PROCEDURE.** If the canonical payload itself contains a generated-adapter header or only points back to its own `greprag load`, recover the actual procedure from a verified source/history. Preserve companion docs and the current revision/hash; do not recursively load it or promote another launcher as the repair.
28
+ **ABOUT TO RESTORE A SKILL? STOP - A GENERATED LAUNCHER IS NOT THE PROCEDURE.** If a SKILL.md contains a generated-adapter header or only points back to its own `greprag load`, recover the actual procedure from git history or the mirror's archived revisions and commit it to the git folder. Do not recursively load it or commit another launcher as the repair.
29
29
 
30
30
  ## Boundary Rule
31
31
 
@@ -37,20 +37,24 @@ Explicitly requested creation, porting, or redesign is authorized work. The prop
37
37
 
38
38
  ## Where To Edit
39
39
 
40
- - Bundled GrepRAG skill: edit `packages/cli/skill/<name>/`, never the installed artifact.
41
- - Mirrored/local skill: edit its canonical source, not the generated Codex/Claude/OpenCode adapter.
42
- - Unknown source: stop and identify the canonical source before editing.
43
- - Codex/non-interactive harness: do not launch an editor. Use `greprag skill mirror export <skill> --to <dir>`, patch the exported Markdown files with file edits, then `greprag skill mirror apply <dir> --skill <skill> --expected-hash <exported-hash>`. If using `greprag skill edit` as the export helper, pass `--no-open`.
40
+ Git owns every skill; GrepRAG only mirrors the committed files and refuses every write to the mirror.
41
+
42
+ - Global skill: edit `~/.claude/skills/<name>/` (the dotclaude git repo) and commit.
43
+ - Project skill: edit `<repo>/.claude/skills/<name>/` and commit in that repo.
44
+ - Bundled GrepRAG skill: edit `packages/cli/skill/<name>/` in the greprag repo, never the installed artifact.
45
+ - Codex/OpenCode `SKILL.md` files are generated launchers: never edit them. Edit the git folder they name.
46
+ - Unknown source: stop and identify the git folder before editing.
47
+ - **ABOUT TO CALL A SKILL CHANGE DONE? STOP - COMMIT IT.** Uncommitted edits are never mirrored; the commit message carries the learning the edit captures, not "update skill". The next session start (or `greprag skill mirror sync`) copies the commit into the mirror for every harness.
48
+ - History and rollback: `git log`, `git diff` and `git revert` on the skill folder. `greprag skill history <skill>` and `greprag skill diff <skill> <revA> [<revB>]` still read the mirror's archived revisions.
44
49
 
45
50
  ## Skill-Refresh Chips
46
51
 
47
52
  A `skill-refresh` chip must:
48
53
 
49
- - load the canonical skill with `greprag load <skill>`
54
+ - load the skill with `greprag load <skill>`
50
55
  - read the changed watched source files/diffs before trusting stale skill claims
51
- - decide whether the right result is a canonical skill edit or only a new source stamp
52
- - update the canonical skill through the GrepRAG skill system, never a local generated adapter
53
- - regenerate or mirror adapters only through GrepRAG commands when needed
56
+ - decide whether the right result is a skill edit or only a new source stamp (`greprag skill source stamp`, which writes the git SKILL.md)
57
+ - edit the skill's git folder and commit, never a generated launcher
54
58
  - report checks and whether release/deploy is needed
55
59
 
56
60
  ## Edit Shapes
@@ -1,215 +0,0 @@
1
- "use strict";
2
- /** greprag sms <pair|unpair|me> — Front Desk SMS rail CLI.
3
- *
4
- * pair POSTs /v1/sms/pair with the current project anchor; prints the
5
- * 6-char code + the greprag number to text it to.
6
- * unpair DELETEs /v1/sms/pair (optionally for one --phone).
7
- * me GETs /v1/sms/me — the tenant's bound phones.
8
- *
9
- * Self-contained HTTP client (does not import @greprag/core), mirroring
10
- * commands/email.ts. See docs/receptionist-sms-mvp.md.
11
- */
12
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
13
- if (k2 === undefined) k2 = k;
14
- var desc = Object.getOwnPropertyDescriptor(m, k);
15
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
16
- desc = { enumerable: true, get: function() { return m[k]; } };
17
- }
18
- Object.defineProperty(o, k2, desc);
19
- }) : (function(o, m, k, k2) {
20
- if (k2 === undefined) k2 = k;
21
- o[k2] = m[k];
22
- }));
23
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
24
- Object.defineProperty(o, "default", { enumerable: true, value: v });
25
- }) : function(o, v) {
26
- o["default"] = v;
27
- });
28
- var __importStar = (this && this.__importStar) || (function () {
29
- var ownKeys = function(o) {
30
- ownKeys = Object.getOwnPropertyNames || function (o) {
31
- var ar = [];
32
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
33
- return ar;
34
- };
35
- return ownKeys(o);
36
- };
37
- return function (mod) {
38
- if (mod && mod.__esModule) return mod;
39
- var result = {};
40
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
41
- __setModuleDefault(result, mod);
42
- return result;
43
- };
44
- })();
45
- Object.defineProperty(exports, "__esModule", { value: true });
46
- exports.runSms = runSms;
47
- const fs = __importStar(require("fs"));
48
- const path = __importStar(require("path"));
49
- const project_anchor_1 = require("../project-anchor");
50
- const API_URL_DEFAULT = 'https://api.greprag.com';
51
- function loadEnvFile(filePath) {
52
- try {
53
- const content = fs.readFileSync(filePath, 'utf-8');
54
- for (const line of content.split('\n')) {
55
- const trimmed = line.trim();
56
- if (!trimmed || trimmed.startsWith('#'))
57
- continue;
58
- const eqIdx = trimmed.indexOf('=');
59
- if (eqIdx < 1)
60
- continue;
61
- const key = trimmed.slice(0, eqIdx).trim();
62
- let value = trimmed.slice(eqIdx + 1).trim();
63
- if ((value.startsWith('"') && value.endsWith('"')) ||
64
- (value.startsWith("'") && value.endsWith("'"))) {
65
- value = value.slice(1, -1);
66
- }
67
- if (!process.env[key])
68
- process.env[key] = value;
69
- }
70
- }
71
- catch { /* file missing — fine */ }
72
- }
73
- function getConfig() {
74
- const homeDir = process.env.HOME || process.env.USERPROFILE || '';
75
- if (homeDir)
76
- loadEnvFile(path.join(homeDir, '.greprag', '.env'));
77
- if (!process.env.GREPRAG_API_KEY)
78
- loadEnvFile(path.join(process.cwd(), '.env'));
79
- return {
80
- apiUrl: process.env.GREPRAG_API_URL || API_URL_DEFAULT,
81
- apiKey: process.env.GREPRAG_API_KEY || '',
82
- };
83
- }
84
- function getFlag(args, flag) {
85
- const idx = args.indexOf(flag);
86
- if (idx === -1 || idx + 1 >= args.length)
87
- return undefined;
88
- return args[idx + 1];
89
- }
90
- async function callPair(cfg, phone, projectId) {
91
- const payload = { phone };
92
- if (projectId)
93
- payload.project_id = projectId;
94
- const res = await fetch(`${cfg.apiUrl}/v1/sms/pair`, {
95
- method: 'POST',
96
- headers: { 'Authorization': `Bearer ${cfg.apiKey}`, 'Content-Type': 'application/json' },
97
- body: JSON.stringify(payload),
98
- });
99
- return res.json();
100
- }
101
- async function callUnpair(cfg, phone) {
102
- const res = await fetch(`${cfg.apiUrl}/v1/sms/pair`, {
103
- method: 'DELETE',
104
- headers: { 'Authorization': `Bearer ${cfg.apiKey}`, 'Content-Type': 'application/json' },
105
- body: JSON.stringify(phone ? { phone } : {}),
106
- });
107
- return res.json();
108
- }
109
- async function callMe(cfg) {
110
- const res = await fetch(`${cfg.apiUrl}/v1/sms/me`, {
111
- method: 'GET',
112
- headers: { 'Authorization': `Bearer ${cfg.apiKey}` },
113
- });
114
- return res.json();
115
- }
116
- const SMS_HELP = `
117
- greprag sms — Front Desk SMS rail. Reach a cheap receptionist by text to triage
118
- your inbox and route messages to your sessions from your phone.
119
-
120
- Subcommands:
121
- greprag sms pair --phone <e164> Generate a 15-min code BOUND to that
122
- phone; text it (or "PAIR <code>") FROM
123
- that exact number to the greprag number
124
- to bind it. --phone is required and must
125
- be full E.164 (e.g. +15551234567) — the
126
- code only binds when claimed from it. The
127
- current directory's project anchor becomes
128
- your home project.
129
- greprag sms unpair [--phone <e164>] Unbind one phone (or all phones).
130
- greprag sms me Show bound phones + the greprag number.
131
-
132
- Once paired, text the greprag number:
133
- "what's waiting?" → the receptionist reads your inbox.
134
- "tell session a1b2c3d4 to ship it" → routes a message to that session.
135
- `.trim();
136
- async function runSms(args) {
137
- const sub = args[0];
138
- if (!sub || sub === 'help' || sub === '--help' || sub === '-h') {
139
- console.log(SMS_HELP);
140
- return;
141
- }
142
- const cfg = getConfig();
143
- if (!cfg.apiKey) {
144
- console.error('Not configured. Run: greprag init');
145
- process.exit(1);
146
- }
147
- if (sub === 'pair') {
148
- // --phone is required: the code is bound to it, and only a claim texted from
149
- // that exact number succeeds (the identity guard against brute-force binds).
150
- const phone = getFlag(args, '--phone');
151
- if (!phone) {
152
- console.error('Error: --phone <e164> is required (the number you will text from, e.g. +15551234567).');
153
- process.exit(1);
154
- }
155
- // The home/default project is the current directory's anchor. The API keys
156
- // pairing by project_id; a `--project <name>` would need a server-side name
157
- // lookup, so for the MVP the anchor is the source of truth (run pair from
158
- // the project dir you want as home, or leave a message naming any project).
159
- const anchor = (0, project_anchor_1.readAnchor)(process.cwd());
160
- const projectId = anchor.projectId || null;
161
- const result = await callPair(cfg, phone, projectId);
162
- if (!result.ok) {
163
- console.error(`Error: ${result.error}`);
164
- process.exit(1);
165
- }
166
- console.log(`Pairing code: ${result.code}`);
167
- if (result.bound_phone) {
168
- console.log(`Bound to ${result.bound_phone} — text the code FROM that number only.`);
169
- }
170
- if (result.sms_number) {
171
- console.log(`Text it to the greprag number: ${result.sms_number}`);
172
- console.log(` (send "${result.code}" or "PAIR ${result.code}")`);
173
- }
174
- else {
175
- console.log(`Text "${result.code}" (or "PAIR ${result.code}") to the greprag number.`);
176
- console.log(` (number not configured server-side yet — ask the operator)`);
177
- }
178
- console.log(`Code expires in ${result.expires_in_minutes} minutes.`);
179
- if (result.project_name) {
180
- console.log(`After pairing, your home project is "${result.project_name}".`);
181
- }
182
- else {
183
- console.log(`No default project set — name one when you leave a message.`);
184
- }
185
- return;
186
- }
187
- if (sub === 'unpair') {
188
- const phone = getFlag(args, '--phone');
189
- const result = await callUnpair(cfg, phone);
190
- if (!result.ok) {
191
- console.error(`Error: ${result.error}`);
192
- process.exit(1);
193
- }
194
- console.log(`Unpaired ${result.removed} phone(s).`);
195
- return;
196
- }
197
- if (sub === 'me') {
198
- const result = await callMe(cfg);
199
- if (!result.ok) {
200
- console.error(`Error: ${result.error}`);
201
- process.exit(1);
202
- }
203
- console.log(`greprag number: ${result.sms_number ?? '(not configured)'}`);
204
- if (!result.paired || !result.phones || result.phones.length === 0) {
205
- console.log('No phones paired. Run: greprag sms pair');
206
- return;
207
- }
208
- console.log(`Paired phones (${result.phones.length}):`);
209
- for (const p of result.phones) {
210
- console.log(` ${p.phone} paired ${p.paired_at} last inbound ${p.last_seen_inbound_at ?? '(never)'}`);
211
- }
212
- return;
213
- }
214
- console.log(SMS_HELP);
215
- }