@varman96/paper 1.0.0 → 1.0.2
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 +31 -120
- package/dist/paper.js +12 -12
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,148 +1,59 @@
|
|
|
1
1
|
# Paper
|
|
2
2
|
|
|
3
|
-
Paper
|
|
3
|
+
Paper captures command failures in a structured Incident Report for coding-agent investigation.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
GitHub: https://github.com/varman96/paper
|
|
6
|
+
npm: https://www.npmjs.com/package/@varman96/paper
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
Primary workflow: Install -> Capture -> Ask.
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
- **Investigative Incident Report**: Orders runtime evidence through Scope, Delta, Failure Boundary, Execution Path, Evidence, falsified hypotheses, a supported working hypothesis, and the next test.
|
|
11
|
-
- **Copy for AI**: Generates the packet locally in the browser and copies it for use in the AI coding tool of your choice.
|
|
12
|
-
- **Note Management**: Create, delete, switch between notes, and clear sample notes. Notes auto-save to browser local storage.
|
|
13
|
-
- **Markdown Export**: Export notes directly to `.md` files.
|
|
14
|
-
- **Local-first workflow**: The packet builder does not require an AI call or backend persistence.
|
|
10
|
+
## Install
|
|
15
11
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
## System Architecture
|
|
19
|
-
|
|
20
|
-
Paper consists of a static client-side application and API endpoints deployed through a Cloudflare Worker with static assets. The public landing page is served at `/`, and the packet builder is served at `/app/`.
|
|
21
|
-
|
|
22
|
-
```
|
|
23
|
-
paper/
|
|
24
|
-
├── index.html # Public landing page
|
|
25
|
-
├── app/
|
|
26
|
-
│ └── index.html # Manual packet fallback shell served at /app/
|
|
27
|
-
├── styles.css # Application styling
|
|
28
|
-
├── app.js # Application entry point and module coordination
|
|
29
|
-
├── js/
|
|
30
|
-
│ ├── debug-packet.js # Shared canonical packet schema and Markdown generator
|
|
31
|
-
│ ├── state.js # Central application state and getters
|
|
32
|
-
│ ├── storage.js # LocalStorage persistence and note schema creation
|
|
33
|
-
│ ├── editor.js # Block editor management, input handling, and character caps
|
|
34
|
-
│ ├── formatting.js # Selection toolbar and inline formatting commands
|
|
35
|
-
│ ├── manual/
|
|
36
|
-
│ │ └── debug-packet.js # Retained manual fallback packet UI logic
|
|
37
|
-
│ ├── notes.js # Note list management, title derivation, and export
|
|
38
|
-
│ ├── mobile.js # Mobile navigation drawer and responsive panels
|
|
39
|
-
│ └── utils.js # HTML sanitization and string helpers
|
|
40
|
-
├── legacy/
|
|
41
|
-
│ └── review/
|
|
42
|
-
│ ├── review.js # Dormant legacy Review coordination
|
|
43
|
-
│ └── critique-ui.js # Dormant legacy Review rendering
|
|
44
|
-
├── scripts/
|
|
45
|
-
│ ├── build-assets.js # Builds the root + /app/ static asset layout
|
|
46
|
-
│ └── paper.js # Local stdin CLI ingestion and deterministic extraction
|
|
47
|
-
├── .paper/
|
|
48
|
-
│ └── incident_report.md # Canonical investigative report template
|
|
49
|
-
├── worker.js # Routes /api/* before static assets
|
|
50
|
-
└── api/
|
|
51
|
-
└── lib/
|
|
52
|
-
├── gemini.js # Gemini API client with retry logic
|
|
53
|
-
├── rate-limit.js # Sliding-window IP rate limiter
|
|
54
|
-
├── review-prompt.js# System and user prompt construction
|
|
55
|
-
└── review-schema.js# Input normalization and response parsing
|
|
12
|
+
```bash
|
|
13
|
+
npm install -g @varman96/paper
|
|
56
14
|
```
|
|
57
15
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
---
|
|
61
|
-
|
|
62
|
-
## How It Works
|
|
63
|
-
|
|
64
|
-
### 1. Document Editing and Storage
|
|
16
|
+
## Use
|
|
65
17
|
|
|
66
|
-
|
|
67
|
-
- Notes are stored in the browser's `localStorage` under the key `paper.notes.v1`.
|
|
68
|
-
- The document title is automatically inferred from the first line of text unless manually modified by the user.
|
|
69
|
-
- Document editing and storage do not impose an AI-driven character limit.
|
|
70
|
-
|
|
71
|
-
### 2. The Incident Report Workflow
|
|
72
|
-
|
|
73
|
-
1. **Capture**: Collect runtime evidence in the CLI, incident template, or manual fallback.
|
|
74
|
-
2. **Structure**: Organize it in investigative order from Scope through Next Test.
|
|
75
|
-
3. **Generate Markdown**: Generate one deterministic packet locally.
|
|
76
|
-
4. **Copy for AI**: Copy the packet into Claude, Cursor, Codex, ChatGPT, or Gemini.
|
|
77
|
-
|
|
78
|
-
### 3. Terminal-first prototype
|
|
79
|
-
|
|
80
|
-
The local prototype accepts stdin and emits the same deterministic packet format without making model, backend, or network calls:
|
|
18
|
+
Run the command that is failing:
|
|
81
19
|
|
|
82
20
|
```bash
|
|
83
|
-
|
|
21
|
+
paper run <command>
|
|
84
22
|
```
|
|
85
23
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
### 4. Retired sharing
|
|
89
|
-
|
|
90
|
-
Document sharing is not part of the active application. The historical implementation is preserved under `legacy/sharing/` for reference and emergency recovery only; it must not be imported or published as an asset. Old share fragments are ignored and `/api/share` returns the normal unknown-API 404.
|
|
91
|
-
|
|
92
|
-
---
|
|
24
|
+
Paper runs the command normally. If it fails, Paper writes the captured evidence to `.paper/incident_report.md`.
|
|
93
25
|
|
|
94
|
-
|
|
26
|
+
Ask your coding agent:
|
|
95
27
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
## Running Locally
|
|
101
|
-
|
|
102
|
-
To run Paper locally with functional API routes:
|
|
103
|
-
|
|
104
|
-
1. Configure `.dev.vars` with the required local secrets.
|
|
105
|
-
|
|
106
|
-
2. Start the existing Cloudflare development server:
|
|
107
|
-
|
|
108
|
-
```bash
|
|
109
|
-
npx.cmd wrangler dev
|
|
110
|
-
```
|
|
28
|
+
```text
|
|
29
|
+
Diagnose the current failure.
|
|
30
|
+
```
|
|
111
31
|
|
|
112
|
-
|
|
32
|
+
The active Incident Report gives supported coding agents an evidence anchor, so you do not need to reconstruct the failure context.
|
|
113
33
|
|
|
114
|
-
For
|
|
34
|
+
For a resolved incident, move the active report out of the workspace:
|
|
115
35
|
|
|
116
36
|
```bash
|
|
117
|
-
|
|
37
|
+
paper shelf
|
|
118
38
|
```
|
|
119
39
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
## Issuing an Alpha Access Link
|
|
123
|
-
|
|
124
|
-
Use the trusted local issuer for a manually approved tester. It requires only an operator label and defaults to production D1 and `https://paper-ai.paperhq.workers.dev`:
|
|
40
|
+
## Commands
|
|
125
41
|
|
|
126
42
|
```bash
|
|
127
|
-
|
|
43
|
+
paper run <command>
|
|
44
|
+
paper shelf
|
|
45
|
+
paper --help
|
|
46
|
+
paper --version
|
|
128
47
|
```
|
|
129
48
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
When diagnosing an operational failure, consult the repository's [observed operator error reference](docs/operator-errors.md) before changing the Alpha access implementation.
|
|
133
|
-
|
|
134
|
-
**CJ Protocol** is the pre-send production verification gate: an invite URL is released only after the production Worker confirms that the exact invite is currently redeemable without consuming it. The issuer sends the exact token and returned credential ID to the Worker's same-origin verification route, where the token is hashed and checked through the same active-state validation used before redemption. Only a `204` response writes the complete private URL to stdout. Progress and diagnostics go to stderr, so failed verification leaves stdout empty. Send the URL directly to the tester; do not open it for them or paste it into logs or tickets. It contains a cryptographically random token, with only its hash stored in D1. No email, signup row, Turnstile, or email delivery is involved in manual issuance.
|
|
135
|
-
|
|
136
|
-
Invites expire after **24 hours** and are atomically single-use. The tester clicks **Open Paper** in their chosen browser; merely loading the invitation page does not consume it. Successful redemption creates the existing secure, HttpOnly, SameSite=Lax 30-day session. An already-authorized browser resumes `/app/` without consuming another invitation. Other browsers need their own fresh invite. Re-run the issuer for a replacement if required; it does not revoke existing sessions.
|
|
137
|
-
|
|
138
|
-
### Release prerequisite
|
|
139
|
-
|
|
140
|
-
Before issuing access to an untrusted tester, follow [Alpha security operations](docs/alpha-security-operations.md): credential-level revocation, migration `0003`, required durable Review ceilings, and production/legacy deployment checks. The issuer prints the credential ID to stderr for operator records; retain it without the bearer link. `npm.cmd run alpha:revoke -- --credential-id <id>` invalidates both the invite and its derived session and confirms the exact row. Labels are not unique identifiers.
|
|
141
|
-
|
|
142
|
-
Before the first label-only production invite, apply `migrations/0002_manual_alpha_invites.sql` through the normal D1 migration workflow, then deploy the matching Worker and assets. The migration rebuilds only the credential child table to permit a label in place of a signup reference, preserving existing credentials and sessions. The new Worker, including `/api/alpha/invite/verify`, must be live before using the updated issuer; an older deployment will make verification fail closed and release no link. Applying this migration or deploying is a separate, explicitly authorized release step.
|
|
49
|
+
## How it works
|
|
143
50
|
|
|
144
|
-
|
|
51
|
+
- Local CLI for capturing failed-command evidence.
|
|
52
|
+
- Structured Incident Report at `.paper/incident_report.md`.
|
|
53
|
+
- Evidence anchor for coding-agent investigation.
|
|
54
|
+
- No model API calls.
|
|
55
|
+
- No command-output upload.
|
|
145
56
|
|
|
146
|
-
|
|
57
|
+
## License
|
|
147
58
|
|
|
148
|
-
|
|
59
|
+
PolyForm Shield License 1.0.0
|
package/dist/paper.js
CHANGED
|
@@ -9,7 +9,7 @@ ${s.join(`
|
|
|
9
9
|
|
|
10
10
|
${t.join(`
|
|
11
11
|
|
|
12
|
-
`)}`:""}`}var T={name:"@varman96/paper",version:"1.0.
|
|
12
|
+
`)}`:""}`}var T={name:"@varman96/paper",version:"1.0.2",description:"Paper captures command failures in a structured Incident Report for coding-agent investigation.",main:"dist/paper.js",bin:{paper:"./dist/paper.js"},files:["dist/paper.js","README.md","LICENSE"],directories:{test:"test"},scripts:{"alpha:issue":"node scripts/issue-alpha-access.js","alpha:revoke":"node scripts/revoke-alpha-access.js","fail:test":"node scripts/fail-test.js",paper:"node scripts/paper.js","build:cli":"node scripts/build-cli.js",prepack:"npm run build:cli","deploy:production":"wrangler deploy --env production",test:"node test/run-tests.js","test:fast":"node test/run-tests.js --fast","test:browser":"node test/run-tests.js --browser","test:alpha-browser":"node test/alpha-access.browser.js"},repository:{type:"git",url:"git+https://github.com/varman96/paper.git"},keywords:[],author:"",license:"SEE LICENSE IN LICENSE",type:"module",bugs:{url:"https://github.com/varman96/paper/issues"},homepage:"https://paper-ai.paperhq.workers.dev/",devDependencies:{"@biomejs/biome":"2.5.14",esbuild:"^0.28.1",wrangler:"^4.132.0"}};var J=`Paper captures a failed command and writes a local Incident Report.
|
|
13
13
|
|
|
14
14
|
Usage: paper run <command>
|
|
15
15
|
|
|
@@ -22,15 +22,15 @@ Report: .paper/incident_report.md
|
|
|
22
22
|
paper shelf Move the active Incident Report out of the workspace
|
|
23
23
|
|
|
24
24
|
--help Show this help
|
|
25
|
-
--version Show the version`,
|
|
25
|
+
--version Show the version`,b=["<!-- paper:start -->","## Paper Incident Workflow","","When `.paper/incident_report.md` exists, read it before investigating.","","Treat the Incident Report as the current evidence anchor, not as infallible truth. Use it to establish the known failure boundary, then inspect the repository, runtime, tests, configuration, and other source-of-truth evidence as needed.","","Diagnose the issue using this trace:","","### 1. Establish the Failing Invariant","","Identify the exact boundary contract that was violated.","","State:","","Invariant Expected:","The concrete behavior or state that should have held.","","Invariant Observed:","The concrete behavior or state actually observed.","","Use precise system evidence where available:","- exit codes","- status codes","- errno","- ports","- file paths","- symbols","- stack frames","- environment values","- process state","- exact command output","","Do not replace concrete evidence with vague summaries.","","### 2. State Elimination","","Shrink the search space by explicitly ruling out competing explanations using verified evidence.","","For each relevant factor, state whether it is:","- confirmed working","- confirmed failing","- still unverified","","Examples:","- config parsed successfully","- network route reachable","- dependency present or missing","- process listening or not listening","- expected environment variable present or absent","","Do not mark a hypothesis ruled out without evidence.","","Do not repeat theories already ruled out by the Incident Report unless new evidence justifies reopening them.","","### 3. Single-Point Attribution","","Narrow the diagnosis to the smallest confirmed fault boundary.","","State:","","Fault Location:","The exact file, line, symbol, process, dependency, configuration value, environment delta, or runtime boundary responsible.","","Mechanism:","The concrete way that fault caused the observed invariant violation.","","Do not invent a root cause if the evidence only supports a narrower failure boundary.","","If the mechanism is not yet verified, label it as unverified and continue investigating.","","Newer source-of-truth evidence overrides stale or incorrect Incident Report content.","","### 4. Proposed Action Packet \u2014 Zero Execution","","Once the failure is sufficiently explained, STOP before remediation.","","Do not:","- modify files","- start or stop services","- change configuration","- install dependencies","- run a fix","- apply a patch","- mutate the environment","","unless the user explicitly asked for remediation.","","Report:","","What I found:","A concise diagnosis grounded in the Incident Report and verified evidence gathered afterward.","","Proposed fix:","The smallest intervention that addresses the confirmed mechanism.","","Diff preview:","Describe the expected code/config change if applicable. Do not apply it.","","Verification test:","Name the smallest test or command that would verify the proposed fix.","","Clearly distinguish:","- evidence already present in the Incident Report","- findings established during investigation","- hypotheses that remain unverified","","Once the current failure is sufficiently explained, stop widening the investigation unless new evidence connects another issue to the same failure.","","Important behavior:","- The agent may inspect the repo/runtime normally.","- The Incident Report is not the only source of truth.","- The agent must not hallucinate missing telemetry.","- The agent must not convert an unverified hypothesis into a confirmed diagnosis.","- The agent must not execute remediation unless explicitly asked.","- The diagnostic trace is investigative structure, not verbose prose. Keep each section concise and evidence-based.","<!-- paper:end -->"].join(`
|
|
26
26
|
`),d=class extends Error{constructor(t,n,r,s){super(n),this.name="PaperCliError",this.causeLabel=t,this.state=r,this.directive=s}};function N(e){return e instanceof d?[e.causeLabel,e.message,"",e.state,"",e.directive].join(`
|
|
27
27
|
`):["PAPER OPERATION FAILED",e?.message||"Paper encountered an unclassified local operation failure.","","Paper stopped before the requested operation completed.","","Resolve the reported local error and run Paper again."].join(`
|
|
28
|
-
`)}function Q({modulePath:e=Y(import.meta.url),invokedPath:t=process.argv[1],resolvePath:n=V.native}={}){if(!t)return{isCli:!1,startupFailure:!1};try{return{isCli:n(g(e))===n(g(t)),startupFailure:!1}}catch{let r=k(e).toLowerCase(),s=k(t).toLowerCase();return{isCli:!1,startupFailure:r===s}}}async function ee(e){try{let t=await F(e);return t.isDirectory()||t.isFile()}catch{return!1}}async function x(e=process.cwd()){let t=g(e);for(;;){if(await ee(o(t,".git")))return t;let n=f(t);if(n===t)return g(e);t=n}}async function v(e,t){try{let n=await F(e);return t==="directory"?n.isDirectory():t==="file"?n.isFile():!0}catch{return!1}}async function m(e){try{if((await q(e)).isSymbolicLink())throw new Error(`Refusing to write through a symbolic link: ${e}`)}catch(t){if(t.code!=="ENOENT")throw t}}async function te(e){let t=[],n=["AGENTS.md","CLAUDE.md","GEMINI.md",o(".github","copilot-instructions.md"),".cursorrules",o(".cursor","rules.md"),o(".cursor","instructions.md")];for(let r of n)await v(o(e,r),"file")&&t.push(o(e,r));return await v(o(e,".cursor","rules"),"directory")&&t.push(o(e,".cursor","rules","paper.mdc")),t.length?t:[o(e,"AGENTS.md")]}function ne(e){let t=/<!-- paper:start -->[\s\S]*?<!-- paper:end -->/g;if(e.match(t)?.length){let r=0,s=e.replace(t,()=>r++===0?
|
|
28
|
+
`)}function Q({modulePath:e=Y(import.meta.url),invokedPath:t=process.argv[1],resolvePath:n=V.native}={}){if(!t)return{isCli:!1,startupFailure:!1};try{return{isCli:n(g(e))===n(g(t)),startupFailure:!1}}catch{let r=k(e).toLowerCase(),s=k(t).toLowerCase();return{isCli:!1,startupFailure:r===s}}}async function ee(e){try{let t=await F(e);return t.isDirectory()||t.isFile()}catch{return!1}}async function x(e=process.cwd()){let t=g(e);for(;;){if(await ee(o(t,".git")))return t;let n=f(t);if(n===t)return g(e);t=n}}async function v(e,t){try{let n=await F(e);return t==="directory"?n.isDirectory():t==="file"?n.isFile():!0}catch{return!1}}async function m(e){try{if((await q(e)).isSymbolicLink())throw new Error(`Refusing to write through a symbolic link: ${e}`)}catch(t){if(t.code!=="ENOENT")throw t}}async function te(e){let t=[],n=["AGENTS.md","CLAUDE.md","GEMINI.md",o(".github","copilot-instructions.md"),".cursorrules",o(".cursor","rules.md"),o(".cursor","instructions.md")];for(let r of n)await v(o(e,r),"file")&&t.push(o(e,r));return await v(o(e,".cursor","rules"),"directory")&&t.push(o(e,".cursor","rules","paper.mdc")),t.length?t:[o(e,"AGENTS.md")]}function ne(e){let t=/<!-- paper:start -->[\s\S]*?<!-- paper:end -->/g;if(e.match(t)?.length){let r=0,s=e.replace(t,()=>r++===0?b:"");return{next:s,changed:s!==e}}return{next:e?`${e}${e.endsWith(`
|
|
29
29
|
`)?`
|
|
30
30
|
`:`
|
|
31
31
|
|
|
32
|
-
`}${
|
|
33
|
-
`:`${
|
|
32
|
+
`}${b}
|
|
33
|
+
`:`${b}
|
|
34
34
|
`,changed:!0}}async function re(e=process.cwd()){let t=await x(e),n=await te(t),r=[],s=[];for(let a of n){await m(a),await m(f(a)),await m(f(f(a)));let i="";try{i=await K(a,"utf8")}catch(u){if(u.code!=="ENOENT")throw u}let{next:c,changed:l}=ne(i);l&&(await P(f(a),{recursive:!0}),await M(a,c,"utf8"),r.push(a),i||s.push(a))}return{repoRoot:t,targetPaths:n,changedPaths:r,created:s.length>0,changed:r.length>0}}async function ie(e,t){let n=o(e,".paper","incident_report.md");return await m(o(e,".paper")),await m(n),await P(f(n),{recursive:!0}),await M(n,t,"utf8"),n}function se(e=process.env,t=O()){return t==="win32"?e.LOCALAPPDATA||o($(),"AppData","Local","Paper"):o(e.XDG_DATA_HOME||o($(),".local","share"),"Paper")}function ae(e,t=process.env,n=O()){let r=Z("sha256").update(g(e)).digest("hex").slice(0,16);return o(se(t,n),"shelf",r)}function oe(e=new Date){return e.toISOString().replace(/[:.]/g,"-")}async function ce(e,t){let n=0;for(;;){let r=o(e,`${t}${n?`-${n}`:""}.md`);if(!await v(r,"file"))return r;n+=1}}async function de(){let e=await x(),t=o(e,".paper","incident_report.md");if(!await v(t,"file"))throw new d("NO ACTIVE INCIDENT","Paper could not find an active Incident Report.","No files were changed.","Run `paper run <command>` to capture a failure first.");let n=ae(e),r=await ce(n,oe());try{await P(n,{recursive:!0}),await X(t,r)}catch(s){throw new d("INCIDENT SHELF FAILED",`Paper could not move the Incident Report out of the workspace${s?.code?` (${s.code})`:"."}`,"The active Incident Report was preserved in the workspace.","Restore access to the Paper shelf location and run `paper shelf` again.")}process.stdout.write(`INCIDENT SHELVED
|
|
35
35
|
Moved the active Incident Report out of the workspace.
|
|
36
36
|
|
|
@@ -41,24 +41,24 @@ ${r}
|
|
|
41
41
|
${a} exited with ${c}.
|
|
42
42
|
|
|
43
43
|
Paper captured the failure and persisted the Incident Report at \`${s}\`.
|
|
44
|
-
`)}}var ge=[/\b(?:error|fatal|exception|panic|failed|failure|traceback|segmentation fault|command not found|exited with code)\b|ERR!/i,/\b(?:HTTP\/\d(?:\.\d)?\s+)?[45]\d{2}\b/i,/\b(?:exit(?:ed| status| code)?|status code)\s*[:=]?\s*[1-9]\d*/i],we=/HTTP\/\d(?:\.\d)?\s+[1-5]\d{2}\b|\bstatus(?: code)?\s*[:=]?\s*[1-5]\d{2}\b/i,ve=/\b(?:exited with code|exit(?: status| code)?|status code)\s*[:=]?\s*[1-9]\d*/i,W=/^\s*(?:at\s+.+|File\s+["'].+["'],\s*line\s+\d+|[\w.]+\.[\w$]+\([^)]*:\d+(?::\d+)?\))/i,_=/^\s*(?:[$>]|(?:curl|wget|git|docker|kubectl|wrangler|npm|npx|node|python(?:\d+)?|pytest|cargo|go|dotnet|java|bun|deno|yarn|pnpm)\b)/i,
|
|
44
|
+
`)}}var ge=[/\b(?:error|fatal|exception|panic|failed|failure|traceback|segmentation fault|command not found|exited with code)\b|ERR!/i,/\b(?:HTTP\/\d(?:\.\d)?\s+)?[45]\d{2}\b/i,/\b(?:exit(?:ed| status| code)?|status code)\s*[:=]?\s*[1-9]\d*/i],we=/HTTP\/\d(?:\.\d)?\s+[1-5]\d{2}\b|\bstatus(?: code)?\s*[:=]?\s*[1-5]\d{2}\b/i,ve=/\b(?:exited with code|exit(?: status| code)?|status code)\s*[:=]?\s*[1-9]\d*/i,W=/^\s*(?:at\s+.+|File\s+["'].+["'],\s*line\s+\d+|[\w.]+\.[\w$]+\([^)]*:\d+(?::\d+)?\))/i,_=/^\s*(?:[$>]|(?:curl|wget|git|docker|kubectl|wrangler|npm|npx|node|python(?:\d+)?|pytest|cargo|go|dotnet|java|bun|deno|yarn|pnpm)\b)/i,ye=/\b(?:node(?:\.js)?|npm|npx|pnpm|yarn|bun|deno|python(?:\d+)?|pytest|ruby|java|dotnet|cargo|rustc|go version|windows|linux|darwin|macos|runtime|version)\b/i,be=/(?:[A-Za-z]:[\\/][^\s,;()[\]{}]+|(?:\.{0,2}[\\/])?[A-Za-z0-9_.-]+(?:[\\/][A-Za-z0-9_.-]+)+\.[A-Za-z0-9_.-]+)/g,A=/^\s*(?:\+\s*)?(?:CategoryInfo|FullyQualifiedErrorId)\b/i,S=/^\s*At line:\d+ char:\d+\s*$/i,C=/^\s*(?:\+\s*)?~+\s*$/,D=/^\s*\+\s*npm(?:\.cmd)?\b/i,Pe=/^\s*\+\s*curl(?:\.exe)?\b/i,xe=/^\s*\|\s*(?:node|npm|npx)\b/i,j=/^\s*(?:npm(?:\.cmd)?|curl(?:\.exe)?)\s*:\s+/i,Ee=/^\s*[a-z]:\/\//i;function Ie(e=""){let t=String(e??""),n=t.replace(/\r\n?/g,`
|
|
45
45
|
`).split(`
|
|
46
46
|
`);if(!(n.some(i=>A.test(i))&&n.some(i=>j.test(i))))return t;let s=[],a=!1;for(let i of n){if(A.test(i)){a=!0;continue}if(a){if(!i.trim()){a=!1,s.push(i);continue}if(S.test(i)||C.test(i)||D.test(i))continue;if(W.test(i)||_.test(i))a=!1;else continue}if(S.test(i)||C.test(i)||D.test(i)||xe.test(i))continue;if(Pe.test(i)){let l=i.replace(/^\s*\+\s*/,"");s.at(-1)!==l&&s.push(l);continue}if(Ee.test(i))continue;let c=i.replace(j,"");s.at(-1)!==c&&s.push(c)}return s.join(`
|
|
47
|
-
`)}function h(e){return[...new Set(e.map(t=>t.trim()).filter(Boolean))]}function Re(e){return h([...e.matchAll(
|
|
47
|
+
`)}function h(e){return[...new Set(e.map(t=>t.trim()).filter(Boolean))]}function Re(e){return h([...e.matchAll(be)].map(([t])=>t.replace(/[.:]+$/,"")).filter(t=>!/^HTTP\/\d(?:\.\d)?$/i.test(t)&&!/^[a-z]:\/\//i.test(t)))}function Te(e=""){let t=Ie(e),r=t.replace(/\r\n?/g,`
|
|
48
48
|
`).split(`
|
|
49
|
-
`).filter(p=>p.trim()),s=h(r.filter(p=>ge.some(G=>G.test(p)))),a=h(r.filter(p=>W.test(p))),i=h(r.filter(p=>_.test(p))),c=h(r.filter(p=>
|
|
50
|
-
`),
|
|
49
|
+
`).filter(p=>p.trim()),s=h(r.filter(p=>ge.some(G=>G.test(p)))),a=h(r.filter(p=>W.test(p))),i=h(r.filter(p=>_.test(p))),c=h(r.filter(p=>ye.test(p))),l=h(r.filter(p=>we.test(p))),u=h(r.filter(p=>ve.test(p))),w=Re(t),E=h([...s,...a]).join(`
|
|
50
|
+
`),y=i.join(`
|
|
51
51
|
`),z=w.length?`${w.join(`
|
|
52
52
|
`)}
|
|
53
53
|
|
|
54
54
|
${t}`:t;return{"what-failing":s.join(`
|
|
55
55
|
`),"observed-at-boundary":s.join(`
|
|
56
|
-
`),"input-payload":
|
|
56
|
+
`),"input-payload":y,"output-error":E,origin:y,"first-confirmed-divergence":s[0]||a[0]||"","runtime-environment-hops":c.join(`
|
|
57
57
|
`),"exit-code":u.join(`
|
|
58
58
|
`),"stderr-stack-trace":E,"status-codes":l.join(`
|
|
59
|
-
`),commands:
|
|
59
|
+
`),commands:y,"runtime-versions":c.join(`
|
|
60
60
|
`),"other-receipts":z}}function $e(e=""){return R(Te(e))}var L=Q();if(L.startupFailure)process.stderr.write(`${N(new d("CLI ENTRYPOINT MISMATCH","Paper loaded, but the executable path could not be resolved to the active CLI entrypoint.","No target command was started.","Reinstall or relink Paper and run the command again."))}
|
|
61
61
|
`),process.exitCode=1;else if(L.isCli)try{let e=process.argv.slice(2);if(e[0]==="--help")process.stdout.write(`${J}
|
|
62
62
|
`);else if(e[0]==="--version")process.stdout.write(`${T.version}
|
|
63
63
|
`);else if(e[0]==="shelf"&&e.length===1)await de();else if(e.length){if(e[0]!=="run")throw new d("INVALID COMMAND","Paper expected `run` before the target command.","No target command was started.","Use `paper run <command>`.");if(e.length===1)throw new d("NO COMMAND","Paper needs a command to capture.","No target command was started.","Use `paper run <command>`. ");await me(e[1],e.slice(2))}else throw new d("NO COMMAND","Paper needs a command to capture.","No target command was started.","Use `paper run <command>`.")}catch(e){process.stderr.write(`${N(e)}
|
|
64
|
-
`),process.exitCode=1}export{
|
|
64
|
+
`),process.exitCode=1}export{b as MANAGED_AGENT_RULES_BLOCK,d as PaperCliError,$e as buildTerminalPacket,te as detectAgentInstructionPaths,re as ensureManagedAgentRules,Te as extractTerminalPacket,x as findRepoRoot,N as formatPaperCliError,Ie as normalizeTerminalOutput,Q as resolveCliEntrypoint,ae as shelfPathForRepo,ie as writeIncidentReport};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@varman96/paper",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Paper captures command failures in a structured Incident Report for coding-agent investigation.",
|
|
5
5
|
"main": "dist/paper.js",
|
|
6
6
|
"bin": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"bugs": {
|
|
39
39
|
"url": "https://github.com/varman96/paper/issues"
|
|
40
40
|
},
|
|
41
|
-
"homepage": "https://
|
|
41
|
+
"homepage": "https://paper-ai.paperhq.workers.dev/",
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@biomejs/biome": "2.5.14",
|
|
44
44
|
"esbuild": "^0.28.1",
|