@codsy/cli 0.0.0-stage → 1.0.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 (80) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +227 -2
  3. package/dist/check-screen-OZJD7UHU.js +80 -0
  4. package/dist/chunk-46NW6PYM.js +115 -0
  5. package/dist/chunk-52CMOWJF.js +59 -0
  6. package/dist/chunk-6AVERKMZ.js +17 -0
  7. package/dist/chunk-BJYMGFW2.js +14 -0
  8. package/dist/chunk-FVNSMO6G.js +313 -0
  9. package/dist/chunk-JVEULAOD.js +24 -0
  10. package/dist/chunk-KFHC377Y.js +21 -0
  11. package/dist/chunk-MOIYJ6UU.js +48 -0
  12. package/dist/chunk-TDOJ55BG.js +120 -0
  13. package/dist/chunk-UWXPACZ7.js +54 -0
  14. package/dist/cli.d.ts +5 -0
  15. package/dist/cli.js +2032 -0
  16. package/dist/home-screen-UIUS4UOT.js +206 -0
  17. package/dist/init-wizard-MXAFTYCQ.js +54 -0
  18. package/dist/new-schema-wizard-NYIHF47J.js +123 -0
  19. package/dist/new-skill-wizard-AZJ5DLDM.js +121 -0
  20. package/package.json +66 -4
  21. package/templates/blank/.github/PULL_REQUEST_TEMPLATE.md +7 -0
  22. package/templates/blank/.github/workflows/codsy.yml +33 -0
  23. package/templates/blank/AGENTS.md +8 -0
  24. package/templates/blank/CODEOWNERS +4 -0
  25. package/templates/blank/README.md +12 -0
  26. package/templates/blank/codsy.config.yaml +1 -0
  27. package/templates/blank/context/company.md +4 -0
  28. package/templates/blank/context/customers.md +4 -0
  29. package/templates/blank/context/industry.md +4 -0
  30. package/templates/blank/context/operations.md +4 -0
  31. package/templates/blank/context/products.md +4 -0
  32. package/templates/blank/context/strategy.md +4 -0
  33. package/templates/blank/evals/.gitkeep +0 -0
  34. package/templates/blank/schemas/.gitkeep +0 -0
  35. package/templates/blank/skills/.gitkeep +0 -0
  36. package/templates/finance/.github/PULL_REQUEST_TEMPLATE.md +8 -0
  37. package/templates/finance/.github/workflows/codsy.yml +33 -0
  38. package/templates/finance/AGENTS.md +14 -0
  39. package/templates/finance/CODEOWNERS +4 -0
  40. package/templates/finance/README.md +16 -0
  41. package/templates/finance/codsy.config.yaml +1 -0
  42. package/templates/finance/context/company.md +6 -0
  43. package/templates/finance/context/customers.md +5 -0
  44. package/templates/finance/context/industry.md +5 -0
  45. package/templates/finance/context/operations.md +6 -0
  46. package/templates/finance/context/products.md +4 -0
  47. package/templates/finance/context/strategy.md +4 -0
  48. package/templates/finance/evals/collections-classification/cases.yaml +81 -0
  49. package/templates/finance/schemas/account.schema.json +21 -0
  50. package/templates/finance/skills/collections-classification/SKILL.md +49 -0
  51. package/templates/sales/.github/PULL_REQUEST_TEMPLATE.md +7 -0
  52. package/templates/sales/.github/workflows/codsy.yml +33 -0
  53. package/templates/sales/AGENTS.md +11 -0
  54. package/templates/sales/CODEOWNERS +4 -0
  55. package/templates/sales/README.md +13 -0
  56. package/templates/sales/codsy.config.yaml +1 -0
  57. package/templates/sales/context/company.md +6 -0
  58. package/templates/sales/context/customers.md +5 -0
  59. package/templates/sales/context/industry.md +5 -0
  60. package/templates/sales/context/operations.md +5 -0
  61. package/templates/sales/context/products.md +4 -0
  62. package/templates/sales/context/strategy.md +4 -0
  63. package/templates/sales/evals/lead-qualification/cases.yaml +87 -0
  64. package/templates/sales/schemas/lead.schema.json +26 -0
  65. package/templates/sales/skills/lead-qualification/SKILL.md +46 -0
  66. package/templates/support/.github/PULL_REQUEST_TEMPLATE.md +7 -0
  67. package/templates/support/.github/workflows/codsy.yml +33 -0
  68. package/templates/support/AGENTS.md +11 -0
  69. package/templates/support/CODEOWNERS +4 -0
  70. package/templates/support/README.md +13 -0
  71. package/templates/support/codsy.config.yaml +1 -0
  72. package/templates/support/context/company.md +5 -0
  73. package/templates/support/context/customers.md +5 -0
  74. package/templates/support/context/industry.md +5 -0
  75. package/templates/support/context/operations.md +5 -0
  76. package/templates/support/context/products.md +4 -0
  77. package/templates/support/context/strategy.md +4 -0
  78. package/templates/support/evals/ticket-triage/cases.yaml +81 -0
  79. package/templates/support/schemas/ticket.schema.json +22 -0
  80. package/templates/support/skills/ticket-triage/SKILL.md +46 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
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 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 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 those 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
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Codsy Contributors
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,228 @@
1
- # Temporary Holding Version
1
+ <img src="assets/brand/codsy-hero.png" alt="Codsy" width="100%">
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ <p align="center">
4
+ Write down how your company makes decisions, in simple files that people and AI agents can both read.
5
+ </p>
6
+
7
+ ## What is Codsy, in one minute
8
+
9
+ Every company has rules that live in someone's head: "big customers go to a senior rep",
10
+ "refunds over $500 need a manager", "urgent tickets get answered in one hour".
11
+
12
+ Codsy helps you write those rules down as small text files, keep them in one folder,
13
+ and check them automatically. Think of it as a **spell checker for your company's
14
+ know-how**:
15
+
16
+ - You write a rule in plain English.
17
+ - Codsy tells you if something is missing, vague, or unsafe, and how to fix it.
18
+ - Codsy can test the rule with real examples to prove it gives the right answer.
19
+
20
+ ![Demo of codsy init, check, and explain](assets/demo/demo.gif)
21
+
22
+ ## What a rule looks like
23
+
24
+ Each rule is a file called `SKILL.md`. This is a real one:
25
+
26
+ ```markdown
27
+ ---
28
+ name: lead-qualification
29
+ description: Decide whether a new lead goes to sales, used when a lead form arrives.
30
+ ---
31
+
32
+ ## Decision logic
33
+
34
+ Send a lead to sales when the company has 50 or more employees.
35
+
36
+ ## Exceptions
37
+
38
+ Leads with no confirmed budget stay in nurture, no matter the size.
39
+ ```
40
+
41
+ That's it: a name, a short description, the rule, and its exceptions. Anyone can read
42
+ it, and an AI agent can follow it.
43
+
44
+ ## Pick your path
45
+
46
+ | You are... | Start here | Terminal needed? |
47
+ | ------------------------------------ | -------------------------------------------------------------- | ---------------- |
48
+ | A manager or CEO | [Use it in your browser](#path-1-use-it-in-your-browser) | No |
49
+ | Someone who owns a process | [Try it in 5 minutes](#path-2-try-it-in-5-minutes) | Yes, a little |
50
+ | A developer setting it up for a team | [Add it to your repository](#path-3-add-it-to-your-repository) | Yes |
51
+
52
+ ## Path 1: Use it in your browser
53
+
54
+ No installation, no terminal.
55
+
56
+ 1. Open the [starter template](https://github.com/faelreis/codsy-starter) on GitHub and
57
+ click **Use this template** to make your own copy.
58
+ 2. Open a file inside `skills/`, click the pencil icon, and write your rule.
59
+ 3. Save it as a **pull request** (GitHub offers this when you save).
60
+ 4. Wait a minute. Codsy leaves a comment on the pull request saying what, if anything,
61
+ needs fixing, and exactly how.
62
+ 5. Fix what it says, then merge. Your rule is now official and versioned.
63
+
64
+ ## Path 2: Try it in 5 minutes
65
+
66
+ You only need [Node.js](https://nodejs.org) 22.12 or newer. Check with `node --version`.
67
+
68
+ ### Step 1. Create a project
69
+
70
+ ```bash
71
+ npx @codsy/cli init my-project --template sales
72
+ cd my-project
73
+ ```
74
+
75
+ This creates a folder with a working example. Other templates: `blank`, `support`,
76
+ `finance`. Run `npx @codsy/cli init` with no options to be asked step by step instead.
77
+
78
+ ### Step 2. Look around
79
+
80
+ Your new folder has four parts. Each one answers a simple question:
81
+
82
+ | Folder | Question it answers | Example |
83
+ | ---------- | --------------------------- | ------------------------------------------------- |
84
+ | `skills/` | What do we decide? | "Who gets routed to sales?" |
85
+ | `schemas/` | What information do we use? | "A lead has a company size and a budget." |
86
+ | `context/` | Why do we do it this way? | "Our reps only have time for big accounts." |
87
+ | `evals/` | How do we know it works? | "A 120-person company with budget goes to sales." |
88
+
89
+ Open `skills/lead-qualification/SKILL.md` to see a complete example.
90
+
91
+ ### Step 3. Check it
92
+
93
+ ```bash
94
+ npx @codsy/cli check
95
+ ```
96
+
97
+ Codsy reads every file and reports problems such as a missing section, a vague rule, or a
98
+ password pasted by mistake. Each problem shows the file, the line, and the fix.
99
+
100
+ Don't understand a problem? Ask Codsy to explain it by its code:
101
+
102
+ ```bash
103
+ npx @codsy/cli explain CODSY010
104
+ ```
105
+
106
+ ### Step 4. Add your own rule
107
+
108
+ ```bash
109
+ npx @codsy/cli new skill
110
+ ```
111
+
112
+ Codsy asks a few plain questions (what is decided, when, the rule, the exceptions, two
113
+ examples) and writes the file for you, showing a preview as you answer. It also creates
114
+ an empty test file in `evals/` for your examples.
115
+
116
+ ### Step 5. Prove it gives the right answer (optional)
117
+
118
+ `codsy check` tells you the rule is **well written**. `codsy eval` tells you it is
119
+ **right**: it asks an AI model to apply your rule to each test case and compares the
120
+ answer with the one you expected.
121
+
122
+ This step calls an AI provider, so it needs an API key and may cost a few cents:
123
+
124
+ ```bash
125
+ export ANTHROPIC_API_KEY=your-key-here
126
+ npx @codsy/cli eval
127
+ ```
128
+
129
+ Want to see what would be sent, without calling anything or spending money?
130
+
131
+ ```bash
132
+ npx @codsy/cli eval --dry-run
133
+ ```
134
+
135
+ The provider and model are set in `codsy.config.yaml`. See
136
+ [Writing a good skill](docs/writing-a-good-skill.md) for the options.
137
+
138
+ ### Your everyday routine
139
+
140
+ Once set up, working with Codsy is a short loop:
141
+
142
+ 1. Edit or add a rule.
143
+ 2. Run `codsy check` and fix what it reports.
144
+ 3. Add a test case to `evals/` when you find a new real example.
145
+ 4. Commit and open a pull request so someone reviews the change.
146
+
147
+ ## Path 3: Add it to your repository
148
+
149
+ Every project created with `codsy init` already includes a GitHub workflow at
150
+ `.github/workflows/codsy.yml`. Push the folder to GitHub and every pull request is
151
+ checked automatically.
152
+
153
+ To add it to an existing repository, create that file yourself:
154
+
155
+ ```yaml
156
+ name: Codsy
157
+
158
+ on:
159
+ pull_request:
160
+
161
+ permissions:
162
+ contents: read
163
+ pull-requests: write
164
+ security-events: write
165
+
166
+ jobs:
167
+ check:
168
+ runs-on: ubuntu-latest
169
+ steps:
170
+ - uses: actions/checkout@v7
171
+ - uses: faelreis/codsy/action@v1
172
+ with:
173
+ strict: true
174
+ ```
175
+
176
+ What happens on each pull request:
177
+
178
+ - Codsy checks every file and fails the build if there is an error.
179
+ - It posts one comment on the pull request with the full report, and updates it on
180
+ each new push.
181
+ - If you add an `ANTHROPIC_API_KEY` or `OPENAI_API_KEY` secret to the repository, it
182
+ also runs the eval tests. Without a key, only the free check runs.
183
+
184
+ More options: [GitHub Action](docs/github-action.md).
185
+
186
+ To install the CLI once instead of using `npx` every time:
187
+
188
+ ```bash
189
+ npm install --global codsy
190
+ ```
191
+
192
+ ## All commands
193
+
194
+ | Command | What it does |
195
+ | ---------------------- | --------------------------------------------------- |
196
+ | `codsy` | Shows the home screen |
197
+ | `codsy init [folder]` | Creates a new project |
198
+ | `codsy new skill` | Adds a new rule, with guided questions |
199
+ | `codsy new schema` | Adds a new data description, with guided questions |
200
+ | `codsy check` | Finds problems in your files |
201
+ | `codsy explain <CODE>` | Explains a problem code in plain words |
202
+ | `codsy eval [skill]` | Tests rules against their examples with an AI model |
203
+ | `codsy --help` | Lists every command and option |
204
+
205
+ Every question Codsy asks can also be answered with an option, so all commands work in
206
+ scripts and CI. Add `--plain` for simple text output with no colors or animation.
207
+
208
+ ## When not to use Codsy
209
+
210
+ - **One-time tasks.** Codsy is for decisions your company makes again and again.
211
+ - **Pure math.** Tax calculations or unit conversions should be code, not a written rule.
212
+ - **Facts that change every hour.** Prices and stock levels belong in a database, not
213
+ in a file that goes through review.
214
+
215
+ ## Learn more
216
+
217
+ - [Getting started](docs/getting-started.md): the full walkthrough and every option
218
+ - [Writing a good skill](docs/writing-a-good-skill.md): tips, test cases, AI providers
219
+ - [The methodology](docs/methodology.md): the thinking behind Codsy and how teams use it
220
+ - [Every rule Codsy checks](docs/rules/index.md)
221
+ - [FAQ](docs/faq.md)
222
+
223
+ Want to contribute? See [CONTRIBUTING.md](CONTRIBUTING.md). Rules live in `src/rules` as
224
+ pure `(project, config) => Diagnostic[]` functions.
225
+
226
+ ## License
227
+
228
+ Apache-2.0. See [LICENSE](LICENSE).
@@ -0,0 +1,80 @@
1
+ import {
2
+ nextStepLine,
3
+ summarize,
4
+ summaryLine
5
+ } from "./chunk-TDOJ55BG.js";
6
+ import {
7
+ detectCapabilitiesFromProcess,
8
+ hexToAnsiForeground
9
+ } from "./chunk-46NW6PYM.js";
10
+ import {
11
+ THEME
12
+ } from "./chunk-BJYMGFW2.js";
13
+
14
+ // src/ui/check-rich-format.ts
15
+ var ANSI_RESET = "\x1B[0m";
16
+ var ANSI_BOLD = "\x1B[1m";
17
+ function colorize(text, hex, colorLevel) {
18
+ const code = hexToAnsiForeground(hex, colorLevel);
19
+ return code ? `${code}${text}${ANSI_RESET}` : text;
20
+ }
21
+ function bold(text, colorLevel) {
22
+ return colorLevel === "none" ? text : `${ANSI_BOLD}${text}${ANSI_RESET}`;
23
+ }
24
+ function severityColor(severity) {
25
+ if (severity === "error") return THEME.error;
26
+ if (severity === "warn") return THEME.warning;
27
+ return THEME.dim;
28
+ }
29
+ function groupByFile(diagnostics) {
30
+ const groups = /* @__PURE__ */ new Map();
31
+ for (const diagnostic of diagnostics) {
32
+ const existing = groups.get(diagnostic.file);
33
+ if (existing) existing.push(diagnostic);
34
+ else groups.set(diagnostic.file, [diagnostic]);
35
+ }
36
+ return groups;
37
+ }
38
+ function formatRichText(diagnostics, colorLevel) {
39
+ const summary = summarize(diagnostics);
40
+ const summaryColor = summary.errorCount > 0 ? THEME.error : summary.warnCount > 0 ? THEME.warning : THEME.success;
41
+ if (diagnostics.length === 0) {
42
+ return `${colorize(summaryLine(summary), summaryColor, colorLevel)}
43
+ ${nextStepLine(summary)}
44
+ `;
45
+ }
46
+ const lines = [];
47
+ for (const [file, fileDiagnostics] of groupByFile(diagnostics)) {
48
+ lines.push(bold(file, colorLevel));
49
+ for (const diagnostic of fileDiagnostics) {
50
+ const label = colorize(
51
+ `${diagnostic.severity.toUpperCase()} ${diagnostic.ruleId}`,
52
+ severityColor(diagnostic.severity),
53
+ colorLevel
54
+ );
55
+ lines.push(` ${label} line ${diagnostic.line}: ${diagnostic.message}`);
56
+ if (diagnostic.fixHint) {
57
+ lines.push(` ${colorize("Fix:", THEME.dim, colorLevel)} ${diagnostic.fixHint}`);
58
+ }
59
+ }
60
+ lines.push("");
61
+ }
62
+ lines.push(colorize(summaryLine(summary), summaryColor, colorLevel));
63
+ lines.push(nextStepLine(summary));
64
+ return `${lines.join("\n")}
65
+ `;
66
+ }
67
+
68
+ // src/ui/check-screen.tsx
69
+ function renderCheckScreen(diagnostics) {
70
+ const capabilities = detectCapabilitiesFromProcess({
71
+ plainFlag: false,
72
+ noMotionFlag: false,
73
+ format: "pretty"
74
+ });
75
+ process.stdout.write(formatRichText(diagnostics, capabilities.colorLevel));
76
+ }
77
+ export {
78
+ renderCheckScreen
79
+ };
80
+ //# sourceMappingURL=check-screen-OZJD7UHU.js.map
@@ -0,0 +1,115 @@
1
+ import {
2
+ THEME
3
+ } from "./chunk-BJYMGFW2.js";
4
+
5
+ // src/ui/capabilities.ts
6
+ var DEFAULT_WIDTH = 80;
7
+ function detectCapabilities(input) {
8
+ const plain = !input.isTTY || input.plainFlag || input.format === "json" || input.format === "sarif" || Boolean(input.env.NO_COLOR) || Boolean(input.env.CI);
9
+ const colorLevel = plain ? "none" : colorLevelFromDepth(input.colorDepth);
10
+ const motionEnabled = !plain && !input.noMotionFlag && !input.env.CODSY_NO_MOTION;
11
+ const width = input.columns ?? DEFAULT_WIDTH;
12
+ return { isTTY: input.isTTY, width, colorLevel, motionEnabled, plain };
13
+ }
14
+ function detectCapabilitiesFromProcess(options) {
15
+ const stream = process.stdout;
16
+ const isTTY = Boolean(stream.isTTY);
17
+ return detectCapabilities({
18
+ isTTY,
19
+ columns: stream.columns,
20
+ colorDepth: isTTY && typeof stream.getColorDepth === "function" ? stream.getColorDepth() : void 0,
21
+ env: process.env,
22
+ plainFlag: options.plainFlag,
23
+ noMotionFlag: options.noMotionFlag,
24
+ format: options.format
25
+ });
26
+ }
27
+ function colorLevelFromDepth(depth) {
28
+ switch (depth) {
29
+ case 24:
30
+ return "truecolor";
31
+ case 8:
32
+ return "256";
33
+ case 4:
34
+ return "16";
35
+ default:
36
+ return "none";
37
+ }
38
+ }
39
+
40
+ // src/ui/mascot/grid.ts
41
+ var BASE_GRID = [
42
+ "..............#......",
43
+ "............#..#.....",
44
+ ".............#..#....",
45
+ "...........#..#.#....",
46
+ "............#.####...",
47
+ ".............###.##..",
48
+ "..............#######",
49
+ "..............###....",
50
+ "..............##.....",
51
+ ".....########.##.....",
52
+ "...#########..##.....",
53
+ ".###..#####..###.....",
54
+ "###.........###......",
55
+ "....##########.......",
56
+ "..###...#..#.........",
57
+ ".###....#..#.........",
58
+ "........#..#.........",
59
+ "........#..##........",
60
+ ".......###..###......"
61
+ ];
62
+ function hexToAnsiForeground(hex, colorLevel) {
63
+ if (colorLevel === "none") return null;
64
+ if (colorLevel === "truecolor") {
65
+ const [r, g, b] = hexToRgb(hex);
66
+ return `\x1B[38;2;${r};${g};${b}m`;
67
+ }
68
+ return `\x1B[38;5;${hexToAnsi256(hex)}m`;
69
+ }
70
+ var ANSI_RESET = "\x1B[0m";
71
+ function hexToRgb(hex) {
72
+ const value = Number.parseInt(hex.replace("#", ""), 16);
73
+ return [value >> 16 & 255, value >> 8 & 255, value & 255];
74
+ }
75
+ function hexToAnsi256(hex) {
76
+ const [r, g, b] = hexToRgb(hex);
77
+ const toIndex = (channel) => Math.round(channel / 255 * 5);
78
+ return 16 + 36 * toIndex(r) + 6 * toIndex(g) + toIndex(b);
79
+ }
80
+ function renderGridLines(grid, colorLevel) {
81
+ const rows = grid.length % 2 === 0 ? grid : [...grid, ".".repeat(grid[0]?.length ?? 0)];
82
+ const lines = [];
83
+ for (let i = 0; i < rows.length; i += 2) {
84
+ const top = rows[i] ?? "";
85
+ const bottom = rows[i + 1] ?? "";
86
+ const width = Math.max(top.length, bottom.length);
87
+ let line = "";
88
+ for (let col = 0; col < width; col += 1) {
89
+ const topFilled = top[col] === "#";
90
+ const bottomFilled = bottom[col] === "#";
91
+ line += pickHalfBlock(topFilled, bottomFilled);
92
+ }
93
+ lines.push(colorize(line, colorLevel));
94
+ }
95
+ return lines;
96
+ }
97
+ function pickHalfBlock(topFilled, bottomFilled) {
98
+ if (topFilled && bottomFilled) return "\u2588";
99
+ if (topFilled) return "\u2580";
100
+ if (bottomFilled) return "\u2584";
101
+ return " ";
102
+ }
103
+ function colorize(line, colorLevel) {
104
+ const code = hexToAnsiForeground(THEME.sand, colorLevel);
105
+ if (!code) return line;
106
+ return `${code}${line}${ANSI_RESET}`;
107
+ }
108
+
109
+ export {
110
+ detectCapabilitiesFromProcess,
111
+ BASE_GRID,
112
+ hexToAnsiForeground,
113
+ renderGridLines
114
+ };
115
+ //# sourceMappingURL=chunk-46NW6PYM.js.map
@@ -0,0 +1,59 @@
1
+ // src/cli/templates/skill-markdown.ts
2
+ function buildDescription(answers) {
3
+ return `${answers.purpose} Used when ${lowercaseFirst(answers.whenToUse)}`;
4
+ }
5
+ function lowercaseFirst(text) {
6
+ return text.length === 0 ? text : text[0].toLowerCase() + text.slice(1);
7
+ }
8
+ function buildSkillMarkdown(answers) {
9
+ const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
10
+ const examplesList = answers.examples.map((example, index) => `${index + 1}. ${example}`).join("\n");
11
+ return `---
12
+ name: ${answers.name}
13
+ description: ${buildDescription(answers)}
14
+ metadata:
15
+ owner: ${answers.owner}
16
+ last_reviewed: ${today}
17
+ review_every_days: 90
18
+ ---
19
+
20
+ ## Purpose
21
+
22
+ ${answers.purpose}
23
+
24
+ ## When to use
25
+
26
+ ${answers.whenToUse}
27
+
28
+ ## Input
29
+
30
+ ${answers.input}
31
+
32
+ ## Decision logic
33
+
34
+ ${answers.decisionLogic}
35
+
36
+ ## Exceptions
37
+
38
+ ${answers.exceptions}
39
+
40
+ ## Output
41
+
42
+ ${answers.output}
43
+
44
+ ## Examples
45
+
46
+ ${examplesList}
47
+ `;
48
+ }
49
+ function buildEvalsStub(skillName) {
50
+ return `skill: ${skillName}
51
+ cases: []
52
+ `;
53
+ }
54
+
55
+ export {
56
+ buildSkillMarkdown,
57
+ buildEvalsStub
58
+ };
59
+ //# sourceMappingURL=chunk-52CMOWJF.js.map