@abubakarsiddiik/portolan 0.0.0-stage → 0.1.1
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 +118 -2
- package/dist/args.d.ts +19 -0
- package/dist/args.d.ts.map +1 -0
- package/dist/args.js +67 -0
- package/dist/args.js.map +1 -0
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +4 -0
- package/dist/bin.js.map +1 -0
- package/dist/browser.d.ts +14 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +25 -0
- package/dist/browser.js.map +1 -0
- package/dist/cli.d.ts +23 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +180 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/bench.d.ts +28 -0
- package/dist/commands/bench.d.ts.map +1 -0
- package/dist/commands/bench.js +50 -0
- package/dist/commands/bench.js.map +1 -0
- package/dist/commands/compile.d.ts +35 -0
- package/dist/commands/compile.d.ts.map +1 -0
- package/dist/commands/compile.js +76 -0
- package/dist/commands/compile.js.map +1 -0
- package/dist/commands/export-skills.d.ts +17 -0
- package/dist/commands/export-skills.d.ts.map +1 -0
- package/dist/commands/export-skills.js +24 -0
- package/dist/commands/export-skills.js.map +1 -0
- package/dist/commands/init.d.ts +20 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +32 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/mcp.d.ts +18 -0
- package/dist/commands/mcp.d.ts.map +1 -0
- package/dist/commands/mcp.js +20 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/commands/qa.d.ts +9 -0
- package/dist/commands/qa.d.ts.map +1 -0
- package/dist/commands/qa.js +386 -0
- package/dist/commands/qa.js.map +1 -0
- package/dist/commands/serve.d.ts +27 -0
- package/dist/commands/serve.d.ts.map +1 -0
- package/dist/commands/serve.js +49 -0
- package/dist/commands/serve.js.map +1 -0
- package/dist/commands/verify.d.ts +30 -0
- package/dist/commands/verify.d.ts.map +1 -0
- package/dist/commands/verify.js +46 -0
- package/dist/commands/verify.js.map +1 -0
- package/dist/config.d.ts +44 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +93 -0
- package/dist/config.js.map +1 -0
- package/dist/doctor.d.ts +33 -0
- package/dist/doctor.d.ts.map +1 -0
- package/dist/doctor.js +214 -0
- package/dist/doctor.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/package.json +51 -3
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,119 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @abubakarsiddiik/portolan
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The `portolan` command.
|
|
4
|
+
|
|
5
|
+
## Run
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm --filter @abubakarsiddiik/portolan build
|
|
9
|
+
node packages/cli/dist/bin.js --help
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Commands
|
|
13
|
+
|
|
14
|
+
### `portolan init [dir]`
|
|
15
|
+
|
|
16
|
+
Writes a starting `portolan.config.json`, `policies/<site>.json` with an empty
|
|
17
|
+
allowlist, and the `maps/<site>/` and `skills/` directories. Existing files are
|
|
18
|
+
kept unless `--force` is passed.
|
|
19
|
+
|
|
20
|
+
Options: `--site <name>`, `--force`.
|
|
21
|
+
|
|
22
|
+
### `portolan serve`
|
|
23
|
+
|
|
24
|
+
Starts the HTTP and MCP server from the config.
|
|
25
|
+
|
|
26
|
+
Options: `--config <path>`, `--host`, `--port`, `--database`, `--maps`.
|
|
27
|
+
`SIGINT` and `SIGTERM` close the server and the database.
|
|
28
|
+
|
|
29
|
+
### `portolan mcp`
|
|
30
|
+
|
|
31
|
+
Serves MCP over stdio for a client that spawns the process. It prints nothing
|
|
32
|
+
on stdout except protocol frames. Reads `MAPS_DIR` and `DATABASE_PATH`, then
|
|
33
|
+
the config file. This is the command every install snippet uses.
|
|
34
|
+
|
|
35
|
+
### `portolan compile <trace...>`
|
|
36
|
+
|
|
37
|
+
Compiles trace JSON files into candidate ops and publishes a new map version.
|
|
38
|
+
The map supplies op names, schemas, and effects; the traces supply the
|
|
39
|
+
evidence. A url op's post-state is captured from a live browser when
|
|
40
|
+
`--base-url` is given.
|
|
41
|
+
|
|
42
|
+
Options: `--map <path>` (required), `--base-url <url>`,
|
|
43
|
+
`--outcome-checks <json>` (op name to the read op that proves the write),
|
|
44
|
+
`--trace <path>` (repeatable, instead of positionals), `--chrome <path>`,
|
|
45
|
+
`--headed`.
|
|
46
|
+
|
|
47
|
+
### `portolan verify`
|
|
48
|
+
|
|
49
|
+
Verifies a map's ops on a fresh session. Each op needs at least three param
|
|
50
|
+
sets; an op without one is reported unverified, and the command exits `1`.
|
|
51
|
+
|
|
52
|
+
Options: `--map <path>`, `--params <path>` (required), `--op <name>`
|
|
53
|
+
(repeatable), `--base-url <url>`, `--chrome <path>`, `--headed`.
|
|
54
|
+
|
|
55
|
+
The params file is a JSON object:
|
|
56
|
+
|
|
57
|
+
```json
|
|
58
|
+
{ "search": [{ "query": "tee" }, { "query": "mug" }, { "query": "cap" }] }
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### `portolan export-skills`
|
|
62
|
+
|
|
63
|
+
Exports a `portolan-<site>` skill from a map. Recipes are mined from any
|
|
64
|
+
`--trace` files; `--gotcha` adds a line under Gotchas.
|
|
65
|
+
|
|
66
|
+
Options: `--map <path>` (required), `--out <dir>` (default `skills`),
|
|
67
|
+
`--trace <path>` (repeatable), `--gotcha <text>` (repeatable).
|
|
68
|
+
|
|
69
|
+
### `portolan bench [suite]`
|
|
70
|
+
|
|
71
|
+
Runs a benchmark suite from the source checkout. `--list` prints the suites
|
|
72
|
+
(`pilot`, `n3`, `drift`, `conformance`, `oracle`, `local`). The benchmark
|
|
73
|
+
harness is not part of the published package.
|
|
74
|
+
|
|
75
|
+
### `portolan doctor [--json]`
|
|
76
|
+
|
|
77
|
+
Diagnoses the local install:
|
|
78
|
+
|
|
79
|
+
| Check | What it looks for | Status when missing |
|
|
80
|
+
|---|---|---|
|
|
81
|
+
| `node` | Node 22.12 or newer | fail |
|
|
82
|
+
| `browser` | `CHROME_PATH`, then Chrome/Chromium; runs `--version` | fail |
|
|
83
|
+
| `config` | `PORTOLAN_CONFIG`, else `./portolan.config.json`; must parse as a JSON object | fail if invalid, warn if absent |
|
|
84
|
+
| `providers` | `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, `GEMINI_API_KEY`, `OLLAMA_HOST` | warn |
|
|
85
|
+
| `clients` | Claude Desktop, Claude Code, Cursor, VS Code, Gemini CLI, Codex; does any name `portolan`? | warn |
|
|
86
|
+
|
|
87
|
+
Provider values are never printed, only the provider names.
|
|
88
|
+
|
|
89
|
+
## Exit codes
|
|
90
|
+
|
|
91
|
+
`0` success (warnings allowed), `1` a command failed, `2` an unknown command.
|
|
92
|
+
|
|
93
|
+
## Config
|
|
94
|
+
|
|
95
|
+
`portolan.config.json`, merged over defaults. Every option is documented with
|
|
96
|
+
its default in [docs/CONFIG.md](../../docs/CONFIG.md).
|
|
97
|
+
|
|
98
|
+
The short version:
|
|
99
|
+
|
|
100
|
+
```json
|
|
101
|
+
{
|
|
102
|
+
"site": "site",
|
|
103
|
+
"maps": "maps",
|
|
104
|
+
"skills": "skills",
|
|
105
|
+
"policies": "policies",
|
|
106
|
+
"database": "portolan.db",
|
|
107
|
+
"host": "127.0.0.1",
|
|
108
|
+
"port": 4200,
|
|
109
|
+
"headless": true,
|
|
110
|
+
"sessionTtlMs": 1800000,
|
|
111
|
+
"maxOpenSessions": 100,
|
|
112
|
+
"cleanupIntervalMs": 60000,
|
|
113
|
+
"recoverSessions": true,
|
|
114
|
+
"logLevel": "info"
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
`baseUrl` and `chrome` are optional. An unknown key is ignored so a newer
|
|
119
|
+
config does not break an older CLI.
|
package/dist/args.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type ParsedArgs = {
|
|
2
|
+
positional: string[];
|
|
3
|
+
flags: Record<string, string | true>;
|
|
4
|
+
/** Repeated `--flag value` pairs, in order. */
|
|
5
|
+
lists: Record<string, string[]>;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* A tiny argument parser: `--key value`, `--flag`, and positionals.
|
|
9
|
+
*
|
|
10
|
+
* A repeated flag keeps every value in `lists`; a single value also lands in
|
|
11
|
+
* `flags`. There is no dependency and no shell-style quoting, because the CLI
|
|
12
|
+
* is called by another program as often as by a person.
|
|
13
|
+
*/
|
|
14
|
+
export declare function parseArgs(argv: string[]): ParsedArgs;
|
|
15
|
+
export declare function stringFlag(args: ParsedArgs, name: string): string | undefined;
|
|
16
|
+
export declare function listFlag(args: ParsedArgs, name: string): string[];
|
|
17
|
+
export declare function numberFlag(args: ParsedArgs, name: string): number | undefined;
|
|
18
|
+
export declare function booleanFlag(args: ParsedArgs, name: string): boolean;
|
|
19
|
+
//# sourceMappingURL=args.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG;IACvB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;IACrC,+CAA+C;IAC/C,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;CACjC,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,UAAU,CA6CpD;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAG7E;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAEjE;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAM7E;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAEnE"}
|
package/dist/args.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A tiny argument parser: `--key value`, `--flag`, and positionals.
|
|
3
|
+
*
|
|
4
|
+
* A repeated flag keeps every value in `lists`; a single value also lands in
|
|
5
|
+
* `flags`. There is no dependency and no shell-style quoting, because the CLI
|
|
6
|
+
* is called by another program as often as by a person.
|
|
7
|
+
*/
|
|
8
|
+
export function parseArgs(argv) {
|
|
9
|
+
const positional = [];
|
|
10
|
+
const flags = {};
|
|
11
|
+
const lists = {};
|
|
12
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
13
|
+
const arg = argv[index];
|
|
14
|
+
if (arg === undefined)
|
|
15
|
+
continue;
|
|
16
|
+
if (!arg.startsWith("--") || arg === "--") {
|
|
17
|
+
positional.push(arg);
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
const body = arg.slice(2);
|
|
21
|
+
const equals = body.indexOf("=");
|
|
22
|
+
const key = equals === -1 ? body : body.slice(0, equals);
|
|
23
|
+
const inline = equals === -1 ? undefined : body.slice(equals + 1);
|
|
24
|
+
if (key.length === 0) {
|
|
25
|
+
positional.push(arg);
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
let value = true;
|
|
29
|
+
if (inline !== undefined) {
|
|
30
|
+
value = inline;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
const next = argv[index + 1];
|
|
34
|
+
if (next !== undefined && !next.startsWith("--")) {
|
|
35
|
+
value = next;
|
|
36
|
+
index += 1;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
flags[key] = value;
|
|
40
|
+
if (value !== true) {
|
|
41
|
+
const list = lists[key] ?? [];
|
|
42
|
+
list.push(value);
|
|
43
|
+
lists[key] = list;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return { positional, flags, lists };
|
|
47
|
+
}
|
|
48
|
+
export function stringFlag(args, name) {
|
|
49
|
+
const value = args.flags[name];
|
|
50
|
+
return typeof value === "string" ? value : undefined;
|
|
51
|
+
}
|
|
52
|
+
export function listFlag(args, name) {
|
|
53
|
+
return args.lists[name] ?? [];
|
|
54
|
+
}
|
|
55
|
+
export function numberFlag(args, name) {
|
|
56
|
+
const value = stringFlag(args, name);
|
|
57
|
+
if (value === undefined)
|
|
58
|
+
return undefined;
|
|
59
|
+
const parsed = Number(value);
|
|
60
|
+
if (!Number.isInteger(parsed))
|
|
61
|
+
throw new Error(`--${name} must be an integer`);
|
|
62
|
+
return parsed;
|
|
63
|
+
}
|
|
64
|
+
export function booleanFlag(args, name) {
|
|
65
|
+
return args.flags[name] === true || args.flags[name] === "true";
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=args.js.map
|
package/dist/args.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"args.js","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"AAOA;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAC,IAAc;IACtC,MA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AED,MAAM,UAAU,WAAW,CAAC,IAAgB,EAAE,IAAY;IACxD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,MAAM,CAAC;AAClE,CAAC"}
|
package/dist/bin.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":""}
|
package/dist/bin.js
ADDED
package/dist/bin.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,OAAO,CAAC,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { SessionRecord } from "@abubakarsiddiik/protocol";
|
|
2
|
+
import type { BrowserRegistry } from "@abubakarsiddiik/server";
|
|
3
|
+
import { Substrate } from "@abubakarsiddiik/substrate";
|
|
4
|
+
import type { CliConfig } from "./config.js";
|
|
5
|
+
export type BrowserFactory = (session: SessionRecord) => Promise<Substrate>;
|
|
6
|
+
/**
|
|
7
|
+
* Build the browser factory shared by `serve` and `mcp`.
|
|
8
|
+
*
|
|
9
|
+
* The browser is launched on the first fallback verb, registered so it can be
|
|
10
|
+
* closed with the server or the session, and given the site's egress policy
|
|
11
|
+
* when `policies/<site>.json` exists.
|
|
12
|
+
*/
|
|
13
|
+
export declare function createBrowserFactory(config: CliConfig, browsers: BrowserRegistry): BrowserFactory | undefined;
|
|
14
|
+
//# sourceMappingURL=browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAA4C,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAEjG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,EAAE,aAAa,KAAK,OAAO,CAAC,SAAS,CAAC,CAAC;AAE5E;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,SAAS,EACjB,QAAQ,EAAE,eAAe,GACxB,cAAc,GAAG,SAAS,CAmB5B"}
|
package/dist/browser.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { findChrome, loadPolicy, PlaywrightEngine, Substrate } from "@abubakarsiddiik/substrate";
|
|
2
|
+
/**
|
|
3
|
+
* Build the browser factory shared by `serve` and `mcp`.
|
|
4
|
+
*
|
|
5
|
+
* The browser is launched on the first fallback verb, registered so it can be
|
|
6
|
+
* closed with the server or the session, and given the site's egress policy
|
|
7
|
+
* when `policies/<site>.json` exists.
|
|
8
|
+
*/
|
|
9
|
+
export function createBrowserFactory(config, browsers) {
|
|
10
|
+
const executablePath = config.chrome ?? findChrome();
|
|
11
|
+
if (executablePath === undefined)
|
|
12
|
+
return undefined;
|
|
13
|
+
const instanceId = process.env.PORTOLAN_INSTANCE_ID;
|
|
14
|
+
return async (session) => {
|
|
15
|
+
const engine = await PlaywrightEngine.launch({
|
|
16
|
+
executablePath,
|
|
17
|
+
headless: config.headless,
|
|
18
|
+
...(instanceId !== undefined ? { instanceId } : {}),
|
|
19
|
+
});
|
|
20
|
+
browsers.register(session.sid, engine);
|
|
21
|
+
const policy = session.site === undefined ? undefined : loadPolicy(session.site, config.policies);
|
|
22
|
+
return new Substrate(engine, policy !== undefined ? { policy } : {});
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAMjG;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAClC,MAAiB,EACjB,QAAyB;IAEzB,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,IAAI,UAAU,EAAE,CAAC;IACrD,IAAI,cAAc,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAEnD,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC;IAEpD,OAAO,KAAK,EAAE,OAAO,EAAE,EAAE;QACvB,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC,MAAM,CAAC;YAC3C,cAAc;YACd,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,GAAG,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACpD,CAAC,CAAC;QACH,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QAEvC,MAAM,MAAM,GACV,OAAO,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;QAErF,OAAO,IAAI,SAAS,CAAC,MAAM,EAAE,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACvE,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { runBench } from "./commands/bench.js";
|
|
2
|
+
import { runCompile } from "./commands/compile.js";
|
|
3
|
+
import { runExportSkills } from "./commands/export-skills.js";
|
|
4
|
+
import { runInit } from "./commands/init.js";
|
|
5
|
+
import { runMcp } from "./commands/mcp.js";
|
|
6
|
+
import { runServe } from "./commands/serve.js";
|
|
7
|
+
import { runVerify } from "./commands/verify.js";
|
|
8
|
+
import { runDoctor } from "./doctor.js";
|
|
9
|
+
export declare const USAGE = "portolan <command> [options]\n\nCommands:\n init [dir] write a config, a policy, and the maps/skills dirs\n serve start the HTTP and MCP server\n mcp serve MCP over stdio (for a client to spawn)\n compile <trace...> compile traces into a new map version\n verify verify a map's ops on a fresh session\n export-skills export a portolan-<site> skill from a map\n bench [suite] run a benchmark suite from the source checkout\n qa <command> local, agent-first QA (see: portolan qa --help)\n doctor [--json] diagnose the browser, config, providers, and clients\n\nCommon options:\n --config <path> config file (default ./portolan.config.json)\n --help show this message\n";
|
|
10
|
+
export type CliDeps = {
|
|
11
|
+
init?: typeof runInit;
|
|
12
|
+
serve?: typeof runServe;
|
|
13
|
+
mcp?: typeof runMcp;
|
|
14
|
+
compile?: typeof runCompile;
|
|
15
|
+
verify?: typeof runVerify;
|
|
16
|
+
exportSkills?: typeof runExportSkills;
|
|
17
|
+
bench?: typeof runBench;
|
|
18
|
+
doctor?: typeof runDoctor;
|
|
19
|
+
out?: (line: string) => void;
|
|
20
|
+
err?: (line: string) => void;
|
|
21
|
+
};
|
|
22
|
+
export declare function main(argv: string[], deps?: CliDeps): Promise<number>;
|
|
23
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,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