tinker-agent 1.0.65 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -0
- package/LICENSE +201 -0
- package/NOTICE +6 -0
- package/README.md +90 -9
- package/bin/tinker.js +39 -0
- package/node_modules/ansi-regex/index.d.ts +33 -0
- package/node_modules/ansi-regex/index.js +14 -0
- package/node_modules/ansi-regex/license +9 -0
- package/node_modules/ansi-regex/package.json +61 -0
- package/node_modules/ansi-regex/readme.md +66 -0
- package/node_modules/ansi-styles/index.d.ts +236 -0
- package/node_modules/ansi-styles/index.js +223 -0
- package/node_modules/ansi-styles/license +9 -0
- package/node_modules/ansi-styles/package.json +54 -0
- package/node_modules/ansi-styles/readme.md +173 -0
- package/node_modules/chalk/license +9 -0
- package/node_modules/chalk/package.json +83 -0
- package/node_modules/chalk/readme.md +297 -0
- package/node_modules/chalk/source/index.d.ts +325 -0
- package/node_modules/chalk/source/index.js +225 -0
- package/node_modules/chalk/source/utilities.js +33 -0
- package/node_modules/chalk/source/vendor/ansi-styles/index.d.ts +236 -0
- package/node_modules/chalk/source/vendor/ansi-styles/index.js +223 -0
- package/node_modules/chalk/source/vendor/supports-color/browser.d.ts +1 -0
- package/node_modules/chalk/source/vendor/supports-color/browser.js +34 -0
- package/node_modules/chalk/source/vendor/supports-color/index.d.ts +55 -0
- package/node_modules/chalk/source/vendor/supports-color/index.js +190 -0
- package/node_modules/character-entities/index.d.ts +6 -0
- package/node_modules/character-entities/index.js +2132 -0
- package/node_modules/character-entities/license +22 -0
- package/node_modules/character-entities/package.json +78 -0
- package/node_modules/character-entities/readme.md +152 -0
- package/node_modules/decode-named-character-reference/index.d.ts +13 -0
- package/node_modules/decode-named-character-reference/index.d.ts.map +1 -0
- package/node_modules/decode-named-character-reference/index.dom.d.ts +6 -0
- package/node_modules/decode-named-character-reference/index.dom.d.ts.map +1 -0
- package/node_modules/decode-named-character-reference/index.dom.js +32 -0
- package/node_modules/decode-named-character-reference/index.js +19 -0
- package/node_modules/decode-named-character-reference/license +22 -0
- package/node_modules/decode-named-character-reference/package.json +90 -0
- package/node_modules/decode-named-character-reference/readme.md +136 -0
- package/node_modules/get-east-asian-width/index.d.ts +60 -0
- package/node_modules/get-east-asian-width/index.js +30 -0
- package/node_modules/get-east-asian-width/license +9 -0
- package/node_modules/get-east-asian-width/lookup-data.js +21 -0
- package/node_modules/get-east-asian-width/lookup.js +138 -0
- package/node_modules/get-east-asian-width/package.json +71 -0
- package/node_modules/get-east-asian-width/readme.md +65 -0
- package/node_modules/get-east-asian-width/utilities.js +24 -0
- package/node_modules/has-flag/index.d.ts +39 -0
- package/node_modules/has-flag/index.js +8 -0
- package/node_modules/has-flag/license +9 -0
- package/node_modules/has-flag/package.json +49 -0
- package/node_modules/has-flag/readme.md +74 -0
- package/node_modules/is-fullwidth-code-point/index.d.ts +17 -0
- package/node_modules/is-fullwidth-code-point/index.js +12 -0
- package/node_modules/is-fullwidth-code-point/license +9 -0
- package/node_modules/is-fullwidth-code-point/package.json +53 -0
- package/node_modules/is-fullwidth-code-point/readme.md +31 -0
- package/node_modules/markdansi/LICENSE +21 -0
- package/node_modules/markdansi/README.md +167 -0
- package/node_modules/markdansi/dist/ast.d.ts +99 -0
- package/node_modules/markdansi/dist/ast.js +1 -0
- package/node_modules/markdansi/dist/cli.d.ts +17 -0
- package/node_modules/markdansi/dist/cli.js +208 -0
- package/node_modules/markdansi/dist/hyperlink.d.ts +9 -0
- package/node_modules/markdansi/dist/hyperlink.js +26 -0
- package/node_modules/markdansi/dist/index.d.ts +10 -0
- package/node_modules/markdansi/dist/index.js +16 -0
- package/node_modules/markdansi/dist/parser.d.ts +2 -0
- package/node_modules/markdansi/dist/parser.js +205 -0
- package/node_modules/markdansi/dist/render.d.ts +9 -0
- package/node_modules/markdansi/dist/render.js +680 -0
- package/node_modules/markdansi/dist/stream.d.ts +39 -0
- package/node_modules/markdansi/dist/stream.js +192 -0
- package/node_modules/markdansi/dist/theme.d.ts +18 -0
- package/node_modules/markdansi/dist/theme.js +105 -0
- package/node_modules/markdansi/dist/types.d.ts +58 -0
- package/node_modules/markdansi/dist/types.js +1 -0
- package/node_modules/markdansi/dist/wrap.d.ts +10 -0
- package/node_modules/markdansi/dist/wrap.js +73 -0
- package/node_modules/markdansi/docs/spec.md +110 -0
- package/node_modules/markdansi/package.json +78 -0
- package/node_modules/markdansi/tsconfig.json +18 -0
- package/node_modules/marked/LICENSE +44 -0
- package/node_modules/marked/README.md +115 -0
- package/node_modules/marked/bin/main.js +284 -0
- package/node_modules/marked/bin/marked.js +16 -0
- package/node_modules/marked/lib/marked.d.ts +760 -0
- package/node_modules/marked/lib/marked.esm.js +77 -0
- package/node_modules/marked/lib/marked.esm.js.map +7 -0
- package/node_modules/marked/lib/marked.umd.js +79 -0
- package/node_modules/marked/lib/marked.umd.js.map +7 -0
- package/node_modules/marked/man/marked.1 +113 -0
- package/node_modules/marked/man/marked.1.md +93 -0
- package/node_modules/marked/package.json +103 -0
- package/node_modules/slice-ansi/index.d.ts +19 -0
- package/node_modules/slice-ansi/index.js +317 -0
- package/node_modules/slice-ansi/license +10 -0
- package/node_modules/slice-ansi/package.json +59 -0
- package/node_modules/slice-ansi/readme.md +55 -0
- package/node_modules/slice-ansi/tokenize-ansi.js +752 -0
- package/node_modules/string-width/index.d.ts +39 -0
- package/node_modules/string-width/index.js +203 -0
- package/node_modules/string-width/license +9 -0
- package/node_modules/string-width/package.json +65 -0
- package/node_modules/string-width/readme.md +66 -0
- package/node_modules/strip-ansi/index.d.ts +15 -0
- package/node_modules/strip-ansi/index.js +19 -0
- package/node_modules/strip-ansi/license +9 -0
- package/node_modules/strip-ansi/package.json +59 -0
- package/node_modules/strip-ansi/readme.md +37 -0
- package/node_modules/supports-color/browser.d.ts +1 -0
- package/node_modules/supports-color/browser.js +35 -0
- package/node_modules/supports-color/index.d.ts +55 -0
- package/node_modules/supports-color/index.js +202 -0
- package/node_modules/supports-color/license +9 -0
- package/node_modules/supports-color/package.json +64 -0
- package/node_modules/supports-color/readme.md +75 -0
- package/node_modules/supports-hyperlinks/browser.js +10 -0
- package/node_modules/supports-hyperlinks/index.d.ts +25 -0
- package/node_modules/supports-hyperlinks/index.js +163 -0
- package/node_modules/supports-hyperlinks/license +10 -0
- package/node_modules/supports-hyperlinks/package.json +47 -0
- package/node_modules/supports-hyperlinks/readme.md +45 -0
- package/package.json +41 -10
- package/patches/markdansi@0.3.2.patch +22 -2
- package/src/agent/context-builder.ts +24 -10
- package/src/agent/context-meter.ts +89 -5
- package/src/agent/loop.ts +107 -10
- package/src/agent/runtime-session.ts +1437 -82
- package/src/agent/session-ledger.ts +169 -29
- package/src/agent/types.ts +12 -1
- package/src/agent/user-prompt-projection.ts +62 -0
- package/src/cli/config.ts +57 -14
- package/src/cli/model-profiles.ts +124 -0
- package/src/cli/run-runner.ts +4 -1
- package/src/cli/tui-runner.tsx +68 -30
- package/src/context/compiled-context-hash.ts +1 -1
- package/src/context/compiled-context-validator.ts +92 -15
- package/src/context/context-automation-policy.ts +121 -0
- package/src/context/context-manager.ts +390 -11
- package/src/context/context-policy.ts +8 -0
- package/src/context/context-protocol-validator.ts +11 -1
- package/src/context/context-revision-compiler.ts +190 -27
- package/src/context/context-revision.ts +105 -19
- package/src/context/context-surface.ts +329 -0
- package/src/context/prefix-retirement-planner.ts +570 -0
- package/src/context/protocol-frame.ts +30 -3
- package/src/context/recall-retirement-contract.ts +27 -0
- package/src/context/swap-planner.ts +34 -10
- package/src/events/observation-text-log.ts +3 -3
- package/src/events/stdout-event-printer.ts +39 -3
- package/src/events/types.ts +172 -35
- package/src/ids/runtime-id.ts +6 -0
- package/src/ids/uuid-v7.ts +7 -0
- package/src/image/image-asset-store.ts +319 -0
- package/src/image/image-input-policy.ts +14 -0
- package/src/image/image-probe.ts +233 -0
- package/src/image/image-types.ts +262 -0
- package/src/instructions/project-instructions.ts +4 -1
- package/src/mcp/mcp-manager.ts +83 -19
- package/src/model/fake-model-client.ts +9 -1
- package/src/model/input-token-estimator.ts +25 -0
- package/src/model/model-client.ts +60 -0
- package/src/model/model-request-preflight.ts +1 -0
- package/src/model/moonshot-input-token-estimator.ts +107 -0
- package/src/model/openai-chat-mapping.ts +77 -1
- package/src/model/openai-chat-model-client.ts +389 -59
- package/src/model/openai-chat-stream.ts +272 -0
- package/src/model/prompt-prefix-hash.ts +2 -4
- package/src/model/token-estimator.ts +4 -0
- package/src/observation/observation-builder.ts +29 -0
- package/src/session/resume-projection.ts +94 -34
- package/src/session/session-catalog.ts +4 -4
- package/src/session/session-errors.ts +1 -1
- package/src/session/session-history-reader.ts +151 -4
- package/src/session/session-last-response-reader.ts +189 -0
- package/src/session/session-schema.ts +349 -35
- package/src/session/session-store.ts +3266 -255
- package/src/session/sqlite-session-ledger.ts +9 -4
- package/src/skills/skill-catalog.ts +182 -0
- package/src/skills/skill-context.ts +364 -0
- package/src/skills/skill-loader.ts +779 -0
- package/src/skills/skill-tool.ts +297 -0
- package/src/tools/edit.ts +51 -64
- package/src/tools/ensure-parent-directory.ts +6 -0
- package/src/tools/read.ts +2 -2
- package/src/tools/recall.ts +43 -40
- package/src/tools/registry.ts +24 -3
- package/src/tools/ripgrep.ts +3 -2
- package/src/tools/types.ts +43 -4
- package/src/tools/write.ts +20 -31
- package/src/tui/app.tsx +333 -96
- package/src/tui/clipboard.ts +5 -0
- package/src/tui/components/mcp-panel.tsx +28 -0
- package/src/tui/components/prompt-input.tsx +790 -257
- package/src/tui/components/skills-panel.tsx +31 -0
- package/src/tui/components/timeline.tsx +30 -1
- package/src/tui/event-store.ts +85 -2
- package/src/tui/file-mention.ts +234 -0
- package/src/tui/line-editor.ts +1 -0
- package/src/tui/project-slash-commands.ts +229 -0
- package/src/tui/prompt-draft.ts +510 -0
- package/src/tui/prompt-history.ts +294 -22
- package/src/tui/slash-commands.ts +46 -2
- package/src/tui/tui-session-controller.ts +110 -48
- package/src/tui/workspace-file-search.ts +94 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
.TH "MARKED" "1" "June 2026" "18.0.4"
|
|
2
|
+
.SH "NAME"
|
|
3
|
+
\fBmarked\fR \- a javascript markdown parser
|
|
4
|
+
.SH SYNOPSIS
|
|
5
|
+
.P
|
|
6
|
+
\fBmarked\fP [\fB\-o\fP <output file>] [\fB\-i\fP <input file>] [\fB\-s\fP <markdown string>] [\fB\-c\fP <config file>] [\fB\-\-help\fP] [\fB\-\-version\fP] [\fB\-\-tokens\fP] [\fB\-\-no\-clobber\fP] [\fB\-\-pedantic\fP] [\fB\-\-gfm\fP] [\fB\-\-breaks\fP] [\fB\-\-no\-etc\.\.\.\fP] [\fB\-\-silent\fP] [filename]
|
|
7
|
+
.SH DESCRIPTION
|
|
8
|
+
.P
|
|
9
|
+
marked is a full\-featured javascript markdown parser, built for speed\.
|
|
10
|
+
.br
|
|
11
|
+
It also includes multiple GFM features\.
|
|
12
|
+
.SH EXAMPLES
|
|
13
|
+
.RS 2
|
|
14
|
+
.nf
|
|
15
|
+
cat in\.md | marked > out\.html
|
|
16
|
+
.fi
|
|
17
|
+
.RE
|
|
18
|
+
.RS 2
|
|
19
|
+
.nf
|
|
20
|
+
echo "hello *world*" | marked
|
|
21
|
+
.fi
|
|
22
|
+
.RE
|
|
23
|
+
.RS 2
|
|
24
|
+
.nf
|
|
25
|
+
marked \-o out\.html \-i in\.md \-\-gfm
|
|
26
|
+
.fi
|
|
27
|
+
.RE
|
|
28
|
+
.RS 2
|
|
29
|
+
.nf
|
|
30
|
+
marked \-\-output="hello world\.html" \-i in\.md \-\-no\-breaks
|
|
31
|
+
.fi
|
|
32
|
+
.RE
|
|
33
|
+
.SH OPTIONS
|
|
34
|
+
|
|
35
|
+
.RS 1
|
|
36
|
+
.IP \(bu 2
|
|
37
|
+
\-o, \-\-output [output file]
|
|
38
|
+
.br
|
|
39
|
+
Specify file output\. If none is specified, write to stdout\.
|
|
40
|
+
.IP \(bu 2
|
|
41
|
+
\-i, \-\-input [input file]
|
|
42
|
+
.br
|
|
43
|
+
Specify file input, otherwise use last argument as input file\.
|
|
44
|
+
.br
|
|
45
|
+
If no input file is specified, read from stdin\.
|
|
46
|
+
.IP \(bu 2
|
|
47
|
+
\-s, \-\-string [markdown string]
|
|
48
|
+
.br
|
|
49
|
+
Specify string input instead of a file\.
|
|
50
|
+
.IP \(bu 2
|
|
51
|
+
\-c, \-\-config [config file]
|
|
52
|
+
.br
|
|
53
|
+
Specify config file to use instead of the default \fB~/\.marked\.json\fP or \fB~/\.marked\.js\fP or \fB~/\.marked/index\.js\fP\|\.
|
|
54
|
+
.IP \(bu 2
|
|
55
|
+
\-t, \-\-tokens
|
|
56
|
+
.br
|
|
57
|
+
Output a token list instead of html\.
|
|
58
|
+
.IP \(bu 2
|
|
59
|
+
\-n, \-\-no\-clobber
|
|
60
|
+
.br
|
|
61
|
+
Do not overwrite \fBoutput\fP if it exists\.
|
|
62
|
+
.IP \(bu 2
|
|
63
|
+
\-\-pedantic
|
|
64
|
+
.br
|
|
65
|
+
Conform to obscure parts of markdown\.pl as much as possible\.
|
|
66
|
+
.br
|
|
67
|
+
Don't fix original markdown bugs\.
|
|
68
|
+
.IP \(bu 2
|
|
69
|
+
\-\-gfm
|
|
70
|
+
.br
|
|
71
|
+
Enable github flavored markdown\.
|
|
72
|
+
.IP \(bu 2
|
|
73
|
+
\-\-breaks
|
|
74
|
+
.br
|
|
75
|
+
Enable GFM line breaks\. Only works with the gfm option\.
|
|
76
|
+
.IP \(bu 2
|
|
77
|
+
\-\-no\-breaks, \-no\-etc\.\.\.
|
|
78
|
+
.br
|
|
79
|
+
The inverse of any of the marked options above\.
|
|
80
|
+
.IP \(bu 2
|
|
81
|
+
\-\-silent
|
|
82
|
+
.br
|
|
83
|
+
Silence error output\.
|
|
84
|
+
.IP \(bu 2
|
|
85
|
+
\-h, \-\-help
|
|
86
|
+
.br
|
|
87
|
+
Display help information\.
|
|
88
|
+
|
|
89
|
+
.RE
|
|
90
|
+
.SH CONFIGURATION
|
|
91
|
+
.P
|
|
92
|
+
For configuring and running programmatically\.
|
|
93
|
+
.P
|
|
94
|
+
Example
|
|
95
|
+
.RS 2
|
|
96
|
+
.nf
|
|
97
|
+
import { Marked } from 'marked';
|
|
98
|
+
const marked = new Marked({ gfm: true });
|
|
99
|
+
marked\.parse('*foo*');
|
|
100
|
+
.fi
|
|
101
|
+
.RE
|
|
102
|
+
.SH BUGS
|
|
103
|
+
.P
|
|
104
|
+
Please report any bugs to https://github.com/markedjs/marked
|
|
105
|
+
.SH LICENSE
|
|
106
|
+
.P
|
|
107
|
+
Copyright (c) 2018+, MarkedJS\. (MIT License)
|
|
108
|
+
.br
|
|
109
|
+
Copyright (c) 2011\-2018, Christopher Jeffrey\. (MIT License)
|
|
110
|
+
.SH SEE ALSO
|
|
111
|
+
.P
|
|
112
|
+
markdown(1), nodejs(1)
|
|
113
|
+
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# marked(1) -- a javascript markdown parser
|
|
2
|
+
|
|
3
|
+
## SYNOPSIS
|
|
4
|
+
|
|
5
|
+
`marked` [`-o` <output file>] [`-i` <input file>] [`-s` <markdown string>] [`-c` <config file>] [`--help`] [`--version`] [`--tokens`] [`--no-clobber`] [`--pedantic`] [`--gfm`] [`--breaks`] [`--no-etc...`] [`--silent`] [filename]
|
|
6
|
+
|
|
7
|
+
## DESCRIPTION
|
|
8
|
+
|
|
9
|
+
marked is a full-featured javascript markdown parser, built for speed.
|
|
10
|
+
It also includes multiple GFM features.
|
|
11
|
+
|
|
12
|
+
## EXAMPLES
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
cat in.md | marked > out.html
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
echo "hello *world*" | marked
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
marked -o out.html -i in.md --gfm
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
marked --output="hello world.html" -i in.md --no-breaks
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## OPTIONS
|
|
31
|
+
|
|
32
|
+
* -o, --output [output file]
|
|
33
|
+
Specify file output. If none is specified, write to stdout.
|
|
34
|
+
|
|
35
|
+
* -i, --input [input file]
|
|
36
|
+
Specify file input, otherwise use last argument as input file.
|
|
37
|
+
If no input file is specified, read from stdin.
|
|
38
|
+
|
|
39
|
+
* -s, --string [markdown string]
|
|
40
|
+
Specify string input instead of a file.
|
|
41
|
+
|
|
42
|
+
* -c, --config [config file]
|
|
43
|
+
Specify config file to use instead of the default `~/.marked.json` or `~/.marked.js` or `~/.marked/index.js`.
|
|
44
|
+
|
|
45
|
+
* -t, --tokens
|
|
46
|
+
Output a token list instead of html.
|
|
47
|
+
|
|
48
|
+
* -n, --no-clobber
|
|
49
|
+
Do not overwrite `output` if it exists.
|
|
50
|
+
|
|
51
|
+
* --pedantic
|
|
52
|
+
Conform to obscure parts of markdown.pl as much as possible.
|
|
53
|
+
Don't fix original markdown bugs.
|
|
54
|
+
|
|
55
|
+
* --gfm
|
|
56
|
+
Enable github flavored markdown.
|
|
57
|
+
|
|
58
|
+
* --breaks
|
|
59
|
+
Enable GFM line breaks. Only works with the gfm option.
|
|
60
|
+
|
|
61
|
+
* --no-breaks, -no-etc...
|
|
62
|
+
The inverse of any of the marked options above.
|
|
63
|
+
|
|
64
|
+
* --silent
|
|
65
|
+
Silence error output.
|
|
66
|
+
|
|
67
|
+
* -h, --help
|
|
68
|
+
Display help information.
|
|
69
|
+
|
|
70
|
+
## CONFIGURATION
|
|
71
|
+
|
|
72
|
+
For configuring and running programmatically.
|
|
73
|
+
|
|
74
|
+
Example
|
|
75
|
+
|
|
76
|
+
```js
|
|
77
|
+
import { Marked } from 'marked';
|
|
78
|
+
const marked = new Marked({ gfm: true });
|
|
79
|
+
marked.parse('*foo*');
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## BUGS
|
|
83
|
+
|
|
84
|
+
Please report any bugs to <https://github.com/markedjs/marked>.
|
|
85
|
+
|
|
86
|
+
## LICENSE
|
|
87
|
+
|
|
88
|
+
Copyright (c) 2018+, MarkedJS. (MIT License)
|
|
89
|
+
Copyright (c) 2011-2018, Christopher Jeffrey. (MIT License)
|
|
90
|
+
|
|
91
|
+
## SEE ALSO
|
|
92
|
+
|
|
93
|
+
markdown(1), nodejs(1)
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "marked",
|
|
3
|
+
"description": "A markdown parser built for speed",
|
|
4
|
+
"author": "Christopher Jeffrey",
|
|
5
|
+
"version": "18.0.5",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./lib/marked.esm.js",
|
|
8
|
+
"module": "./lib/marked.esm.js",
|
|
9
|
+
"browser": "./lib/marked.umd.js",
|
|
10
|
+
"types": "./lib/marked.d.ts",
|
|
11
|
+
"bin": {
|
|
12
|
+
"marked": "bin/marked.js"
|
|
13
|
+
},
|
|
14
|
+
"man": "./man/marked.1",
|
|
15
|
+
"files": [
|
|
16
|
+
"bin/",
|
|
17
|
+
"lib/",
|
|
18
|
+
"man/"
|
|
19
|
+
],
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./lib/marked.d.ts",
|
|
23
|
+
"default": "./lib/marked.esm.js"
|
|
24
|
+
},
|
|
25
|
+
"./bin/marked": "./bin/marked.js",
|
|
26
|
+
"./package.json": "./package.json"
|
|
27
|
+
},
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"provenance": true
|
|
30
|
+
},
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "git://github.com/markedjs/marked.git"
|
|
34
|
+
},
|
|
35
|
+
"homepage": "https://marked.js.org",
|
|
36
|
+
"bugs": {
|
|
37
|
+
"url": "http://github.com/markedjs/marked/issues"
|
|
38
|
+
},
|
|
39
|
+
"license": "MIT",
|
|
40
|
+
"keywords": [
|
|
41
|
+
"markdown",
|
|
42
|
+
"markup",
|
|
43
|
+
"html"
|
|
44
|
+
],
|
|
45
|
+
"tags": [
|
|
46
|
+
"markdown",
|
|
47
|
+
"markup",
|
|
48
|
+
"html"
|
|
49
|
+
],
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@arethetypeswrong/cli": "^0.18.3",
|
|
52
|
+
"@markedjs/eslint-config": "^1.0.14",
|
|
53
|
+
"@markedjs/testutils": "18.0.0-1",
|
|
54
|
+
"@semantic-release/commit-analyzer": "^13.0.1",
|
|
55
|
+
"@semantic-release/git": "^10.0.1",
|
|
56
|
+
"@semantic-release/github": "^12.0.8",
|
|
57
|
+
"@semantic-release/npm": "^13.1.5",
|
|
58
|
+
"@semantic-release/release-notes-generator": "^14.1.1",
|
|
59
|
+
"cheerio": "1.2.0",
|
|
60
|
+
"commonmark": "0.31.2",
|
|
61
|
+
"cross-env": "^10.1.0",
|
|
62
|
+
"dts-bundle-generator": "^9.5.1",
|
|
63
|
+
"esbuild": "^0.28.0",
|
|
64
|
+
"esbuild-plugin-umd-wrapper": "^3.0.0",
|
|
65
|
+
"eslint": "^10.4.1",
|
|
66
|
+
"highlight.js": "^11.11.1",
|
|
67
|
+
"markdown-it": "14.2.0",
|
|
68
|
+
"marked-highlight": "^2.2.4",
|
|
69
|
+
"marked-man": "^2.1.1",
|
|
70
|
+
"recheck": "^4.5.0",
|
|
71
|
+
"rimraf": "^6.1.3",
|
|
72
|
+
"semantic-release": "^25.0.3",
|
|
73
|
+
"titleize": "^4.0.0",
|
|
74
|
+
"tslib": "^2.8.1",
|
|
75
|
+
"typescript": "6.0.3"
|
|
76
|
+
},
|
|
77
|
+
"scripts": {
|
|
78
|
+
"bench": "npm run build && node test/bench.js",
|
|
79
|
+
"build": "npm run build:esbuild && npm run build:types && npm run build:man",
|
|
80
|
+
"build:docs": "npm run build && node docs/build.js",
|
|
81
|
+
"build:esbuild": "node esbuild.config.js",
|
|
82
|
+
"build:man": "marked-man man/marked.1.md > man/marked.1",
|
|
83
|
+
"build:reset": "rimraf ./lib ./public",
|
|
84
|
+
"build:types": "tsc && dts-bundle-generator --export-referenced-types --project tsconfig.json -o lib/marked.d.ts src/marked.ts",
|
|
85
|
+
"lint": "eslint --fix",
|
|
86
|
+
"rules": "node test/rules.js",
|
|
87
|
+
"test": "npm run build:reset && npm run build:docs && npm run test:specs && npm run test:unit && npm run test:umd && npm run test:cjs && npm run test:types && npm run test:lint",
|
|
88
|
+
"test:cjs": "node test/cjs-test.cjs",
|
|
89
|
+
"test:lint": "eslint",
|
|
90
|
+
"test:only": "npm run build && npm run test:specs:only && npm run test:unit:only",
|
|
91
|
+
"test:redos": "node test/recheck.ts > vuln.js",
|
|
92
|
+
"test:specs:only": "node --test --test-only --test-reporter=spec test/run-spec-tests.js",
|
|
93
|
+
"test:specs": "node --test --test-reporter=spec test/run-spec-tests.js",
|
|
94
|
+
"test:types": "tsc --project tsconfig-type-test.json && attw -P --entrypoints . --profile esm-only",
|
|
95
|
+
"test:umd": "node test/umd-test.js",
|
|
96
|
+
"test:unit:only": "node --test --test-only --test-reporter=spec test/unit/*.test.js",
|
|
97
|
+
"test:unit": "node --test --test-reporter=spec test/unit/*.test.js",
|
|
98
|
+
"test:update": "node test/update-specs.js"
|
|
99
|
+
},
|
|
100
|
+
"engines": {
|
|
101
|
+
"node": ">= 20"
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Slice a string with [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles)
|
|
3
|
+
|
|
4
|
+
@param string - A string with ANSI escape codes. Like one styled by [`chalk`](https://github.com/chalk/chalk).
|
|
5
|
+
@param startSlice - Zero-based visible-column index at which to start the slice. Grapheme clusters are kept intact.
|
|
6
|
+
@param endSlice - Zero-based visible-column index at which to end the slice. If a full grapheme cluster would cross `endSlice`, it is excluded.
|
|
7
|
+
|
|
8
|
+
@example
|
|
9
|
+
```
|
|
10
|
+
import chalk from 'chalk';
|
|
11
|
+
import sliceAnsi from 'slice-ansi';
|
|
12
|
+
|
|
13
|
+
const string = 'The quick brown ' + chalk.red('fox jumped over ') +
|
|
14
|
+
'the lazy ' + chalk.green('dog and then ran away with the unicorn.');
|
|
15
|
+
|
|
16
|
+
console.log(sliceAnsi(string, 20, 30));
|
|
17
|
+
```
|
|
18
|
+
*/
|
|
19
|
+
export default function sliceAnsi(string: string, startSlice: number, endSlice?: number): string;
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
import tokenizeAnsi from './tokenize-ansi.js';
|
|
2
|
+
|
|
3
|
+
function applySgrFragments(activeStyles, fragments) {
|
|
4
|
+
for (const fragment of fragments) {
|
|
5
|
+
switch (fragment.type) {
|
|
6
|
+
case 'reset': {
|
|
7
|
+
activeStyles.clear();
|
|
8
|
+
break;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
case 'end': {
|
|
12
|
+
activeStyles.delete(fragment.endCode);
|
|
13
|
+
break;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
case 'start': {
|
|
17
|
+
activeStyles.delete(fragment.endCode);
|
|
18
|
+
activeStyles.set(fragment.endCode, fragment.code);
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
default: {
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return activeStyles;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function undoAnsiCodes(activeStyles) {
|
|
32
|
+
return [...activeStyles.keys()].toReversed().join('');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function closeHyperlink(hyperlinkToken) {
|
|
36
|
+
return `${hyperlinkToken.closePrefix}${hyperlinkToken.terminator}`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function shouldIncludeSgrAfterEnd(token, activeStyles) {
|
|
40
|
+
let hasStartFragment = false;
|
|
41
|
+
let hasClosingEffect = false;
|
|
42
|
+
|
|
43
|
+
for (const fragment of token.fragments) {
|
|
44
|
+
if (fragment.type === 'start') {
|
|
45
|
+
hasStartFragment = true;
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (fragment.type === 'reset' && activeStyles.size > 0) {
|
|
50
|
+
hasClosingEffect = true;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (fragment.type === 'end' && activeStyles.has(fragment.endCode)) {
|
|
55
|
+
hasClosingEffect = true;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return hasClosingEffect && !hasStartFragment;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function hasSgrStartFragment(token) {
|
|
63
|
+
return token.fragments.some(fragment => fragment.type === 'start');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function discardPendingHyperlink(parameters) {
|
|
67
|
+
if (
|
|
68
|
+
parameters.activeHyperlink
|
|
69
|
+
&& !parameters.activeHyperlinkHasVisibleText
|
|
70
|
+
&& parameters.activeHyperlinkOutputIndex !== undefined
|
|
71
|
+
) {
|
|
72
|
+
const openCodeLength = parameters.activeHyperlink.code.length;
|
|
73
|
+
parameters.returnValue = parameters.returnValue.slice(0, parameters.activeHyperlinkOutputIndex) + parameters.returnValue.slice(parameters.activeHyperlinkOutputIndex + openCodeLength);
|
|
74
|
+
|
|
75
|
+
if (
|
|
76
|
+
parameters.pendingSgrOutputIndex !== undefined
|
|
77
|
+
&& parameters.pendingSgrOutputIndex > parameters.activeHyperlinkOutputIndex
|
|
78
|
+
) {
|
|
79
|
+
parameters.pendingSgrOutputIndex -= openCodeLength;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
parameters.activeHyperlink = undefined;
|
|
84
|
+
parameters.activeHyperlinkHasVisibleText = false;
|
|
85
|
+
parameters.activeHyperlinkOutputIndex = undefined;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function applySgrToken(parameters) {
|
|
89
|
+
if (
|
|
90
|
+
parameters.isPastEnd
|
|
91
|
+
&& !shouldIncludeSgrAfterEnd(parameters.token, parameters.activeStyles)
|
|
92
|
+
) {
|
|
93
|
+
return parameters;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (
|
|
97
|
+
parameters.include
|
|
98
|
+
&& hasSgrStartFragment(parameters.token)
|
|
99
|
+
&& parameters.pendingSgrOutputIndex === undefined
|
|
100
|
+
) {
|
|
101
|
+
parameters.pendingSgrOutputIndex = parameters.returnValue.length;
|
|
102
|
+
parameters.pendingSgrActiveStyles = new Map(parameters.activeStyles);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
parameters.activeStyles = applySgrFragments(parameters.activeStyles, parameters.token.fragments);
|
|
106
|
+
if (parameters.include) {
|
|
107
|
+
parameters.returnValue += parameters.token.code;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return parameters;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function applyHyperlinkToken(parameters) {
|
|
114
|
+
if (
|
|
115
|
+
parameters.isPastEnd
|
|
116
|
+
&& (
|
|
117
|
+
parameters.token.action !== 'close'
|
|
118
|
+
|| !parameters.activeHyperlink
|
|
119
|
+
)
|
|
120
|
+
) {
|
|
121
|
+
return parameters;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (parameters.token.action === 'open') {
|
|
125
|
+
parameters.activeHyperlink = parameters.token;
|
|
126
|
+
parameters.activeHyperlinkHasVisibleText = false;
|
|
127
|
+
parameters.activeHyperlinkOutputIndex = undefined;
|
|
128
|
+
if (parameters.include) {
|
|
129
|
+
parameters.activeHyperlinkOutputIndex = parameters.returnValue.length;
|
|
130
|
+
}
|
|
131
|
+
} else if (parameters.token.action === 'close') {
|
|
132
|
+
if (
|
|
133
|
+
parameters.include
|
|
134
|
+
&& parameters.activeHyperlink
|
|
135
|
+
&& !parameters.activeHyperlinkHasVisibleText
|
|
136
|
+
) {
|
|
137
|
+
discardPendingHyperlink(parameters);
|
|
138
|
+
return parameters;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
parameters.activeHyperlink = undefined;
|
|
142
|
+
parameters.activeHyperlinkHasVisibleText = false;
|
|
143
|
+
parameters.activeHyperlinkOutputIndex = undefined;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (parameters.include) {
|
|
147
|
+
parameters.returnValue += parameters.token.code;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return parameters;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function applyControlToken(parameters) {
|
|
154
|
+
if (!parameters.isPastEnd && parameters.include) {
|
|
155
|
+
parameters.returnValue += parameters.token.code;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return parameters;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function applyCharacterToken(parameters) {
|
|
162
|
+
if (
|
|
163
|
+
!parameters.include
|
|
164
|
+
&& parameters.position >= parameters.start
|
|
165
|
+
&& !parameters.token.isGraphemeContinuation
|
|
166
|
+
) {
|
|
167
|
+
parameters.include = true;
|
|
168
|
+
parameters.returnValue = [...parameters.activeStyles.values()].join('');
|
|
169
|
+
if (parameters.activeHyperlink) {
|
|
170
|
+
parameters.activeHyperlinkOutputIndex = parameters.returnValue.length;
|
|
171
|
+
parameters.returnValue += parameters.activeHyperlink.code;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (parameters.include) {
|
|
176
|
+
parameters.returnValue += parameters.token.value;
|
|
177
|
+
parameters.pendingSgrOutputIndex = undefined;
|
|
178
|
+
parameters.pendingSgrActiveStyles = undefined;
|
|
179
|
+
if (parameters.activeHyperlink) {
|
|
180
|
+
parameters.activeHyperlinkHasVisibleText = true;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
parameters.position += parameters.token.visibleWidth;
|
|
185
|
+
return parameters;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const tokenHandlers = {
|
|
189
|
+
sgr: applySgrToken,
|
|
190
|
+
hyperlink: applyHyperlinkToken,
|
|
191
|
+
control: applyControlToken,
|
|
192
|
+
character: applyCharacterToken,
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
function applyToken(parameters) {
|
|
196
|
+
const tokenHandler = tokenHandlers[parameters.token.type];
|
|
197
|
+
if (!tokenHandler) {
|
|
198
|
+
return parameters;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return tokenHandler(parameters);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function createHasContinuationAheadMap(tokens) {
|
|
205
|
+
const hasContinuationAhead = Array.from({length: tokens.length}, () => false);
|
|
206
|
+
let nextCharacterIsContinuation = false;
|
|
207
|
+
|
|
208
|
+
for (let tokenIndex = tokens.length - 1; tokenIndex >= 0; tokenIndex--) {
|
|
209
|
+
const token = tokens[tokenIndex];
|
|
210
|
+
hasContinuationAhead[tokenIndex] = nextCharacterIsContinuation;
|
|
211
|
+
if (token.type === 'character') {
|
|
212
|
+
nextCharacterIsContinuation = Boolean(token.isGraphemeContinuation);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
return hasContinuationAhead;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function isPastEndBoundary(token, position, end) {
|
|
220
|
+
if (end === undefined) {
|
|
221
|
+
return false;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
if (position >= end) {
|
|
225
|
+
return true;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
return token.type === 'character'
|
|
229
|
+
&& !token.isGraphemeContinuation
|
|
230
|
+
&& position + token.visibleWidth > end;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export default function sliceAnsi(string, start, end) {
|
|
234
|
+
const tokens = tokenizeAnsi(string, {endCharacter: end});
|
|
235
|
+
const hasContinuationAhead = createHasContinuationAheadMap(tokens);
|
|
236
|
+
let activeStyles = new Map();
|
|
237
|
+
let activeHyperlink;
|
|
238
|
+
let activeHyperlinkHasVisibleText = false;
|
|
239
|
+
let activeHyperlinkOutputIndex;
|
|
240
|
+
let pendingSgrOutputIndex;
|
|
241
|
+
let pendingSgrActiveStyles;
|
|
242
|
+
let position = 0;
|
|
243
|
+
let returnValue = '';
|
|
244
|
+
let include = false;
|
|
245
|
+
|
|
246
|
+
for (const [tokenIndex, token] of tokens.entries()) {
|
|
247
|
+
let isPastEnd = isPastEndBoundary(token, position, end);
|
|
248
|
+
if (
|
|
249
|
+
isPastEnd
|
|
250
|
+
&& token.type !== 'character'
|
|
251
|
+
&& hasContinuationAhead[tokenIndex]
|
|
252
|
+
) {
|
|
253
|
+
isPastEnd = false;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
if (
|
|
257
|
+
isPastEnd
|
|
258
|
+
&& token.type === 'character'
|
|
259
|
+
&& !token.isGraphemeContinuation
|
|
260
|
+
) {
|
|
261
|
+
if (activeHyperlink && !activeHyperlinkHasVisibleText) {
|
|
262
|
+
const hyperlinkState = {
|
|
263
|
+
activeHyperlink,
|
|
264
|
+
activeHyperlinkHasVisibleText,
|
|
265
|
+
activeHyperlinkOutputIndex,
|
|
266
|
+
pendingSgrOutputIndex,
|
|
267
|
+
returnValue,
|
|
268
|
+
};
|
|
269
|
+
discardPendingHyperlink(hyperlinkState);
|
|
270
|
+
({
|
|
271
|
+
activeHyperlink,
|
|
272
|
+
activeHyperlinkHasVisibleText,
|
|
273
|
+
activeHyperlinkOutputIndex,
|
|
274
|
+
pendingSgrOutputIndex,
|
|
275
|
+
returnValue,
|
|
276
|
+
} = hyperlinkState);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
if (pendingSgrOutputIndex !== undefined) {
|
|
280
|
+
returnValue = returnValue.slice(0, pendingSgrOutputIndex);
|
|
281
|
+
activeStyles = pendingSgrActiveStyles;
|
|
282
|
+
pendingSgrOutputIndex = undefined;
|
|
283
|
+
pendingSgrActiveStyles = undefined;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
break;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
({activeStyles, activeHyperlink, activeHyperlinkHasVisibleText, activeHyperlinkOutputIndex, pendingSgrOutputIndex, pendingSgrActiveStyles, position, returnValue, include} = applyToken({
|
|
290
|
+
token,
|
|
291
|
+
isPastEnd,
|
|
292
|
+
start,
|
|
293
|
+
activeStyles,
|
|
294
|
+
activeHyperlink,
|
|
295
|
+
activeHyperlinkHasVisibleText,
|
|
296
|
+
activeHyperlinkOutputIndex,
|
|
297
|
+
pendingSgrOutputIndex,
|
|
298
|
+
pendingSgrActiveStyles,
|
|
299
|
+
position,
|
|
300
|
+
returnValue,
|
|
301
|
+
include,
|
|
302
|
+
}));
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
if (!include) {
|
|
306
|
+
return '';
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
if (activeHyperlink) {
|
|
310
|
+
returnValue += closeHyperlink(activeHyperlink);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// Disable active codes at the end
|
|
314
|
+
returnValue += undoAnsiCodes(activeStyles);
|
|
315
|
+
|
|
316
|
+
return returnValue;
|
|
317
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) DC <threedeecee@gmail.com>
|
|
4
|
+
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
7
|
+
|
|
8
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
9
|
+
|
|
10
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|