@open-agent-toolkit/cli 0.3.8 → 0.3.10
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/README.md +3 -3
- package/assets/agents/oat-codebase-mapper.md +3 -2
- package/assets/agents/oat-reviewer.md +5 -13
- package/assets/agents/skeptical-evaluator.md +6 -2
- package/assets/bundle-metadata.json +1 -1
- package/assets/config/dispatch-matrix-recommendation.json +6 -6
- package/assets/docs/cli-utilities/backlog-lifecycle.md +3 -2
- package/assets/docs/cli-utilities/bootstrap.md +5 -2
- package/assets/docs/cli-utilities/config-and-local-state.md +13 -6
- package/assets/docs/cli-utilities/configuration.md +22 -17
- package/assets/docs/cli-utilities/tool-packs.md +60 -10
- package/assets/docs/cli-utilities/workflow-gates.md +1 -1
- package/assets/docs/contributing/code.md +9 -5
- package/assets/docs/contributing/updating-model-guidance.md +34 -6
- package/assets/docs/contributing/verifying-cursor-pins.md +38 -9
- package/assets/docs/provider-sync/commands.md +11 -8
- package/assets/docs/provider-sync/instruction-sync.md +241 -39
- package/assets/docs/provider-sync/providers.md +4 -4
- package/assets/docs/provider-sync/scope-and-surface.md +1 -1
- package/assets/docs/reference/cli-reference.md +2 -0
- package/assets/docs/reference/oat-directory-structure.md +12 -11
- package/assets/docs/reference/troubleshooting.md +19 -4
- package/assets/docs/workflows/projects/dispatch-ceiling.md +21 -14
- package/assets/docs/workflows/projects/implementation-execution.md +26 -9
- package/assets/docs/workflows/projects/lifecycle.md +4 -6
- package/assets/public-package-versions.json +4 -4
- package/assets/skills/oat-agent-instructions-analyze/SKILL.md +4 -4
- package/assets/skills/oat-agent-instructions-analyze/references/analysis-artifact-template.md +5 -5
- package/assets/skills/oat-agent-instructions-analyze/references/docs/rules-files.md +14 -11
- package/assets/skills/oat-agent-instructions-analyze/references/quality-checklist.md +2 -2
- package/assets/skills/oat-agent-instructions-analyze/scripts/resolve-instruction-files.sh +4 -3
- package/assets/skills/oat-agent-instructions-apply/SKILL.md +3 -3
- package/assets/skills/oat-agent-instructions-apply/references/docs/rules-files.md +14 -11
- package/assets/skills/oat-dispatch-subagents/SKILL.md +1 -1
- package/assets/skills/oat-dispatch-subagents/references/provider-cursor.md +5 -2
- package/assets/skills/oat-doctor/SKILL.md +17 -13
- package/assets/skills/oat-project-implement/SKILL.md +2 -2
- package/assets/skills/oat-project-implement/references/completion-and-closeout.md +33 -11
- package/assets/skills/oat-project-implement/references/dispatch-and-dry-run.md +1 -1
- package/assets/skills/oat-project-implement/references/phase-execution.md +109 -8
- package/assets/skills/oat-project-lite/SKILL.md +23 -1
- package/assets/skills/oat-project-next/SKILL.md +3 -3
- package/assets/skills/oat-project-plan-writing/SKILL.md +3 -3
- package/assets/skills/oat-project-progress/SKILL.md +2 -2
- package/assets/skills/subagent-orchestration/SKILL.md +1 -1
- package/assets/skills/subagent-orchestration/references/evidence-and-refresh.md +20 -8
- package/assets/skills/subagent-orchestration/references/provider-claude.md +25 -12
- package/assets/skills/subagent-orchestration/references/provider-codex.md +27 -18
- package/assets/skills/subagent-orchestration/references/provider-cursor.md +40 -10
- package/assets/templates/docs-app-mkdocs/docs/contributing.md +1 -3
- package/assets/templates/pjm-agents.md +7 -3
- package/assets/templates/state.md +2 -2
- package/dist/commands/backlog/archive.d.ts +10 -2
- package/dist/commands/backlog/archive.d.ts.map +1 -1
- package/dist/commands/backlog/archive.js +22 -6
- package/dist/commands/backlog/index.d.ts.map +1 -1
- package/dist/commands/backlog/index.js +5 -1
- package/dist/commands/backlog/rewrite-references.d.ts +41 -0
- package/dist/commands/backlog/rewrite-references.d.ts.map +1 -0
- package/dist/commands/backlog/rewrite-references.js +516 -0
- package/dist/commands/config/index.d.ts +1 -0
- package/dist/commands/config/index.d.ts.map +1 -1
- package/dist/commands/config/index.js +69 -34
- package/dist/commands/init/index.d.ts +6 -0
- package/dist/commands/init/index.d.ts.map +1 -1
- package/dist/commands/init/index.js +27 -4
- package/dist/commands/init/tools/index.d.ts +18 -1
- package/dist/commands/init/tools/index.d.ts.map +1 -1
- package/dist/commands/init/tools/index.js +84 -17
- package/dist/commands/init/tools/project-guidance.d.ts +19 -4
- package/dist/commands/init/tools/project-guidance.d.ts.map +1 -1
- package/dist/commands/init/tools/project-guidance.js +58 -15
- package/dist/commands/init/tools/workflows/index.d.ts.map +1 -1
- package/dist/commands/init/tools/workflows/index.js +5 -1
- package/dist/commands/instructions/instructions.types.d.ts +105 -4
- package/dist/commands/instructions/instructions.types.d.ts.map +1 -1
- package/dist/commands/instructions/instructions.types.js +4 -5
- package/dist/commands/instructions/instructions.utils.d.ts +161 -6
- package/dist/commands/instructions/instructions.utils.d.ts.map +1 -1
- package/dist/commands/instructions/instructions.utils.js +650 -12
- package/dist/commands/instructions/sync/sync.d.ts.map +1 -1
- package/dist/commands/instructions/sync/sync.js +256 -18
- package/dist/commands/instructions/validate/validate.d.ts.map +1 -1
- package/dist/commands/instructions/validate/validate.js +36 -8
- package/dist/commands/pjm/index.d.ts.map +1 -1
- package/dist/commands/pjm/index.js +19 -4
- package/dist/commands/pjm/init.d.ts +3 -0
- package/dist/commands/pjm/init.d.ts.map +1 -1
- package/dist/commands/pjm/init.js +23 -5
- package/dist/commands/shared/agents-md.d.ts +26 -5
- package/dist/commands/shared/agents-md.d.ts.map +1 -1
- package/dist/commands/shared/agents-md.js +182 -3
- package/dist/commands/tools/guidance/index.d.ts +15 -0
- package/dist/commands/tools/guidance/index.d.ts.map +1 -0
- package/dist/commands/tools/guidance/index.js +81 -0
- package/dist/commands/tools/index.d.ts.map +1 -1
- package/dist/commands/tools/index.js +2 -0
- package/dist/config/oat-config.d.ts +49 -3
- package/dist/config/oat-config.d.ts.map +1 -1
- package/dist/config/oat-config.js +107 -14
- package/dist/config/resolve.d.ts.map +1 -1
- package/dist/config/resolve.js +12 -2
- package/dist/providers/claude/dispatch-envelope.d.ts.map +1 -1
- package/dist/providers/claude/dispatch-envelope.js +1 -0
- package/dist/providers/claude/targets.d.ts +1 -0
- package/dist/providers/claude/targets.d.ts.map +1 -1
- package/dist/providers/claude/targets.js +3 -1
- package/dist/providers/codex/codec/shared.d.ts +3 -0
- package/dist/providers/codex/codec/shared.d.ts.map +1 -1
- package/dist/providers/codex/codec/shared.js +4 -0
- package/dist/providers/cursor/codec/catalog.d.ts +2 -2
- package/dist/providers/cursor/codec/catalog.d.ts.map +1 -1
- package/dist/providers/cursor/codec/catalog.js +45 -0
- package/dist/providers/cursor/codec/mapping-validation.d.ts +4 -0
- package/dist/providers/cursor/codec/mapping-validation.d.ts.map +1 -0
- package/dist/providers/cursor/codec/mapping-validation.js +25 -0
- package/dist/providers/cursor/codec/materialize.d.ts.map +1 -1
- package/dist/providers/cursor/codec/materialize.js +2 -11
- package/dist/providers/cursor/codec/sync-extension.d.ts.map +1 -1
- package/dist/providers/cursor/codec/sync-extension.js +2 -11
- package/package.json +2 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { join } from 'node:path';
|
|
2
|
+
import { buildAgentsMdManagedBlock, formatAgentsMdGuidanceResult, } from '../../shared/agents-md.js';
|
|
2
3
|
import { CliError } from '../../../errors/index.js';
|
|
3
4
|
export function reportableProjectGuidance(plan) {
|
|
4
5
|
return {
|
|
@@ -8,6 +9,30 @@ export function reportableProjectGuidance(plan) {
|
|
|
8
9
|
...(plan.manualPatch ? { manualPatch: plan.manualPatch } : {}),
|
|
9
10
|
};
|
|
10
11
|
}
|
|
12
|
+
export function isProjectGuidanceIncomplete(plan) {
|
|
13
|
+
return plan.action === 'blocked' || plan.action === 'manual-required';
|
|
14
|
+
}
|
|
15
|
+
/** Prints one guidance plan in the human form every guidance surface uses. */
|
|
16
|
+
export function reportProjectGuidancePlan(logger, plan) {
|
|
17
|
+
const message = `Project guidance: ${plan.action} — ${plan.reason}`;
|
|
18
|
+
if (plan.action === 'skipped') {
|
|
19
|
+
logger.warn(message);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (!isProjectGuidanceIncomplete(plan)) {
|
|
23
|
+
logger.info(message);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
logger.warn(message);
|
|
27
|
+
if (plan.manualPatch) {
|
|
28
|
+
for (const line of formatAgentsMdGuidanceResult({
|
|
29
|
+
action: 'manual-required',
|
|
30
|
+
manualPatch: plan.manualPatch,
|
|
31
|
+
})) {
|
|
32
|
+
logger.info(line);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
11
36
|
const PACK_DESCRIPTIONS = {
|
|
12
37
|
core: 'Diagnostics and documentation (oat-doctor, oat-docs)',
|
|
13
38
|
docs: 'Documentation and instruction governance workflows',
|
|
@@ -18,20 +43,34 @@ const PACK_DESCRIPTIONS = {
|
|
|
18
43
|
research: 'Research, analysis, verification, and synthesis',
|
|
19
44
|
brainstorm: 'Always-on brainstorming entry point with visual companion',
|
|
20
45
|
};
|
|
21
|
-
export function buildToolPacksSectionBody(packs) {
|
|
46
|
+
export function buildToolPacksSectionBody(packs, options = {}) {
|
|
47
|
+
// Directories are named by pack membership, never by directory existence:
|
|
48
|
+
// `oat init --scope project` creates an empty `.agents/skills/`, and
|
|
49
|
+
// unrelated repository skills may live there.
|
|
50
|
+
const projectPacks = packs.filter((pack) => pack.scope === 'project' || pack.scope === 'both');
|
|
22
51
|
const userPacks = packs.filter((pack) => pack.scope === 'user' || pack.scope === 'both');
|
|
52
|
+
const hasOtherProjectSkills = (options.otherProjectSkills?.length ?? 0) > 0;
|
|
23
53
|
const hasWorkflows = packs.some((pack) => pack.pack === 'workflows');
|
|
24
|
-
const lines = [
|
|
25
|
-
|
|
26
|
-
''
|
|
27
|
-
|
|
28
|
-
'- **Discover available skills:** scan `.agents/skills/*/SKILL.md`',
|
|
29
|
-
'- **Refresh provider views:** `oat sync --scope all`',
|
|
30
|
-
'- **Update skills to latest versions:** `oat tools update`',
|
|
31
|
-
];
|
|
54
|
+
const lines = ['## Tool Packs', ''];
|
|
55
|
+
if (projectPacks.length > 0) {
|
|
56
|
+
lines.push(`- **Project skills directory:** \`.agents/skills/\` (${projectPacks.map(({ pack }) => pack).join(', ')} packs installed at project scope)`);
|
|
57
|
+
}
|
|
32
58
|
if (userPacks.length > 0) {
|
|
33
|
-
lines.push(`- **User
|
|
59
|
+
lines.push(`- **User skills directory:** \`~/.agents/skills/\` (${userPacks.map(({ pack }) => pack).join(', ')} packs installed at user scope)`);
|
|
60
|
+
}
|
|
61
|
+
if (hasOtherProjectSkills) {
|
|
62
|
+
lines.push('- **Other project skills:** `.agents/skills/` also holds repository skills that belong to no OAT pack; they are not OAT pack skills.');
|
|
34
63
|
}
|
|
64
|
+
const scanTargets = [
|
|
65
|
+
...(projectPacks.length > 0 || hasOtherProjectSkills
|
|
66
|
+
? ['`.agents/skills/*/SKILL.md`']
|
|
67
|
+
: []),
|
|
68
|
+
...(userPacks.length > 0 ? ['`~/.agents/skills/*/SKILL.md`'] : []),
|
|
69
|
+
];
|
|
70
|
+
if (scanTargets.length > 0) {
|
|
71
|
+
lines.push(`- **Discover available skills:** scan ${scanTargets.join(' and ')}`);
|
|
72
|
+
}
|
|
73
|
+
lines.push('- **Refresh provider views:** `oat sync --scope all`', '- **Update skills to latest versions:** `oat tools update`');
|
|
35
74
|
lines.push('', '### Installed Packs', '');
|
|
36
75
|
for (const { pack, scope } of packs) {
|
|
37
76
|
const suffix = scope === 'user'
|
|
@@ -46,6 +85,10 @@ export function buildToolPacksSectionBody(packs) {
|
|
|
46
85
|
}
|
|
47
86
|
return lines.join('\n');
|
|
48
87
|
}
|
|
88
|
+
/** The complete managed `OAT tools` block, markers included. */
|
|
89
|
+
export function renderToolPacksManagedBlock(packs, options = {}) {
|
|
90
|
+
return buildAgentsMdManagedBlock('tools', buildToolPacksSectionBody(packs, options));
|
|
91
|
+
}
|
|
49
92
|
export function parseProjectGuidanceFlags(args) {
|
|
50
93
|
const accepted = args.includes('--project-guidance');
|
|
51
94
|
const declined = args.includes('--no-project-guidance');
|
|
@@ -67,7 +110,7 @@ export function commandProjectGuidanceChoice(command) {
|
|
|
67
110
|
}
|
|
68
111
|
export function withProjectGuidanceOptions(command) {
|
|
69
112
|
if (!command.options.some(({ long }) => long === '--project-guidance')) {
|
|
70
|
-
command.option('--project-guidance', 'Create
|
|
113
|
+
command.option('--project-guidance', 'Create or append repository AGENTS.md tool guidance, or print a manual patch');
|
|
71
114
|
}
|
|
72
115
|
if (!command.options.some(({ long }) => long === '--no-project-guidance')) {
|
|
73
116
|
command.option('--no-project-guidance', 'Decline repository AGENTS.md tool guidance');
|
|
@@ -89,12 +132,12 @@ export async function planProjectGuidance(input) {
|
|
|
89
132
|
};
|
|
90
133
|
}
|
|
91
134
|
else {
|
|
92
|
-
const accepted = await input.confirmAction('Create
|
|
135
|
+
const accepted = await input.confirmAction('Create or append repository AGENTS.md tool guidance (a different existing block prints a manual patch)?', { interactive: input.interactive });
|
|
93
136
|
choice = accepted
|
|
94
137
|
? { choice: 'accepted', source: 'prompt' }
|
|
95
138
|
: { choice: 'declined', source: 'prompt' };
|
|
96
139
|
}
|
|
97
|
-
const body = buildToolPacksSectionBody(input.packs);
|
|
140
|
+
const body = buildToolPacksSectionBody(input.packs, input);
|
|
98
141
|
if (choice.choice === 'declined') {
|
|
99
142
|
return {
|
|
100
143
|
repoRoot: input.repoRoot,
|
|
@@ -115,7 +158,7 @@ export async function planProjectGuidance(input) {
|
|
|
115
158
|
sectionKey: 'tools',
|
|
116
159
|
body,
|
|
117
160
|
legacySectionAction: 'preserve',
|
|
118
|
-
reason: 'Project guidance was not requested. Re-run with --project-guidance to create an absent AGENTS.md or print a manual patch for
|
|
161
|
+
reason: 'Project guidance was not requested. Re-run with --project-guidance to create an absent AGENTS.md, append an absent guidance block to an existing one, or print a manual patch for a different existing block.',
|
|
119
162
|
choice,
|
|
120
163
|
};
|
|
121
164
|
}
|
|
@@ -138,7 +181,7 @@ export async function planProjectGuidance(input) {
|
|
|
138
181
|
sectionKey: 'tools',
|
|
139
182
|
body,
|
|
140
183
|
legacySectionAction: 'remove',
|
|
141
|
-
reason: 'Project guidance was accepted. An absent AGENTS.md may be created
|
|
184
|
+
reason: 'Project guidance was accepted. An absent AGENTS.md may be created and an absent guidance block appended; a different existing block requires a manual patch.',
|
|
142
185
|
choice,
|
|
143
186
|
};
|
|
144
187
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/commands/init/tools/workflows/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,aAAa,EACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EAIzB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAEL,KAAK,aAAa,EACnB,MAAM,iCAAiC,CAAC;AAQzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,KAAK,EAAY,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAGvE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAGL,mBAAmB,EAIpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAEL,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC3B,MAAM,qBAAqB,CAAC;AAM7B,UAAU,8BAA8B;IACtC,mBAAmB,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,cAAc,CAAC;IAChE,kBAAkB,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACrD,gBAAgB,EAAE,CAChB,KAAK,EAAE,qBAAqB,EAC5B,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,KACT,MAAM,CAAC;IACZ,iBAAiB,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IACzC,gBAAgB,EAAE,CAChB,OAAO,EAAE,uBAAuB,KAC7B,OAAO,CAAC,sBAAsB,CAAC,CAAC;IACrC,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AE,qBAAqB,EAC5B,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,KACT,MAAM,CAAC;IACZ,iBAAiB,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IACzC,gBAAgB,EAAE,CAChB,OAAO,EAAE,uBAAuB,KAC7B,OAAO,CAAC,sBAAsB,CAAC,CAAC;IACrC,aAAa,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,aAAa,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACzE,SAAS,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC9D,mBAAmB,EAAE,OAAO,mBAAmB,CAAC;IAChD,qBAAqB,EAAE,CACrB,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,uBAAuB,KAC9B,OAAO,CAAC,mBAAmB,CAAC,CAAC;CACnC;AAoTD,wBAAgB,+BAA+B,CAC7C,SAAS,GAAE,OAAO,CAAC,8BAA8B,CAAM,GACtD,OAAO,CAuBT"}
|
|
@@ -70,7 +70,11 @@ async function applyProjectGuidance(plan, dependencies) {
|
|
|
70
70
|
}
|
|
71
71
|
return {
|
|
72
72
|
...plan,
|
|
73
|
-
action: result.action === 'created'
|
|
73
|
+
action: result.action === 'created'
|
|
74
|
+
? 'create'
|
|
75
|
+
: result.action === 'appended'
|
|
76
|
+
? 'appended'
|
|
77
|
+
: 'no-change',
|
|
74
78
|
reason: `Accepted project guidance ${result.action}. Capability placement and PJM adoption were unchanged.`,
|
|
75
79
|
};
|
|
76
80
|
}
|
|
@@ -1,16 +1,40 @@
|
|
|
1
1
|
import type { Dirent, Stats } from 'node:fs';
|
|
2
2
|
import type { CommandContext, GlobalOptions } from '../../app/command-context.js';
|
|
3
|
-
|
|
4
|
-
export type InstructionSyncStrategy
|
|
5
|
-
|
|
3
|
+
import type { InstructionSyncStrategy } from '../../config/oat-config.js';
|
|
4
|
+
export { INSTRUCTION_SYNC_STRATEGIES, type InstructionSyncStrategy, } from '../../config/oat-config.js';
|
|
5
|
+
/**
|
|
6
|
+
* - `managed_shim`: under strategy `none`, a CLAUDE.md in the exact shape OAT
|
|
7
|
+
* writes (the `@AGENTS.md` pointer, a symlink to the sibling AGENTS.md, or a
|
|
8
|
+
* byte-identical copy). Drift: sync removes it.
|
|
9
|
+
* - `unmanaged`: under strategy `none`, a CLAUDE.md that is not an exact
|
|
10
|
+
* managed shape (hand-written, modified, a symlink elsewhere). Never
|
|
11
|
+
* removed, and not drift.
|
|
12
|
+
*/
|
|
13
|
+
export type InstructionStatus = 'ok' | 'missing' | 'content_mismatch' | 'stray' | 'managed_shim' | 'unmanaged';
|
|
14
|
+
export type ManagedShimShape = 'pointer' | 'symlink' | 'copy';
|
|
15
|
+
/**
|
|
16
|
+
* What the scan observed about a managed shim, so removal can fail closed if
|
|
17
|
+
* the file changed between planning and deletion. Internal to the sync apply
|
|
18
|
+
* path; never serialized into the JSON payload.
|
|
19
|
+
*/
|
|
20
|
+
export interface ManagedShimRecord {
|
|
21
|
+
shape: ManagedShimShape;
|
|
22
|
+
/** `lstat` identity of the CLAUDE.md itself (the link for a symlink). */
|
|
23
|
+
dev: number;
|
|
24
|
+
ino: number;
|
|
25
|
+
/** The raw `readlink` value, for the symlink shape only. */
|
|
26
|
+
linkTarget?: string;
|
|
27
|
+
}
|
|
6
28
|
export type InstructionsStatus = 'ok' | 'drift';
|
|
7
29
|
export interface InstructionEntry {
|
|
8
30
|
agentsPath: string | null;
|
|
9
31
|
claudePath: string;
|
|
10
32
|
status: InstructionStatus;
|
|
11
33
|
detail: string;
|
|
34
|
+
/** Present only for `managed_shim` entries. */
|
|
35
|
+
managedShim?: ManagedShimRecord;
|
|
12
36
|
}
|
|
13
|
-
export type InstructionActionType = 'create' | 'update' | 'skip';
|
|
37
|
+
export type InstructionActionType = 'create' | 'update' | 'remove' | 'skip';
|
|
14
38
|
export type InstructionActionResult = 'planned' | 'applied' | 'skipped';
|
|
15
39
|
export interface InstructionActionRecord {
|
|
16
40
|
type: InstructionActionType;
|
|
@@ -19,19 +43,69 @@ export interface InstructionActionRecord {
|
|
|
19
43
|
result: InstructionActionResult;
|
|
20
44
|
}
|
|
21
45
|
export type InstructionsMode = 'validate' | 'dry-run' | 'apply';
|
|
46
|
+
/**
|
|
47
|
+
* A finding that never changes the exit code by itself.
|
|
48
|
+
*
|
|
49
|
+
* `claude_md_hides_agents_md`: under strategy `none`, a `CLAUDE.md`,
|
|
50
|
+
* `.claude/CLAUDE.md`, or `CLAUDE.local.md` that makes Claude Code's default
|
|
51
|
+
* `agents-md` mode ignore every AGENTS.md in the project while it exists.
|
|
52
|
+
*/
|
|
53
|
+
export interface ClaudeMdHidesAgentsMdWarning {
|
|
54
|
+
code: 'claude_md_hides_agents_md';
|
|
55
|
+
/** Repository-relative POSIX path. */
|
|
56
|
+
path: string;
|
|
57
|
+
/**
|
|
58
|
+
* Repository-relative `AGENTS.md` paths whose symlink chain reaches `path`.
|
|
59
|
+
* When non-empty, removing `path` would break them: replace each link with
|
|
60
|
+
* the file's content first. Always present, possibly empty.
|
|
61
|
+
*/
|
|
62
|
+
linkedBy: string[];
|
|
63
|
+
message: string;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* `claude_md_blocks_shim_removal`: under strategy `none`, removal is all or
|
|
67
|
+
* nothing. While any `CLAUDE.md`, `.claude/CLAUDE.md`, or `CLAUDE.local.md`
|
|
68
|
+
* is not an exact OAT shim, sync removes no CLAUDE.md at all; this finding
|
|
69
|
+
* names those files and the removals held back. Sync reports each held-back
|
|
70
|
+
* removal as a skipped action, which is what sets its exit code.
|
|
71
|
+
*/
|
|
72
|
+
export interface ClaudeMdBlocksShimRemovalWarning {
|
|
73
|
+
code: 'claude_md_blocks_shim_removal';
|
|
74
|
+
/** Repository-relative POSIX paths of the files with their own content. */
|
|
75
|
+
paths: string[];
|
|
76
|
+
/** Repository-relative POSIX paths of the CLAUDE.md files kept because of them. */
|
|
77
|
+
wouldRemove: string[];
|
|
78
|
+
/**
|
|
79
|
+
* For each path in `paths`, the repository-relative `AGENTS.md` paths whose
|
|
80
|
+
* symlink chain reaches it. A non-empty list means that file holds the only
|
|
81
|
+
* copy of those instructions: replace each link with its content before
|
|
82
|
+
* removing it, never remove it plainly. Every path in `paths` has a key.
|
|
83
|
+
*/
|
|
84
|
+
linkedBy: Record<string, string[]>;
|
|
85
|
+
message: string;
|
|
86
|
+
}
|
|
87
|
+
export type InstructionsWarning = ClaudeMdHidesAgentsMdWarning | ClaudeMdBlocksShimRemovalWarning;
|
|
22
88
|
export interface InstructionsSummary {
|
|
23
89
|
scanned: number;
|
|
24
90
|
ok: number;
|
|
25
91
|
missing: number;
|
|
26
92
|
contentMismatch: number;
|
|
27
93
|
stray: number;
|
|
94
|
+
managedShim: number;
|
|
95
|
+
unmanaged: number;
|
|
28
96
|
created: number;
|
|
29
97
|
updated: number;
|
|
98
|
+
removed: number;
|
|
30
99
|
skipped: number;
|
|
31
100
|
}
|
|
32
101
|
export interface InstructionsJsonPayload {
|
|
33
102
|
mode: InstructionsMode;
|
|
34
103
|
status: InstructionsStatus;
|
|
104
|
+
/**
|
|
105
|
+
* The strategy this run applied or checked: `--strategy` when given, else
|
|
106
|
+
* `instructions.claude.shims`, else the built-in default.
|
|
107
|
+
*/
|
|
108
|
+
strategy: InstructionSyncStrategy;
|
|
35
109
|
summary: InstructionsSummary;
|
|
36
110
|
entries: InstructionEntry[];
|
|
37
111
|
actions: InstructionActionRecord[];
|
|
@@ -71,6 +145,11 @@ export interface InstructionsJsonPayload {
|
|
|
71
145
|
* exclusion that silently does nothing. Omitted when empty.
|
|
72
146
|
*/
|
|
73
147
|
exclusionWarnings?: string[];
|
|
148
|
+
/**
|
|
149
|
+
* Structured warnings, the same text written to stderr in human mode.
|
|
150
|
+
* Omitted when empty, so a clean repository's payload shape is unchanged.
|
|
151
|
+
*/
|
|
152
|
+
warnings?: InstructionsWarning[];
|
|
74
153
|
}
|
|
75
154
|
/**
|
|
76
155
|
* The resolved exclusion set, split so that intent and effect cannot be
|
|
@@ -104,12 +183,30 @@ export interface InstructionsScanDependencies {
|
|
|
104
183
|
lstat: (path: string) => Promise<Stats>;
|
|
105
184
|
realpath: (path: string) => Promise<string>;
|
|
106
185
|
readFile: (path: string, encoding: 'utf8') => Promise<string>;
|
|
186
|
+
/** Raw bytes, for the byte-exact managed-shim comparisons. */
|
|
187
|
+
readFileBytes: (path: string) => Promise<Buffer>;
|
|
107
188
|
readlink: (path: string) => Promise<string>;
|
|
108
189
|
stat: (path: string) => Promise<Stats>;
|
|
109
190
|
}
|
|
110
191
|
export interface InstructionsValidateCommandDependencies {
|
|
111
192
|
buildCommandContext: (options: GlobalOptions) => CommandContext;
|
|
112
193
|
resolveProjectRoot: (cwd: string) => Promise<string>;
|
|
194
|
+
/**
|
|
195
|
+
* The repository's configured `instructions.claude.shims`, or
|
|
196
|
+
* undefined when the key is absent. Sync inherits it from this interface so
|
|
197
|
+
* both commands resolve the strategy through the same config read.
|
|
198
|
+
*/
|
|
199
|
+
readConfiguredInstructionSyncStrategy: (repoRoot: string) => Promise<InstructionSyncStrategy | undefined>;
|
|
200
|
+
/**
|
|
201
|
+
* Every `CLAUDE.md` and `CLAUDE.local.md` in the repository (absolute
|
|
202
|
+
* paths), from a read-only walk that ignores the mutation exclusions, each
|
|
203
|
+
* classified as an exact OAT shim or not.
|
|
204
|
+
*/
|
|
205
|
+
findLeftoverClaudeFiles: (repoRoot: string) => Promise<Array<{
|
|
206
|
+
path: string;
|
|
207
|
+
linkedBy: string[];
|
|
208
|
+
exactShim: boolean;
|
|
209
|
+
}>>;
|
|
113
210
|
/**
|
|
114
211
|
* The single exclusion path both commands resolve through. Sync inherits it
|
|
115
212
|
* from this interface rather than resolving its own, so validate can never
|
|
@@ -121,6 +218,10 @@ export interface InstructionsValidateCommandDependencies {
|
|
|
121
218
|
export interface InstructionsSyncCommandDependencies extends InstructionsValidateCommandDependencies {
|
|
122
219
|
lstat: (path: string) => Promise<Stats>;
|
|
123
220
|
readFile: (path: string, encoding: 'utf8') => Promise<string>;
|
|
221
|
+
/** Raw bytes, for the apply-time managed-shim re-verification. */
|
|
222
|
+
readFileBytes: (path: string) => Promise<Buffer>;
|
|
223
|
+
readlink: (path: string) => Promise<string>;
|
|
224
|
+
realpath: (path: string) => Promise<string>;
|
|
124
225
|
removeFile: (path: string) => Promise<void>;
|
|
125
226
|
symlinkFile: (target: string, path: string) => Promise<void>;
|
|
126
227
|
writeFile: (path: string, content: string, encoding: 'utf8') => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instructions.types.d.ts","sourceRoot":"","sources":["../../../src/commands/instructions/instructions.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAE7C,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"instructions.types.d.ts","sourceRoot":"","sources":["../../../src/commands/instructions/instructions.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAE7C,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAKlE,OAAO,EACL,2BAA2B,EAC3B,KAAK,uBAAuB,GAC7B,MAAM,oBAAoB,CAAC;AAE5B;;;;;;;GAOG;AACH,MAAM,MAAM,iBAAiB,GACzB,IAAI,GACJ,SAAS,GACT,kBAAkB,GAClB,OAAO,GACP,cAAc,GACd,WAAW,CAAC;AAEhB,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,CAAC;AAE9D;;;;GAIG;AACH,MAAM,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}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
];
|
|
1
|
+
// One list shared with the `instructions.claude.shims` config
|
|
2
|
+
// normalizer and `oat config set`, so the commands can never accept a value
|
|
3
|
+
// the config rejects or the reverse.
|
|
4
|
+
export { INSTRUCTION_SYNC_STRATEGIES, } from '../../config/oat-config.js';
|
|
@@ -1,15 +1,83 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { DEFAULT_INSTRUCTION_SYNC_STRATEGY } from '../../config/oat-config.js';
|
|
2
|
+
import type { ClaudeMdBlocksShimRemovalWarning, ClaudeMdHidesAgentsMdWarning, InstructionSyncStrategy, InstructionActionRecord, InstructionEntry, InstructionsJsonPayload, InstructionsMode, InstructionPointerExclusions, InstructionsScanOptions, InstructionsScanDependencies, InstructionsSummary, InstructionsWarning, ManagedShimRecord } from './instructions.types.js';
|
|
2
3
|
export declare const EXPECTED_CLAUDE_CONTENT = "@AGENTS.md\n";
|
|
3
|
-
export
|
|
4
|
+
export { DEFAULT_INSTRUCTION_SYNC_STRATEGY };
|
|
4
5
|
interface BuildInstructionsPayloadArgs {
|
|
5
6
|
mode: InstructionsMode;
|
|
7
|
+
strategy: InstructionSyncStrategy;
|
|
8
|
+
warnings?: InstructionsWarning[];
|
|
6
9
|
entries: InstructionEntry[];
|
|
7
10
|
actions: InstructionActionRecord[];
|
|
8
11
|
excludedPaths?: string[];
|
|
9
12
|
effectiveExcludedPaths?: string[];
|
|
10
13
|
exclusionWarnings?: string[];
|
|
11
14
|
}
|
|
12
|
-
|
|
15
|
+
/** The filesystem reads managed-shim classification needs. */
|
|
16
|
+
export interface ManagedShimInspectionDependencies {
|
|
17
|
+
lstat: InstructionsScanDependencies['lstat'];
|
|
18
|
+
readlink: InstructionsScanDependencies['readlink'];
|
|
19
|
+
readFileBytes: InstructionsScanDependencies['readFileBytes'];
|
|
20
|
+
realpath: InstructionsScanDependencies['realpath'];
|
|
21
|
+
}
|
|
22
|
+
export type ManagedShimInspection = {
|
|
23
|
+
kind: 'managed';
|
|
24
|
+
record: ManagedShimRecord;
|
|
25
|
+
} | {
|
|
26
|
+
kind: 'absent';
|
|
27
|
+
} | {
|
|
28
|
+
kind: 'unmanaged';
|
|
29
|
+
detail: string;
|
|
30
|
+
} | {
|
|
31
|
+
kind: 'unreadable';
|
|
32
|
+
detail: string;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Classify one CLAUDE.md against the exact shapes OAT writes, beside its
|
|
36
|
+
* sibling AGENTS.md. This is the single definition of "OAT-managed" that both
|
|
37
|
+
* planning (the scan) and apply-time re-verification use, so the two can never
|
|
38
|
+
* disagree about what may be deleted.
|
|
39
|
+
*
|
|
40
|
+
* Anything that is not provably one of the three shapes is `unmanaged`, which
|
|
41
|
+
* is never deleted: a CLAUDE.md not named exactly `CLAUDE.md`, one inside a
|
|
42
|
+
* `.claude` directory, a symlink whose target is not the sibling AGENTS.md,
|
|
43
|
+
* and any regular file whose bytes are not exactly a pointer or an exact copy.
|
|
44
|
+
*/
|
|
45
|
+
export declare function inspectManagedShim(claudePath: string, agentsPath: string, dependencies: ManagedShimInspectionDependencies): Promise<ManagedShimInspection>;
|
|
46
|
+
/** The filesystem reads link-chain resolution needs. */
|
|
47
|
+
export interface LinkResolutionDependencies {
|
|
48
|
+
lstat: InstructionsScanDependencies['lstat'];
|
|
49
|
+
readlink: InstructionsScanDependencies['readlink'];
|
|
50
|
+
realpath: InstructionsScanDependencies['realpath'];
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The candidates whose symlink chain passes through `targetPath`: removing
|
|
54
|
+
* `targetPath` would leave each of them dangling. Every hop is followed, so a
|
|
55
|
+
* link to a link to the target counts, and a link to the target that is
|
|
56
|
+
* itself a symlink counts too. Regular files and hard links never dangle, so
|
|
57
|
+
* they are never reported.
|
|
58
|
+
*/
|
|
59
|
+
export declare function findLinksThrough(targetPath: string, candidates: readonly string[], dependencies: LinkResolutionDependencies): Promise<string[]>;
|
|
60
|
+
/**
|
|
61
|
+
* Re-verify, immediately before deletion, that a CLAUDE.md planned for removal
|
|
62
|
+
* is still the exact managed shim the scan recorded: same `lstat` identity
|
|
63
|
+
* (device and inode, so a replaced file is caught even with identical bytes),
|
|
64
|
+
* same shape, same symlink target, and still an exact managed shape now.
|
|
65
|
+
*
|
|
66
|
+
* Returns null when removal may proceed, or the reason it must not.
|
|
67
|
+
*/
|
|
68
|
+
export declare function verifyManagedShimUnchanged(claudePath: string, agentsPath: string, planned: ManagedShimRecord, dependencies: ManagedShimInspectionDependencies): Promise<string | null>;
|
|
69
|
+
/**
|
|
70
|
+
* The effective strategy for one run: the `--strategy` flag, then the
|
|
71
|
+
* repository's `instructions.claude.shims`, then the built-in
|
|
72
|
+
* default. The flag only ever overrides a single run; it never rewrites config.
|
|
73
|
+
*/
|
|
74
|
+
export declare function resolveInstructionSyncStrategy(flagStrategy?: InstructionSyncStrategy, configuredStrategy?: InstructionSyncStrategy): InstructionSyncStrategy;
|
|
75
|
+
/**
|
|
76
|
+
* Read `instructions.claude.shims` from the shared config. A
|
|
77
|
+
* malformed value fails closed in the config normalizer rather than reading as
|
|
78
|
+
* unset, so a typo can never silently select the built-in default.
|
|
79
|
+
*/
|
|
80
|
+
export declare function readConfiguredInstructionSyncStrategy(repoRoot: string): Promise<InstructionSyncStrategy | undefined>;
|
|
13
81
|
/**
|
|
14
82
|
* Canonicalize repo-relative exclusion entries into the exact form the scan
|
|
15
83
|
* compares against: POSIX separators, collapsed `.` and `..` segments and
|
|
@@ -33,7 +101,7 @@ export declare function normalizeExcludedPaths(excludedPaths?: readonly string[]
|
|
|
33
101
|
/**
|
|
34
102
|
* The directories `oat instructions sync` and `oat instructions validate` skip:
|
|
35
103
|
* the derived documentation content root first, then the explicit
|
|
36
|
-
* `
|
|
104
|
+
* `instructions.claude.excludes` opt-outs.
|
|
37
105
|
*
|
|
38
106
|
* Both commands resolve exclusions through this one function. That is the
|
|
39
107
|
* property that matters: if they computed exclusions separately, validate
|
|
@@ -57,8 +125,95 @@ export declare function normalizeExcludedPaths(excludedPaths?: readonly string[]
|
|
|
57
125
|
*/
|
|
58
126
|
export declare function resolveInstructionPointerExcludes(repoRoot: string, overrides?: Partial<InstructionsScanDependencies>): Promise<InstructionPointerExclusions>;
|
|
59
127
|
export declare function scanInstructionFiles(repoRoot: string, options?: InstructionsScanOptions, overrides?: Partial<InstructionsScanDependencies>): Promise<InstructionEntry[]>;
|
|
128
|
+
/** A leftover file and the `AGENTS.md` links that pass through it. */
|
|
129
|
+
export interface LeftoverClaudeFile {
|
|
130
|
+
path: string;
|
|
131
|
+
/** Absolute paths of every `AGENTS.md` whose symlink chain reaches `path`. */
|
|
132
|
+
linkedBy: string[];
|
|
133
|
+
/**
|
|
134
|
+
* Whether the file is an exact OAT shim of its sibling AGENTS.md (pointer,
|
|
135
|
+
* sibling symlink, or identical copy), judged by `inspectManagedShim`. Any
|
|
136
|
+
* other file -- `CLAUDE.local.md`, `.claude/CLAUDE.md`, a hand-written or
|
|
137
|
+
* modified `CLAUDE.md`, one without a sibling AGENTS.md, or one that cannot
|
|
138
|
+
* be read -- has content of its own.
|
|
139
|
+
*/
|
|
140
|
+
exactShim: boolean;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Every `CLAUDE.md` (including `.claude/CLAUDE.md`) and `CLAUDE.local.md` in
|
|
144
|
+
* the repository (exact case), sorted, as absolute paths, each with the
|
|
145
|
+
* `AGENTS.md` files that link to it.
|
|
146
|
+
*
|
|
147
|
+
* A separate, read-only walk on purpose. The instruction scan skips the
|
|
148
|
+
* documentation content root and `instructions.claude.excludes`,
|
|
149
|
+
* but those only limit what OAT may change: Claude Code's `agents-md` plugin
|
|
150
|
+
* stands down whichever directory the file is in. Only `.git`, `node_modules`,
|
|
151
|
+
* the root `.worktrees`, and nested git checkouts (separate repositories) are
|
|
152
|
+
* skipped, and symlinked directories are not followed. A symlink named like
|
|
153
|
+
* an instruction file counts, broken or not. Each directory entry is read
|
|
154
|
+
* once, so one file is never reported twice, even on a case-insensitive
|
|
155
|
+
* filesystem.
|
|
156
|
+
*/
|
|
157
|
+
export declare function findLeftoverClaudeFiles(repoRoot: string, overrides?: Partial<Pick<InstructionsScanDependencies, 'readdir' | 'lstat' | 'readlink' | 'realpath' | 'readFileBytes'>>): Promise<LeftoverClaudeFile[]>;
|
|
158
|
+
/**
|
|
159
|
+
* Where the docs explain why any CLAUDE.md makes Claude Code ignore AGENTS.md.
|
|
160
|
+
* Absolute, because the message is read in terminals and JSON consumers that
|
|
161
|
+
* cannot resolve a repository-relative docs path.
|
|
162
|
+
*/
|
|
163
|
+
export declare const CLAUDE_CODE_AGENTS_MD_DOCS_URL = "https://github.com/voxmedia/open-agent-toolkit/blob/main/apps/oat-docs/docs/provider-sync/instruction-sync.md#claude-code-and-agentsmd";
|
|
164
|
+
/**
|
|
165
|
+
* Under strategy `none`, removal is all or nothing: the leftover files with
|
|
166
|
+
* content of their own (anything but an exact OAT shim) that hold back every
|
|
167
|
+
* CLAUDE.md removal while they exist.
|
|
168
|
+
*
|
|
169
|
+
* A stray the scan will adopt (a lone `CLAUDE.md` with no sibling AGENTS.md)
|
|
170
|
+
* never blocks: its content moves into a new AGENTS.md, so it is not left
|
|
171
|
+
* behind. Every other file counts wherever it is, including excluded and
|
|
172
|
+
* documentation trees, because Claude Code's walk does not honor OAT's
|
|
173
|
+
* exclusions. An unreadable file counts too: blocking is the safe direction.
|
|
174
|
+
*/
|
|
175
|
+
export declare function findShimRemovalBlockers(entries: readonly InstructionEntry[], leftovers: readonly LeftoverClaudeFile[]): ShimRemovalBlocker[];
|
|
176
|
+
/** A file that blocks removal, and the `AGENTS.md` links that reach it. */
|
|
177
|
+
export type ShimRemovalBlocker = Pick<LeftoverClaudeFile, 'path' | 'linkedBy'>;
|
|
178
|
+
/**
|
|
179
|
+
* Under a blocked removal, the leftover warnings minus the files the block
|
|
180
|
+
* holds back: the block finding already names them, and advice to remove
|
|
181
|
+
* one by hand would recreate the mix the block exists to prevent.
|
|
182
|
+
*/
|
|
183
|
+
export declare function omitHeldBackLeftovers<T extends {
|
|
184
|
+
path: string;
|
|
185
|
+
}>(leftovers: readonly T[], heldBack: readonly string[]): T[];
|
|
186
|
+
/** The CLAUDE.md files strategy `none` removes: managed shims and adopted strays. */
|
|
187
|
+
export declare function listShimRemovals(entries: readonly InstructionEntry[]): string[];
|
|
188
|
+
/** The skip reason sync records for each removal the block holds back. */
|
|
189
|
+
export declare function describeShimRemovalBlock(repoRoot: string, blockers: readonly ShimRemovalBlocker[]): string;
|
|
190
|
+
/**
|
|
191
|
+
* The single finding for a blocked removal: which shims the configuration
|
|
192
|
+
* would remove, that none were removed and which files are why, why any
|
|
193
|
+
* CLAUDE.md matters, and what to do next.
|
|
194
|
+
*/
|
|
195
|
+
export declare function buildShimRemovalBlockWarning(repoRoot: string, blockers: readonly ShimRemovalBlocker[], wouldRemove: readonly string[], mode: InstructionsMode): ClaudeMdBlocksShimRemovalWarning;
|
|
196
|
+
/**
|
|
197
|
+
* Restate each managed shim's detail while the block holds: sync will not
|
|
198
|
+
* remove it, so "sync removes it" would be false.
|
|
199
|
+
*/
|
|
200
|
+
export declare function markBlockedShimEntries(entries: readonly InstructionEntry[]): InstructionEntry[];
|
|
201
|
+
/**
|
|
202
|
+
* One warning per leftover file, naming exactly two ways out: remove the
|
|
203
|
+
* file, or opt back into shims and let sync add them everywhere.
|
|
204
|
+
*
|
|
205
|
+
* When an `AGENTS.md` links to the file, removing it would break that link
|
|
206
|
+
* and lose the only copy of the instructions, so the first option becomes
|
|
207
|
+
* "replace the link with the file's content, then remove the file", and
|
|
208
|
+
* `linkedBy` names the links.
|
|
209
|
+
*
|
|
210
|
+
* Claude Code's plugin stands down when such a file sits in the session's
|
|
211
|
+
* working directory or any directory above it up to the project root, so a
|
|
212
|
+
* root file affects every session and a nested one only sessions started in
|
|
213
|
+
* its directory or below.
|
|
214
|
+
*/
|
|
215
|
+
export declare function buildLeftoverClaudeWarnings(repoRoot: string, leftovers: readonly Pick<LeftoverClaudeFile, 'path' | 'linkedBy'>[]): ClaudeMdHidesAgentsMdWarning[];
|
|
60
216
|
export declare function buildInstructionsSummary(entries: InstructionEntry[], actions: InstructionActionRecord[]): InstructionsSummary;
|
|
61
|
-
export declare function buildInstructionsPayload({ mode, entries, actions, excludedPaths, effectiveExcludedPaths, exclusionWarnings, }: BuildInstructionsPayloadArgs): InstructionsJsonPayload;
|
|
217
|
+
export declare function buildInstructionsPayload({ mode, strategy, warnings, entries, actions, excludedPaths, effectiveExcludedPaths, exclusionWarnings, }: BuildInstructionsPayloadArgs): InstructionsJsonPayload;
|
|
62
218
|
export declare function formatInstructionsReport(payload: InstructionsJsonPayload, repoRoot?: string): string;
|
|
63
|
-
export {};
|
|
64
219
|
//# sourceMappingURL=instructions.utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instructions.utils.d.ts","sourceRoot":"","sources":["../../../src/commands/instructions/instructions.utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"instructions.utils.d.ts","sourceRoot":"","sources":["../../../src/commands/instructions/instructions.utils.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,iCAAiC,EAGlC,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EACV,gCAAgC,EAChC,4BAA4B,EAC5B,uBAAuB,EACvB,uBAAuB,EACvB,gBAAgB,EAChB,uBAAuB,EACvB,gBAAgB,EAChB,4BAA4B,EAC5B,uBAAuB,EACvB,4BAA4B,EAE5B,mBAAmB,EACnB,mBAAmB,EAEnB,iBAAiB,EAClB,MAAM,sBAAsB,CAAC;AAE9B,eAAO,MAAM,uBAAuB,iBAAiB,CAAC;AACtD,OAAO,EAAE,iCAAiC,EAAE,CAAC;AAc7C,UAAU,4BAA4B;IACpC,IAAI,EAAE,gBAAgB,CAAC;IACvB,QAAQ,EAAE,uBAAuB,CAAC;IAClC,QAAQ,CAAC,EA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