pi-agentsmd 0.1.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/CHANGELOG.md ADDED
@@ -0,0 +1,16 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ This project follows the spirit of [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and uses semantic versioning for releases.
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [0.1.0] - TBD
10
+
11
+ ### Added
12
+
13
+ - Initial `pi-agentsmd` package scaffold.
14
+ - `/init` command to generate an `AGENTS.md` contributor guide for the current repository.
15
+ - `--force` flag to overwrite an existing `AGENTS.md` file.
16
+ - Init prompt adapted from OpenAI Codex (Apache 2.0).
@@ -0,0 +1,41 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment include:
12
+
13
+ - Demonstrating empathy and kindness toward other people
14
+ - Being respectful of differing opinions, viewpoints, and experiences
15
+ - Giving and gracefully accepting constructive feedback
16
+ - Accepting responsibility and apologizing to those affected by our mistakes
17
+ - Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ - The use of sexualized language or imagery, and sexual attention or advances
22
+ - Trolling, insulting or derogatory comments, and personal or political attacks
23
+ - Public or private harassment
24
+ - Publishing others' private information without explicit permission
25
+ - Other conduct which could reasonably be considered inappropriate in a professional setting
26
+
27
+ ## Enforcement Responsibilities
28
+
29
+ Project maintainers are responsible for clarifying and enforcing standards of acceptable behavior and may remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned with this Code of Conduct.
30
+
31
+ ## Scope
32
+
33
+ This Code of Conduct applies within all project spaces and also applies when an individual is officially representing the project in public spaces.
34
+
35
+ ## Enforcement
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the project maintainers through GitHub. All complaints will be reviewed and investigated promptly and fairly.
38
+
39
+ ## Attribution
40
+
41
+ This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org/), version 2.1.
@@ -0,0 +1,51 @@
1
+ # Contributing
2
+
3
+ Thanks for your interest in contributing to `pi-agentsmd`.
4
+
5
+ ## Development setup
6
+
7
+ ```bash
8
+ npm install
9
+ npm run check
10
+ ```
11
+
12
+ This package is source-distributed: Pi loads the TypeScript extension files directly. There is no build step for runtime use.
13
+
14
+ ## Local testing
15
+
16
+ Install this checkout into a temporary Pi project:
17
+
18
+ ```bash
19
+ mkdir -p <test-project>
20
+ cd <test-project>
21
+ pi install -l /path/to/pi-mono/packages/pi-agentsmd
22
+ pi
23
+ ```
24
+
25
+ Then run `/init` inside the test project to verify AGENTS.md generation.
26
+
27
+ For a one-off run without changing settings:
28
+
29
+ ```bash
30
+ pi -e /path/to/pi-mono/packages/pi-agentsmd --print "list your commands"
31
+ ```
32
+
33
+ ## Pull request checklist
34
+
35
+ Before opening a pull request:
36
+
37
+ - Run `npm run check`.
38
+ - Run `npm audit --omit=dev`.
39
+ - Run `npm run pack:dry-run` and confirm the package contents are intentional.
40
+ - Update `README.md` if user-facing behavior changes.
41
+ - Update `CHANGELOG.md` for notable changes.
42
+ - Keep examples and paths generic; do not commit machine-specific paths, API keys, tokens, or provider config containing secrets.
43
+
44
+ ## Coding guidelines
45
+
46
+ - Keep `extensions/index.ts` focused on Pi extension wiring and move reusable implementation details into `src/`.
47
+ - Treat command names and flags as public interface; changes are breaking changes.
48
+
49
+ ## Code of conduct
50
+
51
+ This project follows the [Contributor Covenant Code of Conduct](CODE_OF_CONDUCT.md).
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jose Mocito
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,85 @@
1
+ # pi-agentsmd
2
+
3
+ Generate `AGENTS.md` contributor guides for [Pi](https://pi.dev) repositories.
4
+
5
+ `pi-agentsmd` provides a `/init` command that analyzes the current repository and generates a concise, well-structured `AGENTS.md` file with repository-specific guidelines for contributors and AI agents.
6
+
7
+ ## Features
8
+
9
+ - `/init` command to generate an `AGENTS.md` file at the repository root.
10
+ - Refuses to overwrite existing files unless `--force` is passed.
11
+ - Delegates generation to the AI model, which analyzes the repository structure, tooling, and conventions to produce tailored guidelines.
12
+ - Prompt adapted from [OpenAI Codex](https://github.com/openai/codex) (Apache 2.0).
13
+
14
+ ## Installation
15
+
16
+ Install from npm:
17
+
18
+ ```bash
19
+ pi install npm:pi-agentsmd
20
+ ```
21
+
22
+ Install project-locally:
23
+
24
+ ```bash
25
+ pi install -l npm:pi-agentsmd
26
+ ```
27
+
28
+ During local development from this monorepo:
29
+
30
+ ```bash
31
+ pi install /path/to/pi-mono/packages/pi-agentsmd
32
+ ```
33
+
34
+ ## Usage
35
+
36
+ ### Generate AGENTS.md
37
+
38
+ Run the `/init` command inside a repository:
39
+
40
+ ```
41
+ /init
42
+ ```
43
+
44
+ Pi will analyze the repository and create an `AGENTS.md` file with sections covering:
45
+
46
+ - Project structure & module organization
47
+ - Build, test, and development commands
48
+ - Coding style & naming conventions
49
+ - Testing guidelines
50
+ - Commit & pull request guidelines
51
+
52
+ ### Overwrite existing AGENTS.md
53
+
54
+ If `AGENTS.md` already exists, use `--force` to regenerate it:
55
+
56
+ ```
57
+ /init --force
58
+ ```
59
+
60
+ ## How it works
61
+
62
+ The `/init` command sends a structured prompt to the active AI model. The model uses its file-writing tools to analyze the repository and generate an `AGENTS.md` file tailored to the project. The package itself does not write the file — it delegates entirely to the model.
63
+
64
+ ## Development
65
+
66
+ Requirements:
67
+
68
+ - Node.js >= 20.6.0
69
+ - npm
70
+
71
+ ```bash
72
+ npm install
73
+ npm run check
74
+ npm run pack:dry-run
75
+ ```
76
+
77
+ ## Contributing
78
+
79
+ Contributions are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) for development workflow and pull request guidelines.
80
+
81
+ ## License
82
+
83
+ MIT. See [LICENSE](LICENSE).
84
+
85
+ Includes a prompt derived from [OpenAI Codex](https://github.com/openai/codex), licensed under the Apache License 2.0. See [THIRD-PARTY-NOTICES](THIRD-PARTY-NOTICES).
package/SECURITY.md ADDED
@@ -0,0 +1,26 @@
1
+ # Security Policy
2
+
3
+ ## Supported versions
4
+
5
+ Security fixes are provided for the latest released version of `pi-agentsmd`.
6
+
7
+ ## Reporting a vulnerability
8
+
9
+ Please do not open a public issue for suspected security vulnerabilities.
10
+
11
+ Report privately by contacting the repository maintainer through GitHub. Include:
12
+
13
+ - a description of the issue;
14
+ - steps to reproduce;
15
+ - affected versions or commits, if known;
16
+ - any suggested mitigation.
17
+
18
+ The maintainer will acknowledge reports as soon as practical and coordinate disclosure once a fix or mitigation is available.
19
+
20
+ ## Security model
21
+
22
+ `pi-agentsmd` is a Pi package. Pi extensions execute with the same permissions as the local user running Pi. Users should review installed Pi packages and only install packages from sources they trust.
23
+
24
+ The `/init` command checks for an existing `AGENTS.md` file before generating one. The `--force` flag bypasses this check. The package does not read or write files other than `AGENTS.md` in the current working directory, and does not send data to external services.
25
+
26
+ Do not commit API keys, tokens, credentials, local settings, or machine-specific paths.
@@ -0,0 +1,204 @@
1
+ THIRD-PARTY NOTICES
2
+
3
+ This project includes material derived from OpenAI Codex.
4
+ Copyright 2025 OpenAI
5
+ Licensed under the Apache License, Version 2.0 (the "License").
6
+
7
+ Source: https://github.com/openai/codex
8
+ Original file: codex-rs/tui/prompt_for_init_command.md
9
+
10
+ You may obtain a copy of the License at:
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+
19
+ ---
20
+
21
+ This project includes code derived from Ratatui (transitive notice from
22
+ OpenAI Codex's NOTICE file).
23
+ Copyright (c) 2016-2022 Florian Dehau
24
+ Copyright (c) 2023-2025 The Ratatui Developers
25
+ Licensed under the MIT license.
26
+
27
+ ---
28
+
29
+ Apache License
30
+ Version 2.0, January 2004
31
+ http://www.apache.org/licenses/
32
+
33
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
34
+
35
+ 1. Definitions.
36
+
37
+ "License" shall mean the terms and conditions for use, reproduction,
38
+ and distribution as defined by Sections 1 through 9 of this document.
39
+
40
+ "Licensor" shall mean the copyright owner or entity authorized by
41
+ the copyright owner that is granting the License.
42
+
43
+ "Legal Entity" shall mean the union of the acting entity and all
44
+ other entities that control, are controlled by, or are under common
45
+ control with that entity. For the purposes of this definition,
46
+ "control" means (i) the power, direct or indirect, to cause the
47
+ direction or management of such entity, whether by contract or
48
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
49
+ outstanding shares, or (iii) beneficial ownership of such entity.
50
+
51
+ "You" (or "Your") shall mean an individual or Legal Entity
52
+ exercising permissions granted by this License.
53
+
54
+ "Source" form shall mean the preferred form for making modifications,
55
+ including but not limited to software source code, documentation
56
+ source, and configuration files.
57
+
58
+ "Object" form shall mean any form resulting from mechanical
59
+ transformation or translation of a Source form, including but
60
+ not limited to compiled object code, generated documentation,
61
+ and conversions to other media types.
62
+
63
+ "Work" shall mean the work of authorship, whether in Source or
64
+ Object form, made available under the License, as indicated by a
65
+ copyright notice that is included in or attached to the work
66
+ (an example is provided in the Appendix below).
67
+
68
+ "Derivative Works" shall mean any work, whether in Source or Object
69
+ form, that is based on (or derived from) the Work and for which the
70
+ editorial revisions, annotations, elaborations, or other modifications
71
+ represent, as a whole, an original work of authorship. For the purposes
72
+ of this License, Derivative Works shall not include works that remain
73
+ separable from, or merely link (or bind by name) to the interfaces of,
74
+ the Work and Derivative Works thereof.
75
+
76
+ "Contribution" shall mean any work of authorship, including
77
+ the original version of the Work and any modifications or additions
78
+ to that Work or Derivative Works thereof, that is intentionally
79
+ submitted to Licensor for inclusion in the Work by the copyright owner
80
+ or by an individual or Legal Entity authorized to submit on behalf of
81
+ the copyright owner. For the purposes of this definition, "submitted"
82
+ means any form of electronic, verbal, or written communication sent
83
+ to the Licensor or its representatives, including but not limited to
84
+ communication on electronic mailing lists, source code control systems,
85
+ and issue tracking systems that are managed by, or on behalf of, the
86
+ Licensor for the purpose of discussing and improving the Work, but
87
+ excluding communication that is conspicuously marked or otherwise
88
+ designated in writing by the copyright owner as "Not a Contribution."
89
+
90
+ "Contributor" shall mean Licensor and any individual or Legal Entity on
91
+ behalf of whom a Contribution has been received by the Licensor and
92
+ subsequently incorporated within the Work.
93
+
94
+ 2. Grant of Copyright License. Subject to the terms and conditions of
95
+ this License, each Contributor hereby grants to You a perpetual,
96
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
97
+ copyright license to reproduce, prepare Derivative Works of,
98
+ publicly display, publicly perform, sublicense, and distribute the
99
+ Work and such Derivative Works in Source or Object form.
100
+
101
+ 3. Grant of Patent License. Subject to the terms and conditions of
102
+ this License, each Contributor hereby grants to You a perpetual,
103
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
104
+ (except as stated in this section) patent license to make, have made,
105
+ use, offer to sell, sell, import, and otherwise transfer the Work,
106
+ where such license applies only to those patent claims licensable
107
+ by such Contributor that are necessarily infringed by their
108
+ Contribution(s) alone or by combination of their Contribution(s)
109
+ with the Work to which such Contribution(s) was submitted. If You
110
+ institute patent litigation against any entity (including a
111
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
112
+ or a Contribution incorporated within the Work constitutes direct
113
+ or contributory patent infringement, then any patent licenses
114
+ granted to You under this License for that Work shall terminate
115
+ as of the date such litigation is filed.
116
+
117
+ 4. Redistribution. You may reproduce and distribute copies of the
118
+ Work or Derivative Works thereof in any medium, with or without
119
+ modifications, and in Source or Object form, provided that You
120
+ meet the following conditions:
121
+
122
+ (a) You must give any other recipients of the Work or
123
+ Derivative Works a copy of this License; and
124
+
125
+ (b) You must cause any modified files to carry prominent notices
126
+ stating that You changed the files; and
127
+
128
+ (c) You must retain, in the Source form of any Derivative Works
129
+ that You distribute, all copyright, patent, trademark, and
130
+ attribution notices from the Source form of the Work,
131
+ excluding those notices that do not pertain to any part of
132
+ the Derivative Works; and
133
+
134
+ (d) If the Work includes a "NOTICE" text file as part of its
135
+ distribution, then any Derivative Works that You distribute must
136
+ include a readable copy of the attribution notices contained
137
+ within such NOTICE file, excluding those notices that do not
138
+ pertain to any part of the Derivative Works, in at least one
139
+ of the following places: within a NOTICE text file distributed
140
+ as part of the Derivative Works; within the Source form or
141
+ documentation, if provided along with the Derivative Works; or,
142
+ within a display generated by the Derivative Works, if and
143
+ wherever such third-party notices normally appear. The contents
144
+ of the NOTICE file are for informational purposes only and
145
+ do not modify the License. You may add Your own attribution
146
+ notices within Derivative Works that You distribute, alongside
147
+ or as an addendum to the NOTICE text from the Work, provided
148
+ that such additional attribution notices cannot be construed
149
+ as modifying the License.
150
+
151
+ You may add Your own copyright statement to Your modifications and
152
+ may provide additional or different license terms and conditions
153
+ for use, reproduction, or distribution of Your modifications, or
154
+ for any such Derivative Works as a whole, provided Your use,
155
+ reproduction, and distribution of the Work otherwise complies with
156
+ the conditions stated in this License.
157
+
158
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
159
+ any Contribution intentionally submitted for inclusion in the Work
160
+ by You to the Licensor shall be under the terms and conditions of
161
+ this License, without any additional terms or conditions.
162
+ Notwithstanding the above, nothing herein shall supersede or modify
163
+ the terms of any separate license agreement you may have executed
164
+ with Licensor regarding such Contributions.
165
+
166
+ 6. Trademarks. This License does not grant permission to use the trade
167
+ names, trademarks, service marks, or product names of the Licensor,
168
+ except as required for reasonable and customary use in describing the
169
+ origin of the Work and reproducing the content of the NOTICE file.
170
+
171
+ 7. Disclaimer of Warranty. Unless required by applicable law or
172
+ agreed to in writing, Licensor provides the Work (and each
173
+ Contributor provides its Contributions) on an "AS IS" BASIS,
174
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
175
+ implied, including, without limitation, any warranties or conditions
176
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
177
+ PARTICULAR PURPOSE. You are solely responsible for determining the
178
+ appropriateness of using or redistributing the Work and assume any
179
+ risks associated with Your exercise of permissions under this License.
180
+
181
+ 8. Limitation of Liability. In no event and under no legal theory,
182
+ whether in tort (including negligence), contract, or otherwise,
183
+ unless required by applicable law (such as deliberate and grossly
184
+ negligent acts) or agreed to in writing, shall any Contributor be
185
+ liable to You for damages, including any direct, indirect, special,
186
+ incidental, or consequential damages of any character arising as a
187
+ result of this License or out of the use or inability to use the
188
+ Work (including but not limited to damages for loss of goodwill,
189
+ work stoppage, computer failure or malfunction, or any and all
190
+ other commercial damages or losses), even if such Contributor
191
+ has been advised of the possibility of such damages.
192
+
193
+ 9. Accepting Warranty or Additional Liability. While redistributing
194
+ the Work or Derivative Works thereof, You may choose to offer,
195
+ and charge a fee for, acceptance of support, warranty, indemnity,
196
+ or other liability obligations and/or rights consistent with this
197
+ License. However, in accepting such obligations, You may act only
198
+ on Your own behalf and on Your sole responsibility, not on behalf
199
+ of any other Contributor, and only if You agree to indemnify,
200
+ defend, and hold each Contributor harmless for any liability
201
+ incurred by, or claims asserted against, such Contributor by reason
202
+ of your accepting any such warranty or additional liability.
203
+
204
+ END OF TERMS AND CONDITIONS
@@ -0,0 +1,14 @@
1
+ import type { ExtensionAPI, ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
2
+ import { handleInitCommand } from "../src/init.js";
3
+ import { reportInstallTelemetry } from "../src/install-telemetry.js";
4
+
5
+ export default function piAgentsMd(pi: ExtensionAPI) {
6
+ reportInstallTelemetry();
7
+
8
+ pi.registerCommand("init", {
9
+ description: "create an AGENTS.md file with instructions for Pi",
10
+ handler: async (args, ctx) => {
11
+ await handleInitCommand(pi, args, ctx);
12
+ },
13
+ });
14
+ }
package/index.ts ADDED
@@ -0,0 +1 @@
1
+ export { default } from "./extensions/index.js";
package/package.json ADDED
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "pi-agentsmd",
3
+ "version": "0.1.0",
4
+ "description": "Generate AGENTS.md contributor guides for Pi repositories.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "author": "Jose Mocito",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/jvm/pi-mono.git",
11
+ "directory": "packages/pi-agentsmd"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/jvm/pi-mono/issues"
15
+ },
16
+ "homepage": "https://github.com/jvm/pi-mono/tree/main/packages/pi-agentsmd#readme",
17
+ "keywords": [
18
+ "pi-package",
19
+ "pi-extension",
20
+ "pi",
21
+ "agents-md",
22
+ "documentation",
23
+ "repository-guidelines"
24
+ ],
25
+ "exports": {
26
+ ".": "./src/index.ts"
27
+ },
28
+ "pi": {
29
+ "extensions": [
30
+ "./index.ts"
31
+ ]
32
+ },
33
+ "files": [
34
+ "index.ts",
35
+ "extensions",
36
+ "src",
37
+ "prompts",
38
+ "README.md",
39
+ "LICENSE",
40
+ "CHANGELOG.md",
41
+ "SECURITY.md",
42
+ "CONTRIBUTING.md",
43
+ "CODE_OF_CONDUCT.md",
44
+ "THIRD-PARTY-NOTICES"
45
+ ],
46
+ "scripts": {
47
+ "check": "tsc --noEmit",
48
+ "typecheck": "tsc --noEmit",
49
+ "pack:dry-run": "npm pack --dry-run"
50
+ },
51
+ "peerDependencies": {
52
+ "@earendil-works/pi-coding-agent": "*"
53
+ },
54
+ "devDependencies": {
55
+ "@earendil-works/pi-coding-agent": "^0.75.4",
56
+ "@types/node": "^25.6.2",
57
+ "typescript": "^6.0.3"
58
+ },
59
+ "publishConfig": {
60
+ "access": "public"
61
+ },
62
+ "engines": {
63
+ "node": ">=20.6.0"
64
+ }
65
+ }
@@ -0,0 +1,40 @@
1
+ Generate a file named AGENTS.md that serves as a contributor guide for this repository.
2
+ Your goal is to produce a clear, concise, and well-structured document with descriptive headings and actionable explanations for each section.
3
+ Follow the outline below, but adapt as needed — add sections if relevant, and omit those that do not apply to this project.
4
+
5
+ Document Requirements
6
+
7
+ - Title the document "Repository Guidelines".
8
+ - Use Markdown headings (#, ##, etc.) for structure.
9
+ - Keep the document concise. 200-400 words is optimal.
10
+ - Keep explanations short, direct, and specific to this repository.
11
+ - Provide examples where helpful (commands, directory paths, naming patterns).
12
+ - Maintain a professional, instructional tone.
13
+
14
+ Recommended Sections
15
+
16
+ Project Structure & Module Organization
17
+
18
+ - Outline the project structure, including where the source code, tests, and assets are located.
19
+
20
+ Build, Test, and Development Commands
21
+
22
+ - List key commands for building, testing, and running locally (e.g., npm test, make build).
23
+ - Briefly explain what each command does.
24
+
25
+ Coding Style & Naming Conventions
26
+
27
+ - Specify indentation rules, language-specific style preferences, and naming patterns.
28
+ - Include any formatting or linting tools used.
29
+
30
+ Testing Guidelines
31
+
32
+ - Identify testing frameworks and coverage requirements.
33
+ - State test naming conventions and how to run tests.
34
+
35
+ Commit & Pull Request Guidelines
36
+
37
+ - Summarize commit message conventions found in the project's Git history.
38
+ - Outline pull request requirements (descriptions, linked issues, screenshots, etc.).
39
+
40
+ (Optional) Add other sections if relevant, such as Security & Configuration Tips, Architecture Overview, or Agent-Specific Instructions.
package/src/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ export { handleInitCommand } from "./init.js";
2
+ export { reportInstallTelemetry } from "./install-telemetry.js";
3
+ export { INIT_PROMPT } from "./prompt.js";
package/src/init.ts ADDED
@@ -0,0 +1,27 @@
1
+ import type { ExtensionAPI, ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
2
+ import { existsSync } from "node:fs";
3
+ import { join } from "node:path";
4
+ import { INIT_PROMPT } from "./prompt.js";
5
+
6
+ const DEFAULT_AGENTS_MD_FILENAME = "AGENTS.md";
7
+
8
+ export async function handleInitCommand(
9
+ pi: ExtensionAPI,
10
+ args: string,
11
+ ctx: ExtensionCommandContext,
12
+ ): Promise<void> {
13
+ const trimmed = args.trim();
14
+ const force = trimmed === "--force" || trimmed === "-f";
15
+
16
+ const initTarget = join(ctx.cwd, DEFAULT_AGENTS_MD_FILENAME);
17
+
18
+ if (existsSync(initTarget) && !force) {
19
+ ctx.ui.notify(
20
+ `${DEFAULT_AGENTS_MD_FILENAME} already exists here. Use /init --force to overwrite.`,
21
+ "warning",
22
+ );
23
+ return;
24
+ }
25
+
26
+ pi.sendUserMessage(INIT_PROMPT);
27
+ }
@@ -0,0 +1,104 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { mkdir, writeFile } from "node:fs/promises";
3
+ import { join } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ import { getAgentDir } from "@earendil-works/pi-coding-agent";
6
+
7
+ const PACKAGE_NAME = "pi-agentsmd";
8
+ const INSTALL_TELEMETRY_URL = "https://mocito.dev/api/report-install";
9
+ const INSTALL_TELEMETRY_TIMEOUT_MS = 5000;
10
+ const CI_ENVIRONMENT_VARIABLES = [
11
+ "APPVEYOR",
12
+ "BITBUCKET_BUILD_NUMBER",
13
+ "BUILDKITE",
14
+ "CIRCLECI",
15
+ "CODESPACES",
16
+ "DRONE",
17
+ "GITHUB_ACTIONS",
18
+ "GITLAB_CI",
19
+ "JENKINS_URL",
20
+ "NETLIFY",
21
+ "TEAMCITY_VERSION",
22
+ "TF_BUILD",
23
+ "TRAVIS",
24
+ "VERCEL",
25
+ ];
26
+
27
+ interface InstallTelemetryState {
28
+ lastReportedVersion?: string;
29
+ }
30
+
31
+ interface PiSettingsDocument {
32
+ enableInstallTelemetry?: unknown;
33
+ }
34
+
35
+ function readJsonFile(path: string): unknown {
36
+ try {
37
+ return JSON.parse(readFileSync(path, "utf8")) as unknown;
38
+ } catch {
39
+ return {};
40
+ }
41
+ }
42
+
43
+ function isTruthyEnvFlag(value: string | undefined): boolean {
44
+ if (!value) return false;
45
+ return value === "1" || value.toLowerCase() === "true" || value.toLowerCase() === "yes";
46
+ }
47
+
48
+ function isPresentEnvFlag(value: string | undefined): boolean {
49
+ if (!value) return false;
50
+ const normalized = value.toLowerCase();
51
+ return normalized !== "0" && normalized !== "false" && normalized !== "no";
52
+ }
53
+
54
+ function isCiEnvironment(): boolean {
55
+ if (isTruthyEnvFlag(process.env.CI)) return true;
56
+ return CI_ENVIRONMENT_VARIABLES.some((name) => isPresentEnvFlag(process.env[name]));
57
+ }
58
+
59
+ function isInstallTelemetryEnabled(): boolean {
60
+ if (isCiEnvironment()) return false;
61
+ if (isTruthyEnvFlag(process.env.PI_OFFLINE)) return false;
62
+ if (process.env.PI_TELEMETRY !== undefined) return isTruthyEnvFlag(process.env.PI_TELEMETRY);
63
+
64
+ const settings = readJsonFile(join(getAgentDir(), "settings.json")) as PiSettingsDocument;
65
+ return settings.enableInstallTelemetry !== false;
66
+ }
67
+
68
+ function getPackageVersion(): string {
69
+ const packageJson = readJsonFile(fileURLToPath(new URL("../package.json", import.meta.url))) as { version?: unknown };
70
+ return typeof packageJson.version === "string" && packageJson.version.length > 0 ? packageJson.version : "0.0.0";
71
+ }
72
+
73
+ function getInstallTelemetryUserAgent(version: string): string {
74
+ const runtimeVersions = process.versions as NodeJS.ProcessVersions & { bun?: string };
75
+ const runtime = runtimeVersions.bun ? `bun/${runtimeVersions.bun}` : `node/${process.version}`;
76
+ return `${PACKAGE_NAME}/${version} (${process.platform}; ${runtime}; ${process.arch})`;
77
+ }
78
+
79
+ async function reportInstallTelemetryAsync(): Promise<void> {
80
+ try {
81
+ if (!isInstallTelemetryEnabled()) return;
82
+
83
+ const version = getPackageVersion();
84
+ const extensionsDir = join(getAgentDir(), "extensions");
85
+ const statePath = join(extensionsDir, "pi-agentsmd-install.json");
86
+ const state = readJsonFile(statePath) as InstallTelemetryState;
87
+ if (state.lastReportedVersion === version) return;
88
+
89
+ await mkdir(extensionsDir, { recursive: true });
90
+ await writeFile(statePath, `${JSON.stringify({ lastReportedVersion: version }, null, 2)}\n`, "utf8");
91
+
92
+ const params = new URLSearchParams({ tool: PACKAGE_NAME, version });
93
+ await fetch(`${INSTALL_TELEMETRY_URL}?${params.toString()}`, {
94
+ headers: { "User-Agent": getInstallTelemetryUserAgent(version) },
95
+ signal: AbortSignal.timeout(INSTALL_TELEMETRY_TIMEOUT_MS),
96
+ });
97
+ } catch {
98
+ // Best-effort telemetry: ignore settings, filesystem, and network failures.
99
+ }
100
+ }
101
+
102
+ export function reportInstallTelemetry(): void {
103
+ void reportInstallTelemetryAsync();
104
+ }
package/src/prompt.ts ADDED
@@ -0,0 +1,10 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { join, dirname } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+
5
+ const __dirname = dirname(fileURLToPath(import.meta.url));
6
+
7
+ export const INIT_PROMPT = readFileSync(
8
+ join(__dirname, "../prompts/init.md"),
9
+ "utf8",
10
+ );