@phnx-labs/artifacts-cli 0.3.9 → 0.4.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/CHANGELOG.md +101 -0
- package/README.md +43 -14
- package/dist/cli.d.ts +2 -1
- package/dist/cli.js +47 -14
- package/dist/cli.js.map +1 -1
- package/dist/commands/new.d.ts +1 -0
- package/dist/commands/new.js +11 -2
- package/dist/commands/new.js.map +1 -1
- package/dist/lib/collab.d.ts +61 -0
- package/dist/lib/collab.js +714 -0
- package/dist/lib/collab.js.map +1 -0
- package/dist/lib/fonts.d.ts +3 -0
- package/dist/lib/fonts.js +68 -12
- package/dist/lib/fonts.js.map +1 -1
- package/dist/lib/highlights.d.ts +11 -1
- package/dist/lib/highlights.js +38 -71
- package/dist/lib/highlights.js.map +1 -1
- package/dist/lib/reader-anchors.d.ts +16 -0
- package/dist/lib/reader-anchors.js +146 -0
- package/dist/lib/reader-anchors.js.map +1 -0
- package/dist/lib/render.d.ts +11 -1
- package/dist/lib/render.js +189 -13
- package/dist/lib/render.js.map +1 -1
- package/dist/lib/section-collapse.d.ts +17 -0
- package/dist/lib/section-collapse.js +113 -0
- package/dist/lib/section-collapse.js.map +1 -0
- package/dist/lib/share.d.ts +17 -0
- package/dist/lib/share.js +52 -23
- package/dist/lib/share.js.map +1 -1
- package/dist/lib/templates.d.ts +23 -1
- package/dist/lib/templates.js +113 -3
- package/dist/lib/templates.js.map +1 -1
- package/dist/lib/tokens.d.ts +2 -0
- package/dist/lib/tokens.js +5 -1
- package/dist/lib/tokens.js.map +1 -1
- package/fonts/Inter-OFL.txt +92 -0
- package/fonts/InterVariable.woff2 +0 -0
- package/fonts/JetBrainsMono-OFL.txt +93 -0
- package/fonts/JetBrainsMono-wght.woff2 +0 -0
- package/fonts/README.md +16 -0
- package/package.json +4 -1
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Collapsible sections: every h2/h3 the renderer wraps (render.ts,
|
|
3
|
+
* wrapCollapsibleSections) carries a `.section-toggle` button and a sibling
|
|
4
|
+
* `.artifact-section-body` that holds its content. This script is the only
|
|
5
|
+
* thing that ever hides that body — the server always renders it open, so a
|
|
6
|
+
* reader with JS disabled always sees the complete document.
|
|
7
|
+
*
|
|
8
|
+
* State is per-browser, per-document: keyed the same way highlights.ts and the
|
|
9
|
+
* view counter key their storage (origin + pathname + title), so re-rendering
|
|
10
|
+
* the same file keeps a reader's choices and two different artifacts never
|
|
11
|
+
* share a key. Only collapsed sections are stored, by their (unique, stable)
|
|
12
|
+
* `aria-controls` id, so a heading that keeps its text across a re-render
|
|
13
|
+
* keeps its saved state too. State is read back through `hasOwnProperty` so a
|
|
14
|
+
* heading that happens to slugify to an `Object.prototype` member name (e.g.
|
|
15
|
+
* `## Constructor`) never inherits a false "collapsed" reading.
|
|
16
|
+
*/
|
|
17
|
+
export const SECTION_COLLAPSE_SCRIPT = `<script>
|
|
18
|
+
(() => {
|
|
19
|
+
const root = document.querySelector('.artifact-body');
|
|
20
|
+
if (!root) return;
|
|
21
|
+
const toggles = [...root.querySelectorAll('.section-toggle')];
|
|
22
|
+
if (!toggles.length) return;
|
|
23
|
+
|
|
24
|
+
const storageKey = 'artifacts-collapse:' + location.origin + location.pathname + ':' + (document.title || '');
|
|
25
|
+
const read = () => {
|
|
26
|
+
try {
|
|
27
|
+
const value = JSON.parse(localStorage.getItem(storageKey) || '{}');
|
|
28
|
+
return value && typeof value === 'object' && !Array.isArray(value) ? value : {};
|
|
29
|
+
} catch { return {}; }
|
|
30
|
+
};
|
|
31
|
+
let state = read();
|
|
32
|
+
const write = () => { try { localStorage.setItem(storageKey, JSON.stringify(state)); } catch {} };
|
|
33
|
+
const isStoredCollapsed = (key) => Object.prototype.hasOwnProperty.call(state, key) && state[key] === true;
|
|
34
|
+
|
|
35
|
+
const bodyFor = (button) => document.getElementById(button.getAttribute('aria-controls'));
|
|
36
|
+
// Every layout-affecting change gets announced so the scroll-spy (a separate
|
|
37
|
+
// inlined script with no import between the two) can drop a heading that just
|
|
38
|
+
// became hidden, or pick one up that just became visible, without a scroll.
|
|
39
|
+
const announce = () => document.dispatchEvent(new Event('artifacts:section-toggle'));
|
|
40
|
+
|
|
41
|
+
const setExpanded = (button, expanded, persist) => {
|
|
42
|
+
const body = bodyFor(button);
|
|
43
|
+
if (!body) return;
|
|
44
|
+
button.setAttribute('aria-expanded', String(expanded));
|
|
45
|
+
const name = button.dataset.sectionLabel || 'section';
|
|
46
|
+
button.setAttribute('aria-label', (expanded ? 'Collapse ' : 'Expand ') + name + ' section');
|
|
47
|
+
if (expanded) body.removeAttribute('hidden'); else body.setAttribute('hidden', '');
|
|
48
|
+
announce();
|
|
49
|
+
if (!persist) return;
|
|
50
|
+
const key = button.getAttribute('aria-controls');
|
|
51
|
+
if (expanded) delete state[key]; else state[key] = true;
|
|
52
|
+
write();
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
for (const button of toggles) {
|
|
56
|
+
if (isStoredCollapsed(button.getAttribute('aria-controls'))) setExpanded(button, false, false);
|
|
57
|
+
button.addEventListener('click', () => setExpanded(button, button.getAttribute('aria-expanded') !== 'true', true));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// A hash target hidden inside a collapsed ancestor — or hidden because it IS
|
|
61
|
+
// a collapsed heading's own content — never scrolls into view on its own: the
|
|
62
|
+
// browser's built-in fragment scroll already ran (and silently did nothing,
|
|
63
|
+
// since the target was not being rendered) before this script gets a chance
|
|
64
|
+
// to run. Open the target's own section, walk every collapsed ancestor open
|
|
65
|
+
// too, then finish the scroll ourselves.
|
|
66
|
+
const reveal = (target) => {
|
|
67
|
+
const own = target.id ? toggles.find((button) => button.dataset.sectionId === target.id) : undefined;
|
|
68
|
+
if (own && own.getAttribute('aria-expanded') !== 'true') setExpanded(own, true, true);
|
|
69
|
+
for (let element = target; element && element !== root; element = element.parentElement) {
|
|
70
|
+
if (!(element.matches && element.matches('.artifact-section-body[hidden]'))) continue;
|
|
71
|
+
const button = toggles.find((candidate) => bodyFor(candidate) === element);
|
|
72
|
+
if (button) setExpanded(button, true, true);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
const gotoHash = () => {
|
|
76
|
+
if (!location.hash) return;
|
|
77
|
+
let target;
|
|
78
|
+
try { target = document.getElementById(decodeURIComponent(location.hash.slice(1))); } catch { return; }
|
|
79
|
+
if (!target) return;
|
|
80
|
+
reveal(target);
|
|
81
|
+
target.scrollIntoView();
|
|
82
|
+
};
|
|
83
|
+
addEventListener('hashchange', gotoHash);
|
|
84
|
+
gotoHash();
|
|
85
|
+
// A click on a same-page anchor whose href already matches the current hash
|
|
86
|
+
// never fires 'hashchange' (the URL does not change), so a reader who
|
|
87
|
+
// re-collapsed a section and clicks its TOC link again would otherwise see
|
|
88
|
+
// nothing happen. Re-run after the browser's own default handling so a real
|
|
89
|
+
// navigation (new tab, modified click, a target elsewhere) is never hijacked.
|
|
90
|
+
document.addEventListener('click', (event) => {
|
|
91
|
+
if (event.defaultPrevented || event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;
|
|
92
|
+
const link = event.target.closest && event.target.closest('a[href^="#"]');
|
|
93
|
+
if (!link) return;
|
|
94
|
+
const target = link.getAttribute('target');
|
|
95
|
+
if (target && target !== '_self') return;
|
|
96
|
+
setTimeout(gotoHash, 0);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
const rail = document.querySelector('.toc');
|
|
100
|
+
if (rail && toggles.length > 1) {
|
|
101
|
+
const bar = document.createElement('div');
|
|
102
|
+
bar.className = 'toc-collapse-actions';
|
|
103
|
+
bar.innerHTML = '<button type="button" data-toc-collapse="collapse">Collapse all</button><button type="button" data-toc-collapse="expand">Expand all</button>';
|
|
104
|
+
rail.prepend(bar);
|
|
105
|
+
bar.addEventListener('click', (event) => {
|
|
106
|
+
const action = event.target.closest('button')?.dataset.tocCollapse;
|
|
107
|
+
if (!action) return;
|
|
108
|
+
for (const button of toggles) setExpanded(button, action === 'expand', true);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
})();
|
|
112
|
+
</script>`;
|
|
113
|
+
//# sourceMappingURL=section-collapse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"section-collapse.js","sourceRoot":"","sources":["../../src/lib/section-collapse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA+F7B,CAAC"}
|
package/dist/lib/share.d.ts
CHANGED
|
@@ -12,6 +12,23 @@ export interface PublishResult {
|
|
|
12
12
|
}
|
|
13
13
|
export declare function generateWriteToken(): string;
|
|
14
14
|
export declare function parseExpire(spec: string | undefined): string | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* The slug when the author did not pass --slug: derived from the artifact's
|
|
17
|
+
* own title, falling back to the filename for title-less sources (images,
|
|
18
|
+
* HTML). Deterministic on purpose — re-sharing an updated artifact updates the
|
|
19
|
+
* same URL instead of minting a new one. The old default prefixed a
|
|
20
|
+
* cwd-derived project name and a random hex, which both invented provenance
|
|
21
|
+
* (the cwd repo is not necessarily the project the artifact is about) and made
|
|
22
|
+
* every re-publish a new link.
|
|
23
|
+
*/
|
|
24
|
+
export declare function defaultSlug(file: string, title?: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* The slug a publish will use: the explicit --slug when given, otherwise the
|
|
27
|
+
* title-derived default. An explicit slug with no letters or digits at all is
|
|
28
|
+
* rejected rather than silently swapped for the default — the author asked for
|
|
29
|
+
* one URL and must not get another.
|
|
30
|
+
*/
|
|
31
|
+
export declare function resolveShareSlug(explicit: string | undefined, file: string, title?: string): string;
|
|
15
32
|
export declare function readShareEndpoint(config?: ArtifactsConfig): {
|
|
16
33
|
baseUrl: string;
|
|
17
34
|
token: string;
|
package/dist/lib/share.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { execFileSync } from 'node:child_process';
|
|
2
2
|
import { randomBytes } from 'node:crypto';
|
|
3
3
|
import { existsSync, readFileSync } from 'node:fs';
|
|
4
|
-
import { basename,
|
|
5
|
-
import
|
|
4
|
+
import { basename, extname, join } from 'node:path';
|
|
5
|
+
import matter from 'gray-matter';
|
|
6
|
+
import { compileArtifact, slugify } from './render.js';
|
|
6
7
|
import { readConfig, updateConfig } from './config.js';
|
|
7
8
|
const UNIT_MS = { s: 1e3, m: 6e4, h: 36e5, d: 864e5, w: 6048e5 };
|
|
8
9
|
export function generateWriteToken() {
|
|
@@ -19,31 +20,56 @@ export function parseExpire(spec) {
|
|
|
19
20
|
return date.toISOString();
|
|
20
21
|
throw new Error(`Bad --expire '${spec}'. Use 30d, 12h, or an absolute date like 2026-08-01.`);
|
|
21
22
|
}
|
|
22
|
-
function
|
|
23
|
-
return
|
|
23
|
+
function fileSlug(file) {
|
|
24
|
+
return slugify(basename(file).replace(/\.[^.]+$/, '')).slice(0, 60) || 'artifact';
|
|
24
25
|
}
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
/**
|
|
27
|
+
* The slug when the author did not pass --slug: derived from the artifact's
|
|
28
|
+
* own title, falling back to the filename for title-less sources (images,
|
|
29
|
+
* HTML). Deterministic on purpose — re-sharing an updated artifact updates the
|
|
30
|
+
* same URL instead of minting a new one. The old default prefixed a
|
|
31
|
+
* cwd-derived project name and a random hex, which both invented provenance
|
|
32
|
+
* (the cwd repo is not necessarily the project the artifact is about) and made
|
|
33
|
+
* every re-publish a new link.
|
|
34
|
+
*/
|
|
35
|
+
export function defaultSlug(file, title = '') {
|
|
36
|
+
return slugify(title).slice(0, 60) || fileSlug(file);
|
|
27
37
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return
|
|
38
|
+
/**
|
|
39
|
+
* The slug a publish will use: the explicit --slug when given, otherwise the
|
|
40
|
+
* title-derived default. An explicit slug with no letters or digits at all is
|
|
41
|
+
* rejected rather than silently swapped for the default — the author asked for
|
|
42
|
+
* one URL and must not get another.
|
|
43
|
+
*/
|
|
44
|
+
export function resolveShareSlug(explicit, file, title = '') {
|
|
45
|
+
if (explicit !== undefined && !slugify(explicit)) {
|
|
46
|
+
throw new Error(`Bad --slug '${explicit}': it must contain at least one letter or digit.`);
|
|
47
|
+
}
|
|
48
|
+
return slugify(explicit ?? '') || defaultSlug(file, title);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The frontmatter title of a Markdown source, '' when there is none or the
|
|
52
|
+
* file cannot be parsed. Sharing must never fail because a title is missing —
|
|
53
|
+
* the filename fallback in defaultSlug covers that case.
|
|
54
|
+
*/
|
|
55
|
+
function artifactTitle(file) {
|
|
56
|
+
if (!/\.md$/i.test(file))
|
|
57
|
+
return '';
|
|
58
|
+
try {
|
|
59
|
+
const title = matter(readFileSync(file, 'utf8')).data.title;
|
|
60
|
+
return typeof title === 'string' ? title : '';
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
return '';
|
|
64
|
+
}
|
|
39
65
|
}
|
|
40
66
|
function githubUser(explicit) {
|
|
41
67
|
if (explicit)
|
|
42
|
-
return
|
|
68
|
+
return slugify(explicit);
|
|
43
69
|
try {
|
|
44
70
|
const out = execFileSync('gh', ['api', 'user', '-q', '.login'], { stdio: ['ignore', 'pipe', 'ignore'] }).toString().trim();
|
|
45
71
|
if (out)
|
|
46
|
-
return
|
|
72
|
+
return slugify(out);
|
|
47
73
|
}
|
|
48
74
|
catch {
|
|
49
75
|
// Fall through to git config.
|
|
@@ -51,7 +77,7 @@ function githubUser(explicit) {
|
|
|
51
77
|
try {
|
|
52
78
|
const out = execFileSync('git', ['config', '--global', 'github.user'], { stdio: ['ignore', 'pipe', 'ignore'] }).toString().trim();
|
|
53
79
|
if (out)
|
|
54
|
-
return
|
|
80
|
+
return slugify(out);
|
|
55
81
|
}
|
|
56
82
|
catch {
|
|
57
83
|
// Fall through to error.
|
|
@@ -83,10 +109,13 @@ export function readShareEndpoint(config = readConfig()) {
|
|
|
83
109
|
}
|
|
84
110
|
export async function publishArtifact(file, opts = {}) {
|
|
85
111
|
const endpoint = readShareEndpoint();
|
|
112
|
+
const title = artifactTitle(file);
|
|
86
113
|
let uploadPath = file;
|
|
87
114
|
if (/\.md$/i.test(file)) {
|
|
88
|
-
uploadPath = join(process.cwd(), '.artifacts', `${
|
|
89
|
-
|
|
115
|
+
uploadPath = join(process.cwd(), '.artifacts', `${fileSlug(file)}.html`);
|
|
116
|
+
// This command does its OWN upload below — compile only, never trigger the
|
|
117
|
+
// managed auto-publish (would mint an unwanted second link).
|
|
118
|
+
const result = await compileArtifact(file, uploadPath, { publish: false });
|
|
90
119
|
const errors = result.diagnostics.filter((diagnostic) => diagnostic.level === 'error');
|
|
91
120
|
if (errors.length)
|
|
92
121
|
throw new Error(`Artifact did not compile cleanly:\n${errors.map((error) => `- ${error.message}`).join('\n')}`);
|
|
@@ -94,7 +123,7 @@ export async function publishArtifact(file, opts = {}) {
|
|
|
94
123
|
if (!existsSync(uploadPath))
|
|
95
124
|
throw new Error(`File not found: ${uploadPath}`);
|
|
96
125
|
const username = githubUser(opts.githubUser);
|
|
97
|
-
const key = `${username}/${
|
|
126
|
+
const key = `${username}/${resolveShareSlug(opts.slug, uploadPath, title)}`;
|
|
98
127
|
const url = `${endpoint.baseUrl}/${key}`;
|
|
99
128
|
const expiresAt = parseExpire(opts.expire);
|
|
100
129
|
const headers = {
|
package/dist/lib/share.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"share.js","sourceRoot":"","sources":["../../src/lib/share.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAA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AAC,OAAe,EAAE,KAAa;IACtD,OAAO,YAAY,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QAC5B,GAAG,GAAG;QACN,KAAK,EAAE;YACL,GAAG,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC;YACpB,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;YACpC,UAAU,EAAE,KAAK;SAClB;KACF,CAAC,CAAC,CAAC;AACN,CAAC"}
|
package/dist/lib/templates.d.ts
CHANGED
|
@@ -22,6 +22,26 @@ export interface ArtifactContext {
|
|
|
22
22
|
}
|
|
23
23
|
export declare const STARTER_DESIGN = "---\nname: default\nfonts:\n body: Inter\n mono: JetBrains Mono\n display: Inter\ntheme:\n default: system\nthemes:\n light:\n background: \"#faf9f6\"\n surface: \"#ffffff\"\n surfaceAlt: \"#f2f4f0\"\n line: \"#e2e6df\"\n text: \"#1a1c1a\"\n muted: \"#5c655c\"\n accent: \"#4d7c0f\"\n accentAlt: \"#0e7490\"\n warn: \"#b45309\"\n danger: \"#dc2626\"\n dark:\n background: \"#0a0a0a\"\n surface: \"#111312\"\n surfaceAlt: \"#161a18\"\n line: \"#26302a\"\n text: \"#e7ece8\"\n muted: \"#8b938c\"\n accent: \"#a3e635\"\n accentAlt: \"#5ad6c0\"\n warn: \"#f5c451\"\n danger: \"#ff6b6b\"\nlayout:\n contentWidth: 980\n pagePadding: 24\n mobilePagePadding: 16\n heroTop: 40\n heroBottom: 28\n sectionSpacing: 36\n figureSpacing: 22\n panelPadding: 16\n footerSpacing: 64\n printMargin: 24\nartifact:\n density: compact\n radius: 10\n printTheme: light\n---\n\n# Design\n\nProject-wide artifact rendering defaults. Keep artifact-specific metadata in the Markdown artifact frontmatter.\n";
|
|
24
24
|
export declare function repositoryName(remote: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* A project the fleet actually knows about, from ~/.agents/projects/<name>.yaml
|
|
27
|
+
* (agents-cli keeps the real definitions there). `name` matches the Linear
|
|
28
|
+
* project / GitHub repo name; `repo` is the `owner/repo` remote; `paths` are
|
|
29
|
+
* the local directories the project owns (`root:` and `defaultPath:` — several
|
|
30
|
+
* projects can share one monorepo checkout and differ only by subdirectory).
|
|
31
|
+
*/
|
|
32
|
+
export interface KnownProject {
|
|
33
|
+
name: string;
|
|
34
|
+
repo: string;
|
|
35
|
+
paths: string[];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Read the known project list. The yaml files are flat `key: value` pairs for
|
|
39
|
+
* the fields provenance needs, so a line parser is enough — this package does
|
|
40
|
+
* not take a yaml dependency for one directory of simple manifests. An absent
|
|
41
|
+
* or unreadable directory (a non-fleet machine) yields an empty list, never an
|
|
42
|
+
* error: detection then falls back to the git remote alone.
|
|
43
|
+
*/
|
|
44
|
+
export declare function knownProjects(dir?: string): KnownProject[];
|
|
25
45
|
/**
|
|
26
46
|
* True when `filePath` lands under a repo's committed `.agents/artifacts/` tree.
|
|
27
47
|
*
|
|
@@ -40,7 +60,9 @@ export declare function isPublishedArtifactPath(filePath: string): boolean;
|
|
|
40
60
|
* when the author left them blank.
|
|
41
61
|
*/
|
|
42
62
|
export declare function anonymizedArtifactContext(cwd?: string): ArtifactContext;
|
|
43
|
-
export declare function detectArtifactContext(cwd?: string
|
|
63
|
+
export declare function detectArtifactContext(cwd?: string, options?: {
|
|
64
|
+
projects?: KnownProject[];
|
|
65
|
+
}): ArtifactContext;
|
|
44
66
|
export declare function templateFor(kind: TemplateKind, context?: Partial<ArtifactContext>): string;
|
|
45
67
|
export declare const PLAN_TEMPLATE: string;
|
|
46
68
|
export declare const REPORT_TEMPLATE: string;
|
package/dist/lib/templates.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { execFileSync } from 'node:child_process';
|
|
2
|
-
import {
|
|
2
|
+
import { readdirSync, readFileSync, realpathSync } from 'node:fs';
|
|
3
|
+
import { homedir, hostname, userInfo } from 'node:os';
|
|
4
|
+
import { join } from 'node:path';
|
|
3
5
|
import matter from 'gray-matter';
|
|
4
6
|
import { randomWorksheetId } from './worksheet.js';
|
|
5
7
|
export const TEMPLATE_KINDS = ['plan', 'report', 'visual', 'worksheet'];
|
|
@@ -247,6 +249,104 @@ export function repositoryName(remote) {
|
|
|
247
249
|
return remote.replace(/^\/+|\.git$/g, '');
|
|
248
250
|
}
|
|
249
251
|
}
|
|
252
|
+
function expandHome(path) {
|
|
253
|
+
if (path === '~')
|
|
254
|
+
return homedir();
|
|
255
|
+
if (path.startsWith('~/'))
|
|
256
|
+
return join(homedir(), path.slice(2));
|
|
257
|
+
return path;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Read the known project list. The yaml files are flat `key: value` pairs for
|
|
261
|
+
* the fields provenance needs, so a line parser is enough — this package does
|
|
262
|
+
* not take a yaml dependency for one directory of simple manifests. An absent
|
|
263
|
+
* or unreadable directory (a non-fleet machine) yields an empty list, never an
|
|
264
|
+
* error: detection then falls back to the git remote alone.
|
|
265
|
+
*/
|
|
266
|
+
export function knownProjects(dir = join(homedir(), '.agents', 'projects')) {
|
|
267
|
+
let files;
|
|
268
|
+
try {
|
|
269
|
+
files = readdirSync(dir).filter((file) => file.endsWith('.yaml') || file.endsWith('.yml'));
|
|
270
|
+
}
|
|
271
|
+
catch {
|
|
272
|
+
return [];
|
|
273
|
+
}
|
|
274
|
+
const projects = [];
|
|
275
|
+
for (const file of files) {
|
|
276
|
+
let text;
|
|
277
|
+
try {
|
|
278
|
+
text = readFileSync(join(dir, file), 'utf8');
|
|
279
|
+
}
|
|
280
|
+
catch {
|
|
281
|
+
continue;
|
|
282
|
+
}
|
|
283
|
+
const field = (name) => text.match(new RegExp(`^${name}:\\s*['"]?([^'\\n"]+?)['"]?\\s*$`, 'm'))?.[1] ?? '';
|
|
284
|
+
const name = field('name');
|
|
285
|
+
if (!name)
|
|
286
|
+
continue;
|
|
287
|
+
projects.push({
|
|
288
|
+
name,
|
|
289
|
+
repo: field('repo'),
|
|
290
|
+
paths: [field('root'), field('defaultPath')].filter(Boolean).map(expandHome),
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
return projects;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* The project an artifact is *about*, or '' when that cannot be determined
|
|
297
|
+
* honestly. Provenance must never be invented: an empty field the author fills
|
|
298
|
+
* (or `artifacts check` warns about) is correct; a fabricated one is not.
|
|
299
|
+
*
|
|
300
|
+
* Resolution, most canonical first:
|
|
301
|
+
* 1. A checkout whose git root is a `.agents` directory is the dotagents
|
|
302
|
+
* store, not a project — an artifact sitting in ~/.agents/artifacts/ is
|
|
303
|
+
* *about* some other repo, so cwd provenance says nothing. Empty.
|
|
304
|
+
* 2. Exactly one known project (~/.agents/projects/) claims this spot: a
|
|
305
|
+
* declared `root`/`defaultPath` that contains cwd wins over a bare `repo`
|
|
306
|
+
* match, and the longest containing path wins among those, so inside the
|
|
307
|
+
* muqsitnawaz/agents monorepo `agents/rush/cli` resolves to rush-cli, not
|
|
308
|
+
* rush-app. A tie — several projects share a repo or a root and no
|
|
309
|
+
* subdirectory disambiguates — resolves to empty, not to whichever
|
|
310
|
+
* manifest readdir happened to return first.
|
|
311
|
+
* 3. The git remote's repository name — a real GitHub repo name, honest when
|
|
312
|
+
* the artifact genuinely lives inside that project's own checkout.
|
|
313
|
+
* A directory basename is never a fallback: a checkout with no remote yields
|
|
314
|
+
* an empty project, not a guess.
|
|
315
|
+
*/
|
|
316
|
+
function detectProject(cwd, root, repository, projects) {
|
|
317
|
+
if (root && (root.split(/[\\/]/).at(-1) || '') === '.agents')
|
|
318
|
+
return '';
|
|
319
|
+
const normalize = (path) => path.replace(/[\\/]+$/, '');
|
|
320
|
+
const normalizedCwd = normalize(cwd);
|
|
321
|
+
// A candidate scores the length of its longest declared path containing cwd,
|
|
322
|
+
// or 0 for a repo-only match — so any subdirectory claim outranks a whole-
|
|
323
|
+
// repo one, and the most specific subdirectory claim outranks a shallower.
|
|
324
|
+
let best;
|
|
325
|
+
let tied = false;
|
|
326
|
+
for (const project of projects) {
|
|
327
|
+
let score = 0;
|
|
328
|
+
for (const declared of project.paths.map(normalize)) {
|
|
329
|
+
if (declared && (normalizedCwd === declared || normalizedCwd.startsWith(`${declared}/`))) {
|
|
330
|
+
score = Math.max(score, declared.length);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
if (score === 0 && !(repository && project.repo && repository.toLowerCase() === project.repo.toLowerCase())) {
|
|
334
|
+
continue;
|
|
335
|
+
}
|
|
336
|
+
if (!best || score > best.score) {
|
|
337
|
+
best = { name: project.name, score };
|
|
338
|
+
tied = false;
|
|
339
|
+
}
|
|
340
|
+
else if (score === best.score) {
|
|
341
|
+
tied = true;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
if (best && !tied)
|
|
345
|
+
return best.name;
|
|
346
|
+
if (best && tied)
|
|
347
|
+
return '';
|
|
348
|
+
return repository.split('/').at(-1) || '';
|
|
349
|
+
}
|
|
250
350
|
function localDate() {
|
|
251
351
|
const now = new Date();
|
|
252
352
|
const month = String(now.getMonth() + 1).padStart(2, '0');
|
|
@@ -298,11 +398,21 @@ export function anonymizedArtifactContext(cwd = process.cwd()) {
|
|
|
298
398
|
sessionId: '',
|
|
299
399
|
};
|
|
300
400
|
}
|
|
301
|
-
export function detectArtifactContext(cwd = process.cwd()) {
|
|
401
|
+
export function detectArtifactContext(cwd = process.cwd(), options = {}) {
|
|
302
402
|
const root = gitValue(cwd, ['rev-parse', '--show-toplevel']);
|
|
303
403
|
const remote = gitValue(cwd, ['remote', 'get-url', 'origin']);
|
|
304
404
|
const repository = repositoryName(remote);
|
|
305
|
-
|
|
405
|
+
// git rev-parse returns the physical path; resolve cwd the same way so a
|
|
406
|
+
// symlinked tmpdir (/var → /private/var on macOS) still prefix-matches the
|
|
407
|
+
// declared project paths.
|
|
408
|
+
let resolvedCwd = cwd;
|
|
409
|
+
try {
|
|
410
|
+
resolvedCwd = realpathSync(cwd);
|
|
411
|
+
}
|
|
412
|
+
catch {
|
|
413
|
+
// Keep cwd as given.
|
|
414
|
+
}
|
|
415
|
+
const project = detectProject(resolvedCwd, root, repository, options.projects ?? knownProjects());
|
|
306
416
|
const session = firstEnvironmentValue([
|
|
307
417
|
'CODEX_THREAD_ID',
|
|
308
418
|
'CLAUDE_SESSION_ID',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/lib/templates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/lib/templates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,CAAU,CAAC;AAGjF,MAAM,YAAY,GAAiC;IACjD,IAAI,EAAE,MAAM;IACZ,QAAQ,EAAE,MAAM;IAChB,qBAAqB,EAAE,MAAM;IAC7B,mBAAmB,EAAE,MAAM;IAC3B,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;IAChB,SAAS,EAAE,WAAW;CACvB,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,GAAY;IACxC,IAAI,OAAO,GAAG,KAAK,QAAQ;Q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AAC,CAAC,CAAC;AAC9E,CAAC;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;AACjD,MAAM,CAAC,MAAM,eAAe,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;AACrD,MAAM,CAAC,MAAM,eAAe,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;AACrD,MAAM,CAAC,MAAM,kBAAkB,GAAG,WAAW,CAAC,WAAW,CAAC,CAAC"}
|
package/dist/lib/tokens.d.ts
CHANGED
|
@@ -7,4 +7,6 @@ export interface ArtifactTokenEstimate {
|
|
|
7
7
|
reductionPercent: number;
|
|
8
8
|
diagnostics: RenderResult['diagnostics'];
|
|
9
9
|
}
|
|
10
|
+
/** Drop compiler-inlined @font-face data URIs so estimate counts agent-authored HTML. */
|
|
11
|
+
export declare function htmlForAuthoringEstimate(html: string): string;
|
|
10
12
|
export declare function estimateArtifactTokens(filePath: string): Promise<ArtifactTokenEstimate>;
|
package/dist/lib/tokens.js
CHANGED
|
@@ -3,6 +3,10 @@ import { resolve } from 'node:path';
|
|
|
3
3
|
import { Tiktoken } from 'js-tiktoken/lite';
|
|
4
4
|
import o200kBase from 'js-tiktoken/ranks/o200k_base';
|
|
5
5
|
import { renderMarkdown } from './render.js';
|
|
6
|
+
/** Drop compiler-inlined @font-face data URIs so estimate counts agent-authored HTML. */
|
|
7
|
+
export function htmlForAuthoringEstimate(html) {
|
|
8
|
+
return html.replace(/@font-face\{[^}]*url\(data:font\/[^)]+\)[^}]*\}/g, '');
|
|
9
|
+
}
|
|
6
10
|
export async function estimateArtifactTokens(filePath) {
|
|
7
11
|
if (!/\.md$/i.test(filePath))
|
|
8
12
|
throw new Error('Token estimates require a Markdown source file.');
|
|
@@ -10,7 +14,7 @@ export async function estimateArtifactTokens(filePath) {
|
|
|
10
14
|
const rendered = await renderMarkdown(filePath, { embedSource: false });
|
|
11
15
|
const tokenizer = new Tiktoken(o200kBase);
|
|
12
16
|
const markdownTokens = tokenizer.encode(markdown).length;
|
|
13
|
-
const htmlTokens = tokenizer.encode(rendered.html).length;
|
|
17
|
+
const htmlTokens = tokenizer.encode(htmlForAuthoringEstimate(rendered.html)).length;
|
|
14
18
|
const avoidedTokens = htmlTokens - markdownTokens;
|
|
15
19
|
return {
|
|
16
20
|
encoding: 'o200k_base',
|
package/dist/lib/tokens.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../src/lib/tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,SAAS,MAAM,8BAA8B,CAAC;AACrD,OAAO,EAAE,cAAc,EAAqB,MAAM,aAAa,CAAC;AAWhE,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,QAAgB;IAC3D,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IACjG,MAAM,QAAQ,GAAG,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,CAAC;IACzD,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,QAAQ,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,CAAC;IACxE,MAAM,SAAS,GAAG,IAAI,QAAQ,CAAC,SAAS,CAAC,CAAC;IAC1C,MAAM,cAAc,GAAG,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC;IACzD,MAAM,UAAU,GAAG,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../src/lib/tokens.ts"],"names":[],"mappings":"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AQ,CAAC,WAAW;KAClC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
Copyright (c) 2016 The Inter Project Authors (https://github.com/rsms/inter)
|
|
2
|
+
|
|
3
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
4
|
+
This license is copied below, and is also available with a FAQ at:
|
|
5
|
+
http://scripts.sil.org/OFL
|
|
6
|
+
|
|
7
|
+
-----------------------------------------------------------
|
|
8
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
9
|
+
-----------------------------------------------------------
|
|
10
|
+
|
|
11
|
+
PREAMBLE
|
|
12
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
13
|
+
development of collaborative font projects, to support the font creation
|
|
14
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
15
|
+
open framework in which fonts may be shared and improved in partnership
|
|
16
|
+
with others.
|
|
17
|
+
|
|
18
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
19
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
20
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
21
|
+
redistributed and/or sold with any software provided that any reserved
|
|
22
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
23
|
+
however, cannot be released under any other type of license. The
|
|
24
|
+
requirement for fonts to remain under this license does not apply
|
|
25
|
+
to any document created using the fonts or their derivatives.
|
|
26
|
+
|
|
27
|
+
DEFINITIONS
|
|
28
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
29
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
30
|
+
include source files, build scripts and documentation.
|
|
31
|
+
|
|
32
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
33
|
+
copyright statement(s).
|
|
34
|
+
|
|
35
|
+
"Original Version" refers to the collection of Font Software components as
|
|
36
|
+
distributed by the Copyright Holder(s).
|
|
37
|
+
|
|
38
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
39
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
40
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
41
|
+
new environment.
|
|
42
|
+
|
|
43
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
44
|
+
writer or other person who contributed to the Font Software.
|
|
45
|
+
|
|
46
|
+
PERMISSION AND CONDITIONS
|
|
47
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
48
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
49
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
50
|
+
Software, subject to the following conditions:
|
|
51
|
+
|
|
52
|
+
1) Neither the Font Software nor any of its individual components,
|
|
53
|
+
in Original or Modified Versions, may be sold by itself.
|
|
54
|
+
|
|
55
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
56
|
+
redistributed and/or sold with any software, provided that each copy
|
|
57
|
+
contains the above copyright notice and this license. These can be
|
|
58
|
+
included either as stand-alone text files, human-readable headers or
|
|
59
|
+
in the appropriate machine-readable metadata fields within text or
|
|
60
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
61
|
+
|
|
62
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
63
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
64
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
65
|
+
presented to the users.
|
|
66
|
+
|
|
67
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
68
|
+
Software shall not be used to promote, endorse or advertise any
|
|
69
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
70
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
71
|
+
permission.
|
|
72
|
+
|
|
73
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
74
|
+
must be distributed entirely under this license, and must not be
|
|
75
|
+
distributed under any other license. The requirement for fonts to
|
|
76
|
+
remain under this license does not apply to any document created
|
|
77
|
+
using the Font Software.
|
|
78
|
+
|
|
79
|
+
TERMINATION
|
|
80
|
+
This license becomes null and void if any of the above conditions are
|
|
81
|
+
not met.
|
|
82
|
+
|
|
83
|
+
DISCLAIMER
|
|
84
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
85
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
86
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
87
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
88
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
89
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
90
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
91
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
92
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
Binary file
|