geopilot 0.0.0-stage → 0.0.1-bootstrap.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +72 -2
- package/dist/agent/install.d.ts +23 -0
- package/dist/agent/install.js +75 -0
- package/dist/agent/install.js.map +1 -0
- package/dist/cache/runs.d.ts +18 -0
- package/dist/cache/runs.js +91 -0
- package/dist/cache/runs.js.map +1 -0
- package/dist/cli/args.d.ts +20 -0
- package/dist/cli/args.js +116 -0
- package/dist/cli/args.js.map +1 -0
- package/dist/cli/commands/agent.d.ts +2 -0
- package/dist/cli/commands/agent.js +48 -0
- package/dist/cli/commands/agent.js.map +1 -0
- package/dist/cli/commands/fix.d.ts +2 -0
- package/dist/cli/commands/fix.js +284 -0
- package/dist/cli/commands/fix.js.map +1 -0
- package/dist/cli/commands/init.d.ts +2 -0
- package/dist/cli/commands/init.js +62 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/insights.d.ts +17 -0
- package/dist/cli/commands/insights.js +143 -0
- package/dist/cli/commands/insights.js.map +1 -0
- package/dist/cli/commands/rules.d.ts +5 -0
- package/dist/cli/commands/rules.js +86 -0
- package/dist/cli/commands/rules.js.map +1 -0
- package/dist/cli/commands/scan.d.ts +14 -0
- package/dist/cli/commands/scan.js +127 -0
- package/dist/cli/commands/scan.js.map +1 -0
- package/dist/cli/commands-list.d.ts +6 -0
- package/dist/cli/commands-list.js +15 -0
- package/dist/cli/commands-list.js.map +1 -0
- package/dist/cli/context.d.ts +26 -0
- package/dist/cli/context.js +108 -0
- package/dist/cli/context.js.map +1 -0
- package/dist/cli/io.d.ts +16 -0
- package/dist/cli/io.js +28 -0
- package/dist/cli/io.js.map +1 -0
- package/dist/cli/main.d.ts +15 -0
- package/dist/cli/main.js +118 -0
- package/dist/cli/main.js.map +1 -0
- package/dist/collect/crawl.d.ts +51 -0
- package/dist/collect/crawl.js +187 -0
- package/dist/collect/crawl.js.map +1 -0
- package/dist/config/config.d.ts +86 -0
- package/dist/config/config.js +396 -0
- package/dist/config/config.js.map +1 -0
- package/dist/core/errors.d.ts +20 -0
- package/dist/core/errors.js +32 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/hash.d.ts +7 -0
- package/dist/core/hash.js +28 -0
- package/dist/core/hash.js.map +1 -0
- package/dist/core/redact.d.ts +3 -0
- package/dist/core/redact.js +23 -0
- package/dist/core/redact.js.map +1 -0
- package/dist/core/tty.d.ts +12 -0
- package/dist/core/tty.js +33 -0
- package/dist/core/tty.js.map +1 -0
- package/dist/core/version.d.ts +6 -0
- package/dist/core/version.js +10 -0
- package/dist/core/version.js.map +1 -0
- package/dist/fix/apply.d.ts +119 -0
- package/dist/fix/apply.js +334 -0
- package/dist/fix/apply.js.map +1 -0
- package/dist/fix/diff.d.ts +1 -0
- package/dist/fix/diff.js +35 -0
- package/dist/fix/diff.js.map +1 -0
- package/dist/fix/plan.d.ts +42 -0
- package/dist/fix/plan.js +385 -0
- package/dist/fix/plan.js.map +1 -0
- package/dist/fix/serve.d.ts +13 -0
- package/dist/fix/serve.js +112 -0
- package/dist/fix/serve.js.map +1 -0
- package/dist/fix/variants.d.ts +13 -0
- package/dist/fix/variants.js +8 -0
- package/dist/fix/variants.js.map +1 -0
- package/dist/frameworks/ast.d.ts +84 -0
- package/dist/frameworks/ast.js +231 -0
- package/dist/frameworks/ast.js.map +1 -0
- package/dist/frameworks/nextjs-app/analyze.d.ts +92 -0
- package/dist/frameworks/nextjs-app/analyze.js +350 -0
- package/dist/frameworks/nextjs-app/analyze.js.map +1 -0
- package/dist/frameworks/static/analyze.d.ts +18 -0
- package/dist/frameworks/static/analyze.js +66 -0
- package/dist/frameworks/static/analyze.js.map +1 -0
- package/dist/html/parse.d.ts +50 -0
- package/dist/html/parse.js +205 -0
- package/dist/html/parse.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/insights/validate.d.ts +74 -0
- package/dist/insights/validate.js +213 -0
- package/dist/insights/validate.js.map +1 -0
- package/dist/net/address.d.ts +10 -0
- package/dist/net/address.js +116 -0
- package/dist/net/address.js.map +1 -0
- package/dist/net/fetch.d.ts +53 -0
- package/dist/net/fetch.js +281 -0
- package/dist/net/fetch.js.map +1 -0
- package/dist/repo/detect.d.ts +3 -0
- package/dist/repo/detect.js +92 -0
- package/dist/repo/detect.js.map +1 -0
- package/dist/repo/reader.d.ts +12 -0
- package/dist/repo/reader.js +97 -0
- package/dist/repo/reader.js.map +1 -0
- package/dist/report/render.d.ts +20 -0
- package/dist/report/render.js +176 -0
- package/dist/report/render.js.map +1 -0
- package/dist/robots/crawlers.d.ts +10 -0
- package/dist/robots/crawlers.js +20 -0
- package/dist/robots/crawlers.js.map +1 -0
- package/dist/robots/robots.d.ts +33 -0
- package/dist/robots/robots.js +133 -0
- package/dist/robots/robots.js.map +1 -0
- package/dist/rules/catalogue.d.ts +43 -0
- package/dist/rules/catalogue.js +361 -0
- package/dist/rules/catalogue.js.map +1 -0
- package/dist/rules/context.d.ts +36 -0
- package/dist/rules/context.js +129 -0
- package/dist/rules/context.js.map +1 -0
- package/dist/rules/evaluate.d.ts +11 -0
- package/dist/rules/evaluate.js +1070 -0
- package/dist/rules/evaluate.js.map +1 -0
- package/dist/rules/finalize.d.ts +34 -0
- package/dist/rules/finalize.js +93 -0
- package/dist/rules/finalize.js.map +1 -0
- package/dist/scan.d.ts +27 -0
- package/dist/scan.js +147 -0
- package/dist/scan.js.map +1 -0
- package/dist/scoring/compare.d.ts +21 -0
- package/dist/scoring/compare.js +47 -0
- package/dist/scoring/compare.js.map +1 -0
- package/dist/scoring/score.d.ts +21 -0
- package/dist/scoring/score.js +112 -0
- package/dist/scoring/score.js.map +1 -0
- package/dist/sitemap/sitemap.d.ts +10 -0
- package/dist/sitemap/sitemap.js +48 -0
- package/dist/sitemap/sitemap.js.map +1 -0
- package/dist/types.d.ts +155 -0
- package/dist/types.js +13 -0
- package/dist/types.js.map +1 -0
- package/hosts/claude-project/.claude/agents/geopilot-explainer.md +36 -0
- package/hosts/claude-project/.claude/agents/geopilot-fixer.md +42 -0
- package/hosts/claude-project/.claude/agents/geopilot-investigator.md +45 -0
- package/hosts/claude-project/.claude/agents/geopilot-reviewer.md +41 -0
- package/hosts/claude-project/.claude/agents/geopilot-scanner.md +47 -0
- package/hosts/claude-project/.claude/skills/geo/SKILL.md +95 -0
- package/hosts/claude-project/.claude/skills/geo/references/frameworks.md +20 -0
- package/hosts/claude-project/.claude/skills/geo/references/insight-contract.md +42 -0
- package/hosts/claude-project/.claude/skills/geo/references/safety.md +30 -0
- package/hosts/claude-project/.claude/skills/geo/references/workflow-explain.md +8 -0
- package/hosts/claude-project/.claude/skills/geo/references/workflow-fix.md +20 -0
- package/hosts/claude-project/.claude/skills/geo/references/workflow-init.md +6 -0
- package/hosts/claude-project/.claude/skills/geo/references/workflow-insights.md +13 -0
- package/hosts/claude-project/.claude/skills/geo/references/workflow-plan.md +13 -0
- package/hosts/claude-project/.claude/skills/geo/references/workflow-review.md +8 -0
- package/hosts/claude-project/.claude/skills/geo/references/workflow-scan.md +18 -0
- package/hosts/claude-project/.claude/skills/geo/schemas/insights.schema.json +255 -0
- package/hosts/claude-project/.claude/skills/geo/scripts/geo.ps1 +11 -0
- package/hosts/claude-project/.claude/skills/geo/scripts/geo.sh +11 -0
- package/hosts/claude-project/.claude/skills/geopilot-explain/SKILL.md +9 -0
- package/hosts/claude-project/.claude/skills/geopilot-fix/SKILL.md +12 -0
- package/hosts/claude-project/.claude/skills/geopilot-init/SKILL.md +15 -0
- package/hosts/claude-project/.claude/skills/geopilot-insights/SKILL.md +11 -0
- package/hosts/claude-project/.claude/skills/geopilot-review/SKILL.md +11 -0
- package/hosts/claude-project/.claude/skills/geopilot-scan/SKILL.md +11 -0
- package/hosts/geopilot/.claude-plugin/plugin.json +22 -0
- package/hosts/geopilot/README.md +25 -0
- package/hosts/geopilot/agents/explainer.agent.md +36 -0
- package/hosts/geopilot/agents/fixer.agent.md +42 -0
- package/hosts/geopilot/agents/investigator.agent.md +45 -0
- package/hosts/geopilot/agents/reviewer.agent.md +41 -0
- package/hosts/geopilot/agents/scanner.agent.md +47 -0
- package/hosts/geopilot/assets/icon.png +0 -0
- package/hosts/geopilot/skills/explain/SKILL.md +9 -0
- package/hosts/geopilot/skills/fix/SKILL.md +12 -0
- package/hosts/geopilot/skills/geo/SKILL.md +95 -0
- package/hosts/geopilot/skills/geo/references/frameworks.md +20 -0
- package/hosts/geopilot/skills/geo/references/insight-contract.md +42 -0
- package/hosts/geopilot/skills/geo/references/safety.md +30 -0
- package/hosts/geopilot/skills/geo/references/workflow-explain.md +8 -0
- package/hosts/geopilot/skills/geo/references/workflow-fix.md +20 -0
- package/hosts/geopilot/skills/geo/references/workflow-init.md +6 -0
- package/hosts/geopilot/skills/geo/references/workflow-insights.md +13 -0
- package/hosts/geopilot/skills/geo/references/workflow-plan.md +13 -0
- package/hosts/geopilot/skills/geo/references/workflow-review.md +8 -0
- package/hosts/geopilot/skills/geo/references/workflow-scan.md +18 -0
- package/hosts/geopilot/skills/geo/schemas/insights.schema.json +255 -0
- package/hosts/geopilot/skills/geo/scripts/geo.ps1 +11 -0
- package/hosts/geopilot/skills/geo/scripts/geo.sh +11 -0
- package/hosts/geopilot/skills/init/SKILL.md +15 -0
- package/hosts/geopilot/skills/insights/SKILL.md +11 -0
- package/hosts/geopilot/skills/review/SKILL.md +11 -0
- package/hosts/geopilot/skills/scan/SKILL.md +11 -0
- package/hosts/opencode/.opencode/agents/geopilot-explainer.md +39 -0
- package/hosts/opencode/.opencode/agents/geopilot-fixer.md +45 -0
- package/hosts/opencode/.opencode/agents/geopilot-investigator.md +48 -0
- package/hosts/opencode/.opencode/agents/geopilot-reviewer.md +44 -0
- package/hosts/opencode/.opencode/agents/geopilot-scanner.md +50 -0
- package/hosts/opencode/.opencode/commands/geopilot-explain.md +8 -0
- package/hosts/opencode/.opencode/commands/geopilot-fix.md +10 -0
- package/hosts/opencode/.opencode/commands/geopilot-init.md +12 -0
- package/hosts/opencode/.opencode/commands/geopilot-insights.md +10 -0
- package/hosts/opencode/.opencode/commands/geopilot-review.md +10 -0
- package/hosts/opencode/.opencode/commands/geopilot-scan.md +10 -0
- package/hosts/opencode/.opencode/skills/geo/SKILL.md +95 -0
- package/hosts/opencode/.opencode/skills/geo/references/frameworks.md +20 -0
- package/hosts/opencode/.opencode/skills/geo/references/insight-contract.md +42 -0
- package/hosts/opencode/.opencode/skills/geo/references/safety.md +30 -0
- package/hosts/opencode/.opencode/skills/geo/references/workflow-explain.md +8 -0
- package/hosts/opencode/.opencode/skills/geo/references/workflow-fix.md +20 -0
- package/hosts/opencode/.opencode/skills/geo/references/workflow-init.md +6 -0
- package/hosts/opencode/.opencode/skills/geo/references/workflow-insights.md +13 -0
- package/hosts/opencode/.opencode/skills/geo/references/workflow-plan.md +13 -0
- package/hosts/opencode/.opencode/skills/geo/references/workflow-review.md +8 -0
- package/hosts/opencode/.opencode/skills/geo/references/workflow-scan.md +18 -0
- package/hosts/opencode/.opencode/skills/geo/schemas/insights.schema.json +255 -0
- package/hosts/opencode/.opencode/skills/geo/scripts/geo.ps1 +11 -0
- package/hosts/opencode/.opencode/skills/geo/scripts/geo.sh +11 -0
- package/package.json +65 -4
- package/schemas/config-v1.json +392 -0
- package/schemas/insights-v1.json +255 -0
- package/schemas/merged-v1.json +71 -0
- package/schemas/report-v1.json +836 -0
- package/skill/geo/SKILL.md +95 -0
- package/skill/geo/references/frameworks.md +20 -0
- package/skill/geo/references/insight-contract.md +42 -0
- package/skill/geo/references/safety.md +30 -0
- package/skill/geo/references/workflow-explain.md +8 -0
- package/skill/geo/references/workflow-fix.md +20 -0
- package/skill/geo/references/workflow-init.md +6 -0
- package/skill/geo/references/workflow-insights.md +13 -0
- package/skill/geo/references/workflow-plan.md +13 -0
- package/skill/geo/references/workflow-review.md +8 -0
- package/skill/geo/references/workflow-scan.md +18 -0
- package/skill/geo/schemas/insights.schema.json +255 -0
- package/skill/geo/scripts/geo.ps1 +11 -0
- package/skill/geo/scripts/geo.sh +11 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,73 @@
|
|
|
1
|
-
#
|
|
1
|
+
# geopilot
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Find the observable issue, show the evidence, trace its source when reliable, propose the smallest safe change, and honestly report what was verified.**
|
|
4
|
+
|
|
5
|
+
geopilot is an open-source, local-first technical readiness auditor and source-aware remediation assistant for websites. It is an implementation of the GEO Build Specification v2.2.1: a deterministic CLI that is useful on its own, plus a portable agent skill that drives it from your coding agent.
|
|
6
|
+
|
|
7
|
+
> Technical readiness only. GEO does not measure or predict citations, rankings, traffic or inclusion in any AI or search product.
|
|
8
|
+
|
|
9
|
+
Docs: https://moelzanaty3.github.io/geopilot/
|
|
10
|
+
|
|
11
|
+
## Quick start
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npx geopilot scan https://www.example.com # any stack (T0)
|
|
15
|
+
npx geopilot scan . # repository: source locations on Next.js App Router / static HTML
|
|
16
|
+
npx geopilot scan . --url http://127.0.0.1:3000 # both: the strongest evidence
|
|
17
|
+
npx geopilot fix # dry run of closed-list fixes
|
|
18
|
+
npx geopilot fix --apply --approve <fixId> --serve # guarded fix, verified on a server GEO starts after the write
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### In your coding agent
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
/plugin install geopilot --marketplace moelzanaty3/geopilot # Claude Code
|
|
25
|
+
copilot plugin marketplace add moelzanaty3/geopilot && copilot plugin install geopilot@geopilot # GitHub Copilot CLI (provisional)
|
|
26
|
+
npx geopilot agent install --host opencode # OpenCode (provisional)
|
|
27
|
+
npx geopilot agent install --host claude-code # commit the agents into this repo instead
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Agents: `scanner`, `fixer`, `reviewer`, `investigator`, `explainer`. Commands: `scan`, `fix`, `review`, `explain`, `insights`, `init`. They drive the pinned CLI, keep engine findings apart from their own recommendations, and never apply a guarded fix without its id.
|
|
31
|
+
|
|
32
|
+
## What it does
|
|
33
|
+
|
|
34
|
+
| | |
|
|
35
|
+
| --- | --- |
|
|
36
|
+
| **Rules** | GEO-013 robots reachability · GEO-009 search-crawler access vs declared policy · GEO-014 indexability of listed/linked routes · GEO-015 canonicals · GEO-003 server HTML content · GEO-004 JSON-LD · GEO-011 sitemaps · GEO-012 title/description/lang · GEO-016 server-rendered links · GEO-017 snippet restrictions · GEO-002 accessibility subset · GEO-101 app association files; GEO-010 and GEO-102 informational |
|
|
37
|
+
| **Outputs** | Readiness, coverage, confidence and assessment scope, kept separate. Readiness counts direct evidence only, never passes a rule on part of its sub-checks, is capped at 40 on blocker conditions, and is hidden below 50% coverage |
|
|
38
|
+
| **Provenance** | `exact` / `file` / `candidate` / `unmapped` / `absent`, read from source as AST — never executed — with documented downgrades (middleware, i18n, dynamic routes, unknown Next.js majors) |
|
|
39
|
+
| **Fixes** | S1 sitemap line in robots.txt, S2 `lang` on root `<html>` (safe); G1 remove literal noindex, G2 add canonical, G3 static `app/sitemap.ts` (guarded). Snapshots, byte-exact rollback, V1–V4 verification |
|
|
40
|
+
| **Freshness** | V4 counts only when GEO itself started your dev server after the write (`fix.serve`, `--serve`). Anything else is `applied_unverified`, exit 6 |
|
|
41
|
+
| **Safety** | SSRF guard that pins the validated address to the socket; private targets only when named; robots.txt respected; no telemetry, accounts or model calls |
|
|
42
|
+
|
|
43
|
+
## Repository layout
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
packages/geopilot/ the published CLI and library (src/, test/, schemas/)
|
|
47
|
+
skill/ canonical agent kit: the geo skill, agents/, commands/ (the only copy a human edits)
|
|
48
|
+
plugins/ generated host plugins (Claude Code + Copilot, OpenCode, project install)
|
|
49
|
+
web/ the documentation site (Next.js static export → GitHub Pages)
|
|
50
|
+
docs/adr/ decisions taken while implementing the specification
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Development
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
corepack enable
|
|
57
|
+
pnpm install
|
|
58
|
+
pnpm typecheck
|
|
59
|
+
pnpm test # fixtures A–E, 10k-case scoring properties, SSRF, fix engine incl. real V4 serve runs
|
|
60
|
+
pnpm build
|
|
61
|
+
pnpm publish:local # install this working tree as the global geopilot (pnpm publish:local:clean removes it)
|
|
62
|
+
pnpm web:dev # docs site on http://localhost:3000
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Requires Node 22.18 or newer. Commits follow Conventional Commits; merges to `main` release through semantic-release with npm trusted publishing (see [Releases](https://moelzanaty3.github.io/geopilot/docs/releases/)).
|
|
66
|
+
|
|
67
|
+
## Status
|
|
68
|
+
|
|
69
|
+
This is the Phase 1 alpha slice with the parts of Phase 2 it needs to stay honest. Not yet built: a browser renderer (GEO-003/GEO-002 report `not_evaluated`), SARIF and the GitHub Action, the CLI `review` command, baselines and hooks, fixes G4/G5, Cursor and Codex packages. See [ADR-0004](https://github.com/moelzanaty3/geopilot/blob/main/docs/adr/0004-phase-scope.md).
|
|
70
|
+
|
|
71
|
+
## License
|
|
72
|
+
|
|
73
|
+
Apache-2.0. See [LICENSE](https://github.com/moelzanaty3/geopilot/blob/main/LICENSE).
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type Host = 'claude-code' | 'opencode' | 'agents-md';
|
|
2
|
+
export type HostStatus = 'supported' | 'provisional' | 'marketplace' | 'not_available';
|
|
3
|
+
export declare const HOSTS: readonly {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
readonly status: HostStatus;
|
|
6
|
+
readonly note: string;
|
|
7
|
+
}[];
|
|
8
|
+
export declare const VERSION_PLACEHOLDER = "{{ENGINE_VERSION}}";
|
|
9
|
+
/** A generated host bundle: published under hosts/, in the repository under plugins/. */
|
|
10
|
+
export declare function bundleSource(bundle: 'claude-project' | 'opencode' | 'geopilot'): string;
|
|
11
|
+
export declare function skillSource(): string;
|
|
12
|
+
export declare function listSkillFiles(root: string): string[];
|
|
13
|
+
export declare function installedVersion(repoRoot: string): string | null;
|
|
14
|
+
export interface InstallPlan {
|
|
15
|
+
readonly host: Host;
|
|
16
|
+
readonly writes: readonly {
|
|
17
|
+
readonly path: string;
|
|
18
|
+
readonly content: string;
|
|
19
|
+
readonly exists: boolean;
|
|
20
|
+
}[];
|
|
21
|
+
}
|
|
22
|
+
export declare function planInstall(repoRoot: string, host: Host): InstallPlan;
|
|
23
|
+
export declare function executeInstall(plan: InstallPlan): void;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, join, relative } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { TOOL_VERSION } from "../core/version.js";
|
|
5
|
+
export const HOSTS = [
|
|
6
|
+
{ id: 'claude-code', status: 'supported', note: 'project install: .claude/agents and .claude/skills; or the plugin: /plugin install geopilot --marketplace moelzanaty3/geopilot' },
|
|
7
|
+
{ id: 'opencode', status: 'provisional', note: 'project install: .opencode/agents, .opencode/commands, .opencode/skills' },
|
|
8
|
+
{ id: 'copilot', status: 'marketplace', note: 'copilot plugin marketplace add moelzanaty3/geopilot && copilot plugin install geopilot@geopilot (provisional)' },
|
|
9
|
+
{ id: 'agents-md', status: 'provisional', note: 'a section in AGENTS.md, with --write-agents-md' },
|
|
10
|
+
{ id: 'cursor', status: 'not_available', note: 'not tested yet; use agents-md' },
|
|
11
|
+
{ id: 'codex', status: 'not_available', note: 'not tested yet; use agents-md' },
|
|
12
|
+
];
|
|
13
|
+
export const VERSION_PLACEHOLDER = '{{ENGINE_VERSION}}';
|
|
14
|
+
/** A generated host bundle: published under hosts/, in the repository under plugins/. */
|
|
15
|
+
export function bundleSource(bundle) {
|
|
16
|
+
const published = fileURLToPath(new URL(`../../hosts/${bundle}/`, import.meta.url));
|
|
17
|
+
if (existsSync(published))
|
|
18
|
+
return published;
|
|
19
|
+
return fileURLToPath(new URL(`../../../../plugins/${bundle}/`, import.meta.url));
|
|
20
|
+
}
|
|
21
|
+
export function skillSource() {
|
|
22
|
+
return join(bundleSource('claude-project'), '.claude', 'skills', 'geo');
|
|
23
|
+
}
|
|
24
|
+
export function listSkillFiles(root) {
|
|
25
|
+
const out = [];
|
|
26
|
+
const walk = (dir) => {
|
|
27
|
+
for (const name of readdirSync(dir).sort()) {
|
|
28
|
+
const abs = join(dir, name);
|
|
29
|
+
if (statSync(abs).isDirectory())
|
|
30
|
+
walk(abs);
|
|
31
|
+
else
|
|
32
|
+
out.push(relative(root, abs).split('\\').join('/'));
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
walk(root);
|
|
36
|
+
return out;
|
|
37
|
+
}
|
|
38
|
+
export function installedVersion(repoRoot) {
|
|
39
|
+
const file = join(repoRoot, '.claude', 'skills', 'geo', 'SKILL.md');
|
|
40
|
+
if (!existsSync(file))
|
|
41
|
+
return null;
|
|
42
|
+
const m = /engine-version:\s*"?([^"\n]+)"?/.exec(readFileSync(file, 'utf8'));
|
|
43
|
+
return m ? m[1].trim() : null;
|
|
44
|
+
}
|
|
45
|
+
const AGENTS_START = '<!-- geopilot:begin -->';
|
|
46
|
+
const AGENTS_END = '<!-- geopilot:end -->';
|
|
47
|
+
export function planInstall(repoRoot, host) {
|
|
48
|
+
if (host === 'claude-code' || host === 'opencode') {
|
|
49
|
+
const src = host === 'claude-code' ? bundleSource('claude-project') : bundleSource('opencode');
|
|
50
|
+
const writes = listSkillFiles(src).map((rel) => {
|
|
51
|
+
const content = readFileSync(join(src, rel), 'utf8').replaceAll(VERSION_PLACEHOLDER, TOOL_VERSION);
|
|
52
|
+
const path = join(repoRoot, rel);
|
|
53
|
+
return { path, content, exists: existsSync(path) };
|
|
54
|
+
});
|
|
55
|
+
return { host, writes };
|
|
56
|
+
}
|
|
57
|
+
const path = join(repoRoot, 'AGENTS.md');
|
|
58
|
+
const section = `${AGENTS_START}\n## geopilot (GEO technical readiness)\n\nUse the geopilot CLI for technical readiness checks; never claim rule outcomes it did not report.\n\n- Scan: \`npx geopilot@${TOOL_VERSION} scan --format json\`\n- Explain a rule: \`npx geopilot@${TOOL_VERSION} explain <ruleId>\`\n- Fixes are dry-run by default; apply only after the user approves each guarded fix (\`--approve <fixId>\`).\n- Label your own file attributions as agent-suggested; they are not engine provenance.\n- Report verification honestly: \`applied_unverified\` is not success.\n\nTechnical readiness only. GEO does not measure or predict citations, rankings, traffic or inclusion in any AI or search product.\n${AGENTS_END}\n`;
|
|
59
|
+
const exists = existsSync(path);
|
|
60
|
+
let content = section;
|
|
61
|
+
if (exists) {
|
|
62
|
+
const current = readFileSync(path, 'utf8');
|
|
63
|
+
const s = current.indexOf(AGENTS_START);
|
|
64
|
+
const e = current.indexOf(AGENTS_END);
|
|
65
|
+
content = s !== -1 && e > s ? `${current.slice(0, s)}${section}${current.slice(e + AGENTS_END.length + 1)}` : `${current.replace(/\n*$/, '\n\n')}${section}`;
|
|
66
|
+
}
|
|
67
|
+
return { host, writes: [{ path, content, exists }] };
|
|
68
|
+
}
|
|
69
|
+
export function executeInstall(plan) {
|
|
70
|
+
for (const w of plan.writes) {
|
|
71
|
+
mkdirSync(dirname(w.path), { recursive: true });
|
|
72
|
+
writeFileSync(w.path, w.content, { mode: w.path.endsWith('.sh') ? 0o755 : 0o644 });
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
//# sourceMapp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M,CAAC,CAAC;QAC3C,MAAM,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QACxC,MAAM,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QACtC,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;IAC/J,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;AACvD,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,IAAiB;IAC9C,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QAC5B,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAChD,aAAa,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;IACrF,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Report } from '../types.ts';
|
|
2
|
+
export declare const RETAIN_RUNS = 10;
|
|
3
|
+
export declare const SNAPSHOT_MAX_BYTES: number;
|
|
4
|
+
export declare function userCacheDir(env?: NodeJS.ProcessEnv): string;
|
|
5
|
+
export declare function cacheRoot(repoRoot: string | null, env?: NodeJS.ProcessEnv): string;
|
|
6
|
+
export declare function ensureGeoDir(root: string): void;
|
|
7
|
+
export declare function runDir(root: string, runId: string): string;
|
|
8
|
+
export declare function snapshotName(url: string): string;
|
|
9
|
+
export declare function saveRun(root: string, report: Report, snapshots: ReadonlyMap<string, string>): string;
|
|
10
|
+
export declare function listRuns(root: string): string[];
|
|
11
|
+
export interface LoadedRun {
|
|
12
|
+
readonly report: Report;
|
|
13
|
+
readonly reportSha256: string;
|
|
14
|
+
readonly dir: string;
|
|
15
|
+
readonly dom: ReadonlyMap<string, string>;
|
|
16
|
+
}
|
|
17
|
+
export declare function loadRun(root: string, runId: string): LoadedRun | null;
|
|
18
|
+
export declare function latestRun(root: string): string | null;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { homedir, platform } from 'node:os';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { canonicalJson, sha256 } from "../core/hash.js";
|
|
5
|
+
import { redact } from "../core/redact.js";
|
|
6
|
+
// `.geo/runs/<runId>` inside a repository, otherwise the OS user cache
|
|
7
|
+
// (spec 5.1). Ten runs are kept. DOM snapshots are bounded and redacted; no
|
|
8
|
+
// cookies, auth headers or full response bodies beyond the cap are stored.
|
|
9
|
+
export const RETAIN_RUNS = 10;
|
|
10
|
+
export const SNAPSHOT_MAX_BYTES = 512 * 1024;
|
|
11
|
+
export function userCacheDir(env = process.env) {
|
|
12
|
+
if (env.GEO_CACHE_DIR)
|
|
13
|
+
return env.GEO_CACHE_DIR;
|
|
14
|
+
if (platform() === 'win32')
|
|
15
|
+
return join(env.LOCALAPPDATA ?? join(homedir(), 'AppData', 'Local'), 'geopilot');
|
|
16
|
+
if (platform() === 'darwin')
|
|
17
|
+
return join(homedir(), 'Library', 'Caches', 'geopilot');
|
|
18
|
+
return join(env.XDG_CACHE_HOME ?? join(homedir(), '.cache'), 'geopilot');
|
|
19
|
+
}
|
|
20
|
+
export function cacheRoot(repoRoot, env = process.env) {
|
|
21
|
+
return repoRoot ? join(repoRoot, '.geo') : userCacheDir(env);
|
|
22
|
+
}
|
|
23
|
+
export function ensureGeoDir(root) {
|
|
24
|
+
mkdirSync(join(root, 'runs'), { recursive: true });
|
|
25
|
+
const gi = join(root, '.gitignore');
|
|
26
|
+
if (root.endsWith('.geo') && !existsSync(gi))
|
|
27
|
+
writeFileSync(gi, '*\n');
|
|
28
|
+
}
|
|
29
|
+
export function runDir(root, runId) {
|
|
30
|
+
if (!/^r-[0-9TZ]+-[0-9a-f]{6}$/.test(runId))
|
|
31
|
+
throw new Error(`not a run id: ${runId}`);
|
|
32
|
+
return join(root, 'runs', runId);
|
|
33
|
+
}
|
|
34
|
+
export function snapshotName(url) {
|
|
35
|
+
return `${sha256(url).slice(0, 16)}.html`;
|
|
36
|
+
}
|
|
37
|
+
export function saveRun(root, report, snapshots) {
|
|
38
|
+
ensureGeoDir(root);
|
|
39
|
+
const dir = runDir(root, report.run.id);
|
|
40
|
+
mkdirSync(join(dir, 'dom'), { recursive: true });
|
|
41
|
+
const json = canonicalJson(report);
|
|
42
|
+
writeFileSync(join(dir, 'report.json'), json);
|
|
43
|
+
const index = {};
|
|
44
|
+
for (const [url, html] of snapshots) {
|
|
45
|
+
const name = snapshotName(url);
|
|
46
|
+
const bounded = Buffer.byteLength(html) > SNAPSHOT_MAX_BYTES ? Buffer.from(html).subarray(0, SNAPSHOT_MAX_BYTES).toString('utf8') : html;
|
|
47
|
+
writeFileSync(join(dir, 'dom', name), redact(bounded));
|
|
48
|
+
index[url] = name;
|
|
49
|
+
}
|
|
50
|
+
writeFileSync(join(dir, 'dom', 'index.json'), canonicalJson(index));
|
|
51
|
+
prune(root);
|
|
52
|
+
return dir;
|
|
53
|
+
}
|
|
54
|
+
export function listRuns(root) {
|
|
55
|
+
const dir = join(root, 'runs');
|
|
56
|
+
if (!existsSync(dir))
|
|
57
|
+
return [];
|
|
58
|
+
return readdirSync(dir).filter((d) => /^r-/.test(d)).sort();
|
|
59
|
+
}
|
|
60
|
+
function prune(root) {
|
|
61
|
+
const runs = listRuns(root);
|
|
62
|
+
for (const old of runs.slice(0, Math.max(0, runs.length - RETAIN_RUNS))) {
|
|
63
|
+
// Runs holding fix snapshots are kept: rollback depends on them.
|
|
64
|
+
if (existsSync(join(root, 'runs', old, 'fix')))
|
|
65
|
+
continue;
|
|
66
|
+
rmSync(join(root, 'runs', old), { recursive: true, force: true });
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
export function loadRun(root, runId) {
|
|
70
|
+
const dir = runDir(root, runId);
|
|
71
|
+
const file = join(dir, 'report.json');
|
|
72
|
+
if (!existsSync(file))
|
|
73
|
+
return null;
|
|
74
|
+
const text = readFileSync(file, 'utf8');
|
|
75
|
+
const dom = new Map();
|
|
76
|
+
const idx = join(dir, 'dom', 'index.json');
|
|
77
|
+
if (existsSync(idx)) {
|
|
78
|
+
const index = JSON.parse(readFileSync(idx, 'utf8'));
|
|
79
|
+
for (const [url, name] of Object.entries(index)) {
|
|
80
|
+
const p = join(dir, 'dom', name);
|
|
81
|
+
if (existsSync(p))
|
|
82
|
+
dom.set(url, readFileSync(p, 'utf8'));
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return { report: JSON.parse(text), reportSha256: sha256(text), dir, dom };
|
|
86
|
+
}
|
|
87
|
+
export function latestRun(root) {
|
|
88
|
+
const runs = listRuns(root).filter((r) => existsSync(join(root, 'runs', r, 'report.json')));
|
|
89
|
+
return runs[runs.length - 1] ?? null;
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=runs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runs.js","sourceRoot":"","sources":["../../src/cache/runs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,aA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C,IAAI,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AACtF,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;IAC5F,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC;AACvC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface FlagSpec {
|
|
2
|
+
readonly name: string;
|
|
3
|
+
readonly type: 'boolean' | 'string' | 'multi';
|
|
4
|
+
readonly short?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const GLOBAL_FLAGS: readonly FlagSpec[];
|
|
7
|
+
export declare const SCAN_FLAGS: readonly FlagSpec[];
|
|
8
|
+
export declare const FIX_FLAGS: readonly FlagSpec[];
|
|
9
|
+
export declare const INIT_FLAGS: readonly FlagSpec[];
|
|
10
|
+
export declare const AGENT_FLAGS: readonly FlagSpec[];
|
|
11
|
+
export declare const RULES_FLAGS: readonly FlagSpec[];
|
|
12
|
+
export declare const INSIGHTS_FLAGS: readonly FlagSpec[];
|
|
13
|
+
export interface Parsed {
|
|
14
|
+
readonly positionals: string[];
|
|
15
|
+
readonly bool: ReadonlySet<string>;
|
|
16
|
+
readonly str: ReadonlyMap<string, string>;
|
|
17
|
+
readonly multi: ReadonlyMap<string, string[]>;
|
|
18
|
+
}
|
|
19
|
+
export declare function parseArgs(argv: readonly string[], specs: readonly FlagSpec[]): Parsed;
|
|
20
|
+
export declare function intFlag(p: Parsed, name: string, min: number, max: number): number | undefined;
|
package/dist/cli/args.js
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { usage } from "../core/errors.js";
|
|
2
|
+
export const GLOBAL_FLAGS = [
|
|
3
|
+
{ name: 'config', type: 'string' },
|
|
4
|
+
{ name: 'cwd', type: 'string' },
|
|
5
|
+
{ name: 'format', type: 'multi' },
|
|
6
|
+
{ name: 'output', type: 'multi', short: 'o' },
|
|
7
|
+
{ name: 'non-interactive', type: 'boolean' },
|
|
8
|
+
{ name: 'yes', type: 'boolean', short: 'y' },
|
|
9
|
+
{ name: 'quiet', type: 'boolean', short: 'q' },
|
|
10
|
+
{ name: 'verbose', type: 'boolean' },
|
|
11
|
+
{ name: 'no-color', type: 'boolean' },
|
|
12
|
+
{ name: 'no-cache', type: 'boolean' },
|
|
13
|
+
{ name: 'print-config', type: 'boolean' },
|
|
14
|
+
{ name: 'help', type: 'boolean', short: 'h' },
|
|
15
|
+
];
|
|
16
|
+
export const SCAN_FLAGS = [
|
|
17
|
+
{ name: 'url', type: 'multi' },
|
|
18
|
+
{ name: 'max-pages', type: 'string' },
|
|
19
|
+
{ name: 'max-depth', type: 'string' },
|
|
20
|
+
{ name: 'routes', type: 'multi' },
|
|
21
|
+
{ name: 'render', type: 'string' },
|
|
22
|
+
{ name: 'follow-external', type: 'boolean' },
|
|
23
|
+
{ name: 'ignore-robots', type: 'boolean' },
|
|
24
|
+
{ name: 'fail-on', type: 'string' },
|
|
25
|
+
{ name: 'min-readiness', type: 'string' },
|
|
26
|
+
{ name: 'fail-on-incomplete', type: 'boolean' },
|
|
27
|
+
{ name: 'baseline', type: 'string' },
|
|
28
|
+
{ name: 'rule', type: 'multi' },
|
|
29
|
+
{ name: 'skip-rule', type: 'multi' },
|
|
30
|
+
];
|
|
31
|
+
export const FIX_FLAGS = [
|
|
32
|
+
{ name: 'rule', type: 'multi' },
|
|
33
|
+
{ name: 'apply', type: 'boolean' },
|
|
34
|
+
{ name: 'approve', type: 'multi' },
|
|
35
|
+
{ name: 'verify', type: 'string' },
|
|
36
|
+
{ name: 'rollback', type: 'string' },
|
|
37
|
+
{ name: 'verify-cmd', type: 'multi' },
|
|
38
|
+
{ name: 'serve', type: 'boolean' },
|
|
39
|
+
{ name: 'allow-dirty', type: 'boolean' },
|
|
40
|
+
{ name: 'url', type: 'multi' },
|
|
41
|
+
];
|
|
42
|
+
export const INIT_FLAGS = [
|
|
43
|
+
{ name: 'origin', type: 'string' },
|
|
44
|
+
{ name: 'language', type: 'string' },
|
|
45
|
+
{ name: 'force', type: 'boolean' },
|
|
46
|
+
];
|
|
47
|
+
export const AGENT_FLAGS = [
|
|
48
|
+
{ name: 'host', type: 'string' },
|
|
49
|
+
{ name: 'write-agents-md', type: 'boolean' },
|
|
50
|
+
];
|
|
51
|
+
export const RULES_FLAGS = [
|
|
52
|
+
{ name: 'all', type: 'boolean' },
|
|
53
|
+
{ name: 'json', type: 'boolean' },
|
|
54
|
+
];
|
|
55
|
+
export const INSIGHTS_FLAGS = [{ name: 'run', type: 'string' }];
|
|
56
|
+
export function parseArgs(argv, specs) {
|
|
57
|
+
const byName = new Map(specs.map((s) => [s.name, s]));
|
|
58
|
+
const byShort = new Map(specs.filter((s) => s.short).map((s) => [s.short, s]));
|
|
59
|
+
const positionals = [];
|
|
60
|
+
const bool = new Set();
|
|
61
|
+
const str = new Map();
|
|
62
|
+
const multi = new Map();
|
|
63
|
+
for (let i = 0; i < argv.length; i++) {
|
|
64
|
+
const arg = argv[i];
|
|
65
|
+
if (arg === '--') {
|
|
66
|
+
positionals.push(...argv.slice(i + 1));
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
let spec;
|
|
70
|
+
let inline;
|
|
71
|
+
if (arg.startsWith('--')) {
|
|
72
|
+
const eq = arg.indexOf('=');
|
|
73
|
+
const name = eq === -1 ? arg.slice(2) : arg.slice(2, eq);
|
|
74
|
+
inline = eq === -1 ? undefined : arg.slice(eq + 1);
|
|
75
|
+
spec = byName.get(name);
|
|
76
|
+
if (!spec)
|
|
77
|
+
throw usage(`unknown flag --${name}`, 'Run geopilot --help for the flags each command takes.');
|
|
78
|
+
}
|
|
79
|
+
else if (arg.startsWith('-') && arg.length === 2) {
|
|
80
|
+
spec = byShort.get(arg[1]);
|
|
81
|
+
if (!spec)
|
|
82
|
+
throw usage(`unknown flag ${arg}`);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
positionals.push(arg);
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
if (spec.type === 'boolean') {
|
|
89
|
+
if (inline !== undefined)
|
|
90
|
+
throw usage(`--${spec.name} takes no value`);
|
|
91
|
+
bool.add(spec.name);
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
const value = inline ?? argv[++i];
|
|
95
|
+
if (value === undefined || (inline === undefined && value.startsWith('--')))
|
|
96
|
+
throw usage(`--${spec.name} needs a value`);
|
|
97
|
+
if (spec.type === 'string') {
|
|
98
|
+
if (str.has(spec.name))
|
|
99
|
+
throw usage(`--${spec.name} was given twice`);
|
|
100
|
+
str.set(spec.name, value);
|
|
101
|
+
}
|
|
102
|
+
else
|
|
103
|
+
multi.set(spec.name, [...(multi.get(spec.name) ?? []), value]);
|
|
104
|
+
}
|
|
105
|
+
return { positionals, bool, str, multi };
|
|
106
|
+
}
|
|
107
|
+
export function intFlag(p, name, min, max) {
|
|
108
|
+
const v = p.str.get(name);
|
|
109
|
+
if (v === undefined)
|
|
110
|
+
return undefined;
|
|
111
|
+
const n = Number(v);
|
|
112
|
+
if (!Number.isInteger(n) || n < min || n > max)
|
|
113
|
+
throw usage(`--${name} must be an integer from ${min} to ${max}`);
|
|
114
|
+
return n;
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=args.js.map
|