@miller-tech/uap 1.48.1 → 1.49.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/dist/.tsbuildinfo +1 -1
- package/dist/bin/cli.js +8 -2
- package/dist/bin/cli.js.map +1 -1
- package/dist/cli/guided-setup.d.ts +15 -0
- package/dist/cli/guided-setup.d.ts.map +1 -0
- package/dist/cli/guided-setup.js +122 -0
- package/dist/cli/guided-setup.js.map +1 -0
- package/dist/cli/init.d.ts +1 -0
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +10 -0
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/prompt-ui.d.ts +54 -0
- package/dist/cli/prompt-ui.d.ts.map +1 -0
- package/dist/cli/prompt-ui.js +72 -0
- package/dist/cli/prompt-ui.js.map +1 -0
- package/dist/cli/setup-backup.d.ts +25 -0
- package/dist/cli/setup-backup.d.ts.map +1 -0
- package/dist/cli/setup-backup.js +44 -0
- package/dist/cli/setup-backup.js.map +1 -0
- package/dist/cli/setup-extract.d.ts +64 -0
- package/dist/cli/setup-extract.d.ts.map +1 -0
- package/dist/cli/setup-extract.js +287 -0
- package/dist/cli/setup-extract.js.map +1 -0
- package/dist/cli/setup.d.ts +19 -2
- package/dist/cli/setup.d.ts.map +1 -1
- package/dist/cli/setup.js +69 -23
- package/dist/cli/setup.js.map +1 -1
- package/dist/utils/lazy-imports.d.ts +6 -0
- package/dist/utils/lazy-imports.d.ts.map +1 -1
- package/dist/utils/lazy-imports.js +13 -0
- package/dist/utils/lazy-imports.js.map +1 -1
- package/dist/utils/merge-claude-md.d.ts +13 -0
- package/dist/utils/merge-claude-md.d.ts.map +1 -1
- package/dist/utils/merge-claude-md.js +3 -3
- package/dist/utils/merge-claude-md.js.map +1 -1
- package/package.json +4 -3
- package/src/policies/enforcers/__pycache__/_common.cpython-312.pyc +0 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PromptUI — a thin prompt abstraction over @clack/prompts.
|
|
3
|
+
*
|
|
4
|
+
* Decouples the setup wizard's flow from the concrete TUI library and gives a
|
|
5
|
+
* single seam for headless / non-interactive runs (CI, tests). Cancel (Ctrl-C)
|
|
6
|
+
* handling is centralized in the clack implementation so the wizard body never
|
|
7
|
+
* sprinkles `isCancel` checks.
|
|
8
|
+
*/
|
|
9
|
+
import { ensureClack } from '../utils/lazy-imports.js';
|
|
10
|
+
/**
|
|
11
|
+
* Clack-backed interactive UI. On cancel it prints a cancel notice and exits
|
|
12
|
+
* cleanly (no partial work — the wizard only writes after the final confirm).
|
|
13
|
+
*/
|
|
14
|
+
export async function createClackUI() {
|
|
15
|
+
const clack = await ensureClack();
|
|
16
|
+
const guard = (value) => {
|
|
17
|
+
if (clack.isCancel(value)) {
|
|
18
|
+
clack.cancel('Setup cancelled — no changes were made.');
|
|
19
|
+
process.exit(0);
|
|
20
|
+
}
|
|
21
|
+
return value;
|
|
22
|
+
};
|
|
23
|
+
// clack's prompt generics can't be inferred through this adapter; options are
|
|
24
|
+
// cast at the boundary while the public PromptUI signatures keep call sites
|
|
25
|
+
// fully type-safe.
|
|
26
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
27
|
+
return {
|
|
28
|
+
intro: (m) => clack.intro(m),
|
|
29
|
+
outro: (m) => clack.outro(m),
|
|
30
|
+
note: (m, t) => clack.note(m, t),
|
|
31
|
+
select: async (opts) => guard(await clack.select({
|
|
32
|
+
message: opts.message,
|
|
33
|
+
options: opts.options,
|
|
34
|
+
initialValue: opts.initialValue,
|
|
35
|
+
})),
|
|
36
|
+
multiselect: async (opts) => guard((await clack.multiselect({
|
|
37
|
+
message: opts.message,
|
|
38
|
+
options: opts.options,
|
|
39
|
+
initialValues: opts.initialValues,
|
|
40
|
+
required: opts.required ?? false,
|
|
41
|
+
}))),
|
|
42
|
+
confirm: async (opts) => guard(await clack.confirm({ message: opts.message, initialValue: opts.initialValue ?? true })),
|
|
43
|
+
text: async (opts) => guard(await clack.text({
|
|
44
|
+
message: opts.message,
|
|
45
|
+
placeholder: opts.placeholder,
|
|
46
|
+
initialValue: opts.initialValue,
|
|
47
|
+
})),
|
|
48
|
+
spinner: () => {
|
|
49
|
+
const s = clack.spinner();
|
|
50
|
+
return { start: (m) => s.start(m), stop: (m) => s.stop(m) };
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
/* eslint-enable @typescript-eslint/no-explicit-any */
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Non-interactive UI: returns the initial/default value for every prompt and
|
|
57
|
+
* never reads stdin. The headless path for CI and the unit-test seam — the same
|
|
58
|
+
* wizard body runs against it deterministically.
|
|
59
|
+
*/
|
|
60
|
+
export function createNonInteractiveUI() {
|
|
61
|
+
return {
|
|
62
|
+
intro: () => undefined,
|
|
63
|
+
outro: () => undefined,
|
|
64
|
+
note: () => undefined,
|
|
65
|
+
select: async (opts) => opts.initialValue ?? opts.options[0]?.value,
|
|
66
|
+
multiselect: async (opts) => opts.initialValues ?? [],
|
|
67
|
+
confirm: async (opts) => opts.initialValue ?? true,
|
|
68
|
+
text: async (opts) => opts.initialValue ?? '',
|
|
69
|
+
spinner: () => ({ start: () => undefined, stop: () => undefined }),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=prompt-ui.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-ui.js","sourceRoot":"","sources":["../../src/cli/prompt-ui.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAwBvD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa;IACjC,MAAM,KAAK,GAAG,MAAM,WAAW,EAAE,CAAC;IAElC,MAAM,KAAK,GAAG,CAAI,KAAiB,EAAK,EAAE;QACxC,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1B,K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}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Backup of agent instruction files before `uap init`/`uap setup` modifies them.
|
|
3
|
+
*
|
|
4
|
+
* init merges/regenerates CLAUDE.md (and platform AGENTS.md) and rewrites
|
|
5
|
+
* `.uap.json`; this captures the pre-change state under `.uap-backups/<date>/`
|
|
6
|
+
* (via the shared, idempotent {@link backupFile}) so a setup run is always
|
|
7
|
+
* reversible. Fail-soft per file — a backup failure never blocks setup.
|
|
8
|
+
*/
|
|
9
|
+
/** Agent instruction files (and config) a setup run may rewrite or merge. */
|
|
10
|
+
export declare const INSTRUCTION_FILES: readonly ["CLAUDE.md", "AGENTS.md", "AGENT.md", "GEMINI.md", ".cursorrules", ".clinerules", ".windsurfrules", ".uap.json"];
|
|
11
|
+
export interface BackupResult {
|
|
12
|
+
/** Files that existed and were backed up (or already had a backup today). */
|
|
13
|
+
backedUp: string[];
|
|
14
|
+
/** Files absent or that failed to back up (non-fatal). */
|
|
15
|
+
skipped: string[];
|
|
16
|
+
/** Backup date folder (YYYY-MM-DD). */
|
|
17
|
+
date: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Back up every present instruction file under `.uap-backups/<date>/`.
|
|
21
|
+
* Idempotent (relies on backupFile returning the existing backup path) and
|
|
22
|
+
* fail-soft. Returns a report for the setup summary.
|
|
23
|
+
*/
|
|
24
|
+
export declare function backupInstructionFiles(cwd: string): BackupResult;
|
|
25
|
+
//# sourceMappingURL=setup-backup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup-backup.d.ts","sourceRoot":"","sources":["../../src/cli/setup-backup.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,6EAA6E;AAC7E,eAAO,MAAM,iBAAiB,4HASpB,CAAC;AAEX,MAAM,WAAW,YAAY;IAC3B,6EAA6E;IAC7E,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,0DAA0D;IAC1D,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,uCAAuC;IACvC,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,CAgBhE"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Backup of agent instruction files before `uap init`/`uap setup` modifies them.
|
|
3
|
+
*
|
|
4
|
+
* init merges/regenerates CLAUDE.md (and platform AGENTS.md) and rewrites
|
|
5
|
+
* `.uap.json`; this captures the pre-change state under `.uap-backups/<date>/`
|
|
6
|
+
* (via the shared, idempotent {@link backupFile}) so a setup run is always
|
|
7
|
+
* reversible. Fail-soft per file — a backup failure never blocks setup.
|
|
8
|
+
*/
|
|
9
|
+
import { backupFile } from '../telemetry/session-telemetry.js';
|
|
10
|
+
/** Agent instruction files (and config) a setup run may rewrite or merge. */
|
|
11
|
+
export const INSTRUCTION_FILES = [
|
|
12
|
+
'CLAUDE.md',
|
|
13
|
+
'AGENTS.md',
|
|
14
|
+
'AGENT.md',
|
|
15
|
+
'GEMINI.md',
|
|
16
|
+
'.cursorrules',
|
|
17
|
+
'.clinerules',
|
|
18
|
+
'.windsurfrules',
|
|
19
|
+
'.uap.json',
|
|
20
|
+
];
|
|
21
|
+
/**
|
|
22
|
+
* Back up every present instruction file under `.uap-backups/<date>/`.
|
|
23
|
+
* Idempotent (relies on backupFile returning the existing backup path) and
|
|
24
|
+
* fail-soft. Returns a report for the setup summary.
|
|
25
|
+
*/
|
|
26
|
+
export function backupInstructionFiles(cwd) {
|
|
27
|
+
const date = new Date().toISOString().split('T')[0];
|
|
28
|
+
const backedUp = [];
|
|
29
|
+
const skipped = [];
|
|
30
|
+
for (const file of INSTRUCTION_FILES) {
|
|
31
|
+
try {
|
|
32
|
+
const backup = backupFile(file, cwd);
|
|
33
|
+
if (backup)
|
|
34
|
+
backedUp.push(file);
|
|
35
|
+
else
|
|
36
|
+
skipped.push(file);
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
skipped.push(file);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return { backedUp, skipped, date };
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=setup-backup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup-backup.js","sourceRoot":"","sources":["../../src/cli/setup-backup.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAE/D,6EAA6E;AAC7E,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,WAAW;IACX,WAAW;IACX,UAAU;IACV,WAAW;IACX,cAAc;IACd,aAAa;IACb,gBAAgB;IAChB,WAAW;CACH,CAAC;AAWX;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CAAC,GAAW;IAChD,MAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACpD,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,MAAM,OAAO,GAAa,EAAE,CAAC;IAE7B,KAAK,MAAM,IAAI,IAAI,iBAAiB,EAAE,CAAC;QACrC,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;YACrC,IAAI,MAAM;gBAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;;gBAC3B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1B,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrB,CAAC;IACH,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extraction engine — turn a project's UNIQUE custom agent instructions into
|
|
3
|
+
* reusable UAP policies and skills during setup.
|
|
4
|
+
*
|
|
5
|
+
* Existing instruction files (CLAUDE.md, AGENTS.md, …) usually contain a few
|
|
6
|
+
* bespoke rules/workflows alongside the UAP-standard scaffolding. This module
|
|
7
|
+
* detects those non-standard sections, heuristically classifies each as a
|
|
8
|
+
* policy (imperative rule/gate) or a skill (workflow/how-to), and — after the
|
|
9
|
+
* user confirms — emits valid policy `.md` + skill `SKILL.md` files.
|
|
10
|
+
*
|
|
11
|
+
* Deterministic (no LLM). Backup runs before this (see setup-backup.ts); v1
|
|
12
|
+
* copies content into policy/skill files and leaves the originals in place, so
|
|
13
|
+
* nothing is lost. Idempotent via a sidecar manifest of extracted slugs.
|
|
14
|
+
*/
|
|
15
|
+
import type { PromptUI } from './prompt-ui.js';
|
|
16
|
+
/** Agent instruction files scanned for custom content (config excluded). */
|
|
17
|
+
export declare const AGENT_INSTRUCTION_FILES: readonly ["CLAUDE.md", "AGENTS.md", "AGENT.md", "GEMINI.md", ".cursorrules", ".clinerules", ".windsurfrules"];
|
|
18
|
+
export type Classification = 'policy' | 'skill' | 'keep-inline';
|
|
19
|
+
export interface CustomSection {
|
|
20
|
+
title: string;
|
|
21
|
+
content: string;
|
|
22
|
+
sourceFile: string;
|
|
23
|
+
classification: Classification;
|
|
24
|
+
confidence: number;
|
|
25
|
+
slug: string;
|
|
26
|
+
/** Stable identity for idempotency (source file + title), independent of slug
|
|
27
|
+
* so two distinct sections that slugify the same aren't conflated. */
|
|
28
|
+
key: string;
|
|
29
|
+
}
|
|
30
|
+
export interface ExtractionResult {
|
|
31
|
+
detected: CustomSection[];
|
|
32
|
+
extractedPolicies: string[];
|
|
33
|
+
extractedSkills: string[];
|
|
34
|
+
skipped: string[];
|
|
35
|
+
}
|
|
36
|
+
export declare function slugify(title: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* Heuristically classify a section. Policy signals are imperative rules/gates;
|
|
39
|
+
* skill signals are workflow/how-to. Biased toward keep-inline when ambiguous
|
|
40
|
+
* so content the user expects in CLAUDE.md isn't moved unnecessarily.
|
|
41
|
+
*/
|
|
42
|
+
export declare function classifySection(title: string, content: string): {
|
|
43
|
+
classification: Classification;
|
|
44
|
+
confidence: number;
|
|
45
|
+
};
|
|
46
|
+
/** Existing agent instruction files present in the project. */
|
|
47
|
+
export declare function findInstructionFiles(cwd: string): string[];
|
|
48
|
+
/**
|
|
49
|
+
* Detect non-standard (custom) sections across the project's instruction files,
|
|
50
|
+
* pre-classified. Already-extracted sections (per the manifest) are skipped.
|
|
51
|
+
*/
|
|
52
|
+
export declare function detectCustomSections(cwd: string): CustomSection[];
|
|
53
|
+
/** Detect + print what would be extracted, writing nothing (non-interactive default). */
|
|
54
|
+
export declare function reportOnly(sections: CustomSection[], log?: (m: string) => void): void;
|
|
55
|
+
/** Non-interactive auto-extract per heuristic (skips keep-inline). */
|
|
56
|
+
export declare function extractAuto(cwd: string): Promise<ExtractionResult>;
|
|
57
|
+
/**
|
|
58
|
+
* Interactive review: choose which custom sections to extract and confirm the
|
|
59
|
+
* target (policy/skill/skip) for each, then emit and report.
|
|
60
|
+
*/
|
|
61
|
+
export declare function extractInteractive(cwd: string, ui: PromptUI): Promise<ExtractionResult>;
|
|
62
|
+
/** True when there is at least one extractable custom section. */
|
|
63
|
+
export declare function hasExtractableContent(cwd: string): boolean;
|
|
64
|
+
//# sourceMappingURL=setup-extract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup-extract.d.ts","sourceRoot":"","sources":["../../src/cli/setup-extract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAMH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,4EAA4E;AAC5E,eAAO,MAAM,uBAAuB,+GAQ1B,CAAC;AAEX,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,OAAO,GAAG,aAAa,CAAC;AAEhE,MAAM,WAAW,a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MAAM,GAAG,OAAO,CAE1D"}
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extraction engine — turn a project's UNIQUE custom agent instructions into
|
|
3
|
+
* reusable UAP policies and skills during setup.
|
|
4
|
+
*
|
|
5
|
+
* Existing instruction files (CLAUDE.md, AGENTS.md, …) usually contain a few
|
|
6
|
+
* bespoke rules/workflows alongside the UAP-standard scaffolding. This module
|
|
7
|
+
* detects those non-standard sections, heuristically classifies each as a
|
|
8
|
+
* policy (imperative rule/gate) or a skill (workflow/how-to), and — after the
|
|
9
|
+
* user confirms — emits valid policy `.md` + skill `SKILL.md` files.
|
|
10
|
+
*
|
|
11
|
+
* Deterministic (no LLM). Backup runs before this (see setup-backup.ts); v1
|
|
12
|
+
* copies content into policy/skill files and leaves the originals in place, so
|
|
13
|
+
* nothing is lost. Idempotent via a sidecar manifest of extracted slugs.
|
|
14
|
+
*/
|
|
15
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
|
|
16
|
+
import { join } from 'path';
|
|
17
|
+
import { parseSections, isStandardSection } from '../utils/merge-claude-md.js';
|
|
18
|
+
import { getPolicyMemoryManager } from '../policies/policy-memory.js';
|
|
19
|
+
/** Agent instruction files scanned for custom content (config excluded). */
|
|
20
|
+
export const AGENT_INSTRUCTION_FILES = [
|
|
21
|
+
'CLAUDE.md',
|
|
22
|
+
'AGENTS.md',
|
|
23
|
+
'AGENT.md',
|
|
24
|
+
'GEMINI.md',
|
|
25
|
+
'.cursorrules',
|
|
26
|
+
'.clinerules',
|
|
27
|
+
'.windsurfrules',
|
|
28
|
+
];
|
|
29
|
+
const MANIFEST_PATH = join('.uap', 'extracted.json');
|
|
30
|
+
function loadManifest(cwd) {
|
|
31
|
+
try {
|
|
32
|
+
const raw = readFileSync(join(cwd, MANIFEST_PATH), 'utf-8');
|
|
33
|
+
const data = JSON.parse(raw);
|
|
34
|
+
return new Set(data.slugs ?? []);
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return new Set();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function saveManifest(cwd, slugs) {
|
|
41
|
+
try {
|
|
42
|
+
mkdirSync(join(cwd, '.uap'), { recursive: true });
|
|
43
|
+
writeFileSync(join(cwd, MANIFEST_PATH), JSON.stringify({ slugs: [...slugs] }, null, 2));
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
/* sidecar is best-effort */
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export function slugify(title) {
|
|
50
|
+
return title
|
|
51
|
+
.toLowerCase()
|
|
52
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
53
|
+
.replace(/^-+|-+$/g, '')
|
|
54
|
+
.slice(0, 60) || 'custom';
|
|
55
|
+
}
|
|
56
|
+
/** Resolve a slug that doesn't collide with an existing file at dir/<slug><ext>. */
|
|
57
|
+
function uniqueSlug(base, exists) {
|
|
58
|
+
if (!exists(base))
|
|
59
|
+
return base;
|
|
60
|
+
for (let n = 2; n < 100; n++) {
|
|
61
|
+
const candidate = `${base}-${n}`;
|
|
62
|
+
if (!exists(candidate))
|
|
63
|
+
return candidate;
|
|
64
|
+
}
|
|
65
|
+
return `${base}-${Date.now()}`;
|
|
66
|
+
}
|
|
67
|
+
const POLICY_RE = /\b(MUST|DO NOT|DON'T|NEVER|ALWAYS|REQUIRED|SHALL|PROHIBITED|FORBIDDEN|MANDATORY|GATE|ENFORCE)\b/gi;
|
|
68
|
+
const SKILL_RE = /\b(how to|workflow|procedure|step\s*\d|usage|run the|guide)\b/gi;
|
|
69
|
+
/**
|
|
70
|
+
* Heuristically classify a section. Policy signals are imperative rules/gates;
|
|
71
|
+
* skill signals are workflow/how-to. Biased toward keep-inline when ambiguous
|
|
72
|
+
* so content the user expects in CLAUDE.md isn't moved unnecessarily.
|
|
73
|
+
*/
|
|
74
|
+
export function classifySection(title, content) {
|
|
75
|
+
const text = `${title}\n${content}`;
|
|
76
|
+
let policyScore = (text.match(POLICY_RE) ?? []).length * 2;
|
|
77
|
+
let skillScore = (text.match(SKILL_RE) ?? []).length * 1.5;
|
|
78
|
+
// Structural signals
|
|
79
|
+
if (/^\s*[-*]\s*\[[ x]\]/m.test(content))
|
|
80
|
+
policyScore += 2; // checklist
|
|
81
|
+
if (/[⛔🔴]/.test(text))
|
|
82
|
+
policyScore += 2;
|
|
83
|
+
if (/^\s*\d+\.\s+/m.test(content))
|
|
84
|
+
skillScore += 1.5; // ordered steps
|
|
85
|
+
if (/```/.test(content))
|
|
86
|
+
skillScore += 1.5; // code block
|
|
87
|
+
if (/\b(gate|policy|prohibited)\b/i.test(title))
|
|
88
|
+
policyScore += 2;
|
|
89
|
+
if (/\b(workflow|guide|how|setup|deploy)\b/i.test(title))
|
|
90
|
+
skillScore += 1.5;
|
|
91
|
+
const total = policyScore + skillScore;
|
|
92
|
+
const confidence = total === 0 ? 0 : Math.abs(policyScore - skillScore) / total;
|
|
93
|
+
if (policyScore > skillScore && policyScore >= 4)
|
|
94
|
+
return { classification: 'policy', confidence };
|
|
95
|
+
if (skillScore > policyScore && skillScore >= 3)
|
|
96
|
+
return { classification: 'skill', confidence };
|
|
97
|
+
return { classification: 'keep-inline', confidence };
|
|
98
|
+
}
|
|
99
|
+
/** Existing agent instruction files present in the project. */
|
|
100
|
+
export function findInstructionFiles(cwd) {
|
|
101
|
+
return AGENT_INSTRUCTION_FILES.filter((f) => existsSync(join(cwd, f)));
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Detect non-standard (custom) sections across the project's instruction files,
|
|
105
|
+
* pre-classified. Already-extracted sections (per the manifest) are skipped.
|
|
106
|
+
*/
|
|
107
|
+
export function detectCustomSections(cwd) {
|
|
108
|
+
const alreadyExtracted = loadManifest(cwd);
|
|
109
|
+
const out = [];
|
|
110
|
+
for (const file of findInstructionFiles(cwd)) {
|
|
111
|
+
let sections;
|
|
112
|
+
try {
|
|
113
|
+
sections = parseSections(readFileSync(join(cwd, file), 'utf-8'));
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
for (const s of sections) {
|
|
119
|
+
if (!s.title || !s.content.trim())
|
|
120
|
+
continue;
|
|
121
|
+
if (isStandardSection(s.title))
|
|
122
|
+
continue;
|
|
123
|
+
const key = `${file}::${s.title.toLowerCase().trim()}`;
|
|
124
|
+
if (alreadyExtracted.has(key))
|
|
125
|
+
continue;
|
|
126
|
+
const { classification, confidence } = classifySection(s.title, s.content);
|
|
127
|
+
out.push({
|
|
128
|
+
title: s.title,
|
|
129
|
+
content: s.content.trim(),
|
|
130
|
+
sourceFile: file,
|
|
131
|
+
classification,
|
|
132
|
+
confidence,
|
|
133
|
+
slug: slugify(s.title),
|
|
134
|
+
key,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return out;
|
|
139
|
+
}
|
|
140
|
+
function policyMarkdown(section, slug) {
|
|
141
|
+
const stem = section.sourceFile.replace(/\.[^.]+$/, '').replace(/^\./, '');
|
|
142
|
+
return `# ${slug}
|
|
143
|
+
|
|
144
|
+
**Category**: custom
|
|
145
|
+
**Level**: RECOMMENDED
|
|
146
|
+
**Enforcement Stage**: pre-exec
|
|
147
|
+
**Tags**: extracted, ${stem}
|
|
148
|
+
|
|
149
|
+
## Rule
|
|
150
|
+
|
|
151
|
+
${section.content}
|
|
152
|
+
|
|
153
|
+
## Why
|
|
154
|
+
|
|
155
|
+
Extracted from ${section.sourceFile} during \`uap setup\` — a project-specific rule promoted to a reviewable UAP policy.
|
|
156
|
+
`;
|
|
157
|
+
}
|
|
158
|
+
function skillDescription(section) {
|
|
159
|
+
// First meaningful prose line: skip blanks, headings, and list/step markers
|
|
160
|
+
// (so a "1. Run build" workflow doesn't become a description of "1.").
|
|
161
|
+
const line = section.content
|
|
162
|
+
.split('\n')
|
|
163
|
+
.map((l) => l.trim())
|
|
164
|
+
.find((l) => l && !/^#{1,6}\s/.test(l) && !/^([-*+]|\d+\.)\s/.test(l) && !/^```/.test(l));
|
|
165
|
+
const base = (line ?? section.title).replace(/\s+/g, ' ').trim();
|
|
166
|
+
return base.length > 120 ? `${base.slice(0, 117)}…` : base;
|
|
167
|
+
}
|
|
168
|
+
function skillMarkdown(section) {
|
|
169
|
+
// JSON.stringify yields a valid YAML flow scalar — safe even when the source
|
|
170
|
+
// line contains colons, quotes, or markdown control characters.
|
|
171
|
+
return `---
|
|
172
|
+
name: ${section.slug}
|
|
173
|
+
description: ${JSON.stringify(skillDescription(section))}
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
# ${section.title}
|
|
177
|
+
|
|
178
|
+
${section.content}
|
|
179
|
+
`;
|
|
180
|
+
}
|
|
181
|
+
async function emitPolicy(cwd, section) {
|
|
182
|
+
const dir = join(cwd, 'policies');
|
|
183
|
+
mkdirSync(dir, { recursive: true });
|
|
184
|
+
const slug = uniqueSlug(section.slug, (s) => existsSync(join(dir, `${s}.md`)));
|
|
185
|
+
const md = policyMarkdown(section, slug);
|
|
186
|
+
writeFileSync(join(dir, `${slug}.md`), md);
|
|
187
|
+
// Register into the policy store (fail-soft — the .md on disk is the source of truth).
|
|
188
|
+
try {
|
|
189
|
+
await getPolicyMemoryManager().storeRawPolicy(md, { category: 'custom', tags: ['extracted'] });
|
|
190
|
+
}
|
|
191
|
+
catch {
|
|
192
|
+
/* registration is best-effort */
|
|
193
|
+
}
|
|
194
|
+
return slug;
|
|
195
|
+
}
|
|
196
|
+
function emitSkill(cwd, section) {
|
|
197
|
+
const root = join(cwd, 'skills');
|
|
198
|
+
const name = uniqueSlug(section.slug, (s) => existsSync(join(root, s)));
|
|
199
|
+
const dir = join(root, name);
|
|
200
|
+
mkdirSync(dir, { recursive: true });
|
|
201
|
+
writeFileSync(join(dir, 'SKILL.md'), skillMarkdown({ ...section, slug: name }));
|
|
202
|
+
return name;
|
|
203
|
+
}
|
|
204
|
+
/** Detect + print what would be extracted, writing nothing (non-interactive default). */
|
|
205
|
+
export function reportOnly(sections, log = console.log) {
|
|
206
|
+
if (sections.length === 0) {
|
|
207
|
+
log(' No custom (non-standard) instruction sections detected.');
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
log(` Detected ${sections.length} custom section(s) (run setup interactively, or --extract-auto, to extract):`);
|
|
211
|
+
for (const s of sections) {
|
|
212
|
+
log(` - [${s.classification}] ${s.title} (${s.sourceFile})`);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
/** Non-interactive auto-extract per heuristic (skips keep-inline). */
|
|
216
|
+
export async function extractAuto(cwd) {
|
|
217
|
+
const detected = detectCustomSections(cwd);
|
|
218
|
+
const result = { detected, extractedPolicies: [], extractedSkills: [], skipped: [] };
|
|
219
|
+
const manifest = loadManifest(cwd);
|
|
220
|
+
for (const s of detected) {
|
|
221
|
+
if (s.classification === 'policy')
|
|
222
|
+
result.extractedPolicies.push(await emitPolicy(cwd, s));
|
|
223
|
+
else if (s.classification === 'skill')
|
|
224
|
+
result.extractedSkills.push(emitSkill(cwd, s));
|
|
225
|
+
else {
|
|
226
|
+
result.skipped.push(s.title);
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
manifest.add(s.key);
|
|
230
|
+
}
|
|
231
|
+
saveManifest(cwd, manifest);
|
|
232
|
+
return result;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Interactive review: choose which custom sections to extract and confirm the
|
|
236
|
+
* target (policy/skill/skip) for each, then emit and report.
|
|
237
|
+
*/
|
|
238
|
+
export async function extractInteractive(cwd, ui) {
|
|
239
|
+
const detected = detectCustomSections(cwd);
|
|
240
|
+
const result = { detected, extractedPolicies: [], extractedSkills: [], skipped: [] };
|
|
241
|
+
if (detected.length === 0)
|
|
242
|
+
return result;
|
|
243
|
+
ui.note('Found custom instructions in your agent files. You can promote them to reusable UAP policies (rules/gates) or skills (workflows).', 'Extract custom content');
|
|
244
|
+
const chosen = await ui.multiselect({
|
|
245
|
+
message: 'Which custom sections to extract? (space to toggle, enter to confirm)',
|
|
246
|
+
options: detected.map((s) => ({
|
|
247
|
+
label: `${s.title} · ${s.sourceFile}`,
|
|
248
|
+
value: s.slug,
|
|
249
|
+
hint: `suggested: ${s.classification}`,
|
|
250
|
+
})),
|
|
251
|
+
initialValues: detected.filter((s) => s.classification !== 'keep-inline').map((s) => s.slug),
|
|
252
|
+
required: false,
|
|
253
|
+
});
|
|
254
|
+
const manifest = loadManifest(cwd);
|
|
255
|
+
for (const s of detected) {
|
|
256
|
+
if (!chosen.includes(s.slug)) {
|
|
257
|
+
result.skipped.push(s.title);
|
|
258
|
+
continue;
|
|
259
|
+
}
|
|
260
|
+
const target = await ui.select({
|
|
261
|
+
message: `Extract "${s.title}" as:`,
|
|
262
|
+
options: [
|
|
263
|
+
{ label: 'Policy (a rule/gate UAP enforces)', value: 'policy' },
|
|
264
|
+
{ label: 'Skill (a workflow/how-to UAP can load)', value: 'skill' },
|
|
265
|
+
{ label: 'Skip (leave inline)', value: 'keep-inline' },
|
|
266
|
+
],
|
|
267
|
+
initialValue: s.classification === 'keep-inline' ? 'skill' : s.classification,
|
|
268
|
+
});
|
|
269
|
+
if (target === 'policy')
|
|
270
|
+
result.extractedPolicies.push(await emitPolicy(cwd, s));
|
|
271
|
+
else if (target === 'skill')
|
|
272
|
+
result.extractedSkills.push(emitSkill(cwd, s));
|
|
273
|
+
else {
|
|
274
|
+
result.skipped.push(s.title);
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
manifest.add(s.key);
|
|
278
|
+
}
|
|
279
|
+
saveManifest(cwd, manifest);
|
|
280
|
+
ui.note(`Policies: ${result.extractedPolicies.length} → policies/\nSkills: ${result.extractedSkills.length} → skills/\nSkipped: ${result.skipped.length}`, 'Extraction complete');
|
|
281
|
+
return result;
|
|
282
|
+
}
|
|
283
|
+
/** True when there is at least one extractable custom section. */
|
|
284
|
+
export function hasExtractableContent(cwd) {
|
|
285
|
+
return detectCustomSections(cwd).length > 0;
|
|
286
|
+
}
|
|
287
|
+
//# sourceMappingURL=setup-extract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup-extract.js","sourceRoot":"","sources":["../../src/cli/setup-extract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACxE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAgB,MAAM,6BAA6B,CAAC;AAC7F,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAGtE,4EAA4E;AAC5E,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,WAAW;IACX,WAAW;IACX,UAAU;IACV,WAAW;IACX,cAAc;IACd,aAAa;IACb,gBAAgB;CACR,CAAC;AAuBX,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;AAErD,SAAS,YAAY,CAAC,GAAW;IAC/B,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,YAAY,CAAC,IAAI,CAAC,GAAG,EAAE,aAAa,CAAC,EAAE,OAAO,CAAC,CAAC;QAC5D,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAyB,CAAC;QACrD,OAAO,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;IACnC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,GAAG,EAAE,CAAC;IACnB,CAAC;AACH,CAAC;AAED,SAAS,YAAY,CAAC,GAAW,EAAE,KAAkB;IACnD,IAAI,CAAC;QACH,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAClD,aAAa,CAAC,IAAI,CAAC,GAAG,EAAE,aAAa,CAAC,EAAE,IAAI,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IAAI,CACL,aAAa,MAAM,CAAC,iBAAiB,CAAC,MAAM,yBAAyB,MAAM,CAAC,eAAe,CAAC,MAAM,wBAAwB,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,EACjJ,qBAAqB,CACtB,CAAC;IACF,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,kEAAkE;AAClE,MAAM,UAAU,qBAAqB,CAAC,GAAW;IAC/C,OAAO,oBAAoB,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;AAC9C,CAAC"}
|
package/dist/cli/setup.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
interface SetupOptions {
|
|
1
|
+
export interface SetupOptions {
|
|
2
2
|
platform?: string[];
|
|
3
3
|
patterns?: boolean;
|
|
4
4
|
memory?: boolean;
|
|
@@ -7,11 +7,28 @@ interface SetupOptions {
|
|
|
7
7
|
interactive?: boolean;
|
|
8
8
|
systemdServices?: boolean;
|
|
9
9
|
selfUpdate?: boolean;
|
|
10
|
+
nonInteractive?: boolean;
|
|
11
|
+
yes?: boolean;
|
|
12
|
+
extract?: boolean;
|
|
13
|
+
extractAuto?: boolean;
|
|
14
|
+
backup?: boolean;
|
|
15
|
+
legacyWizard?: boolean;
|
|
10
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Decide whether to run the guided (interactive) wizard. Default is interactive,
|
|
19
|
+
* but a non-TTY / CI / explicit --non-interactive|-y run uses the scripted path
|
|
20
|
+
* so pipelines never hang on a prompt.
|
|
21
|
+
*/
|
|
22
|
+
export declare function resolveInteractive(options: SetupOptions): boolean;
|
|
11
23
|
/**
|
|
12
24
|
* One-command setup: init + start services + venv + index patterns.
|
|
13
25
|
* Chains existing commands so everything "just works".
|
|
14
26
|
*/
|
|
15
27
|
export declare function setupCommand(options: SetupOptions): Promise<void>;
|
|
16
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Run the post-init setup steps (Qdrant, consolidation, venv, pattern index,
|
|
30
|
+
* MCP router, delivery-enforcement, hooks, summary). Shared by the scripted
|
|
31
|
+
* path and the guided wizard so neither duplicates the work.
|
|
32
|
+
*/
|
|
33
|
+
export declare function runSetupSteps(cwd: string, options: SetupOptions): Promise<void>;
|
|
17
34
|
//# sourceMappingURL=setup.d.ts.map
|
package/dist/cli/setup.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/cli/setup.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/cli/setup.ts"],"names":[],"mappings":"AAcA,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAIjE;AAED;;;GAGG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAwDvE;AAgBD;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAkKrF"}
|