@cat-kit/agent-context 1.0.6 → 1.1.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.
Files changed (75) hide show
  1. package/README.md +58 -61
  2. package/dist/cli.js +1 -1
  3. package/dist/cli.js.map +1 -1
  4. package/dist/commands/install.js +2 -0
  5. package/dist/commands/install.js.map +1 -0
  6. package/dist/commands/printer.js +4 -0
  7. package/dist/commands/printer.js.map +1 -0
  8. package/dist/commands/sync.js +2 -0
  9. package/dist/commands/sync.js.map +1 -0
  10. package/dist/content/actions.js +172 -0
  11. package/dist/content/actions.js.map +1 -0
  12. package/dist/content/index.js +47 -0
  13. package/dist/content/index.js.map +1 -0
  14. package/dist/runner.js +3 -0
  15. package/dist/runner.js.map +1 -0
  16. package/dist/stats.html +1 -1
  17. package/dist/tools.js +2 -0
  18. package/dist/tools.js.map +1 -0
  19. package/package.json +1 -1
  20. package/src/cli.ts +14 -14
  21. package/src/commands/install.ts +56 -0
  22. package/src/commands/{shared.ts → printer.ts} +2 -3
  23. package/src/commands/sync.ts +40 -0
  24. package/src/content/actions.ts +232 -0
  25. package/src/content/index.ts +93 -0
  26. package/src/runner.ts +113 -0
  27. package/src/tools.ts +114 -0
  28. package/src/types.ts +42 -0
  29. package/dist/adapters/tool-targets.js +0 -2
  30. package/dist/adapters/tool-targets.js.map +0 -1
  31. package/dist/commands/setup.js +0 -2
  32. package/dist/commands/setup.js.map +0 -1
  33. package/dist/commands/shared.js +0 -4
  34. package/dist/commands/shared.js.map +0 -1
  35. package/dist/commands/update.js +0 -2
  36. package/dist/commands/update.js.map +0 -1
  37. package/dist/domain/workflow-content.js +0 -2
  38. package/dist/domain/workflow-content.js.map +0 -1
  39. package/dist/domain/workflow-context.js +0 -2
  40. package/dist/domain/workflow-context.js.map +0 -1
  41. package/dist/domain/workflow-templates/done.js +0 -23
  42. package/dist/domain/workflow-templates/done.js.map +0 -1
  43. package/dist/domain/workflow-templates/implement.js +0 -35
  44. package/dist/domain/workflow-templates/implement.js.map +0 -1
  45. package/dist/domain/workflow-templates/init.js +0 -37
  46. package/dist/domain/workflow-templates/init.js.map +0 -1
  47. package/dist/domain/workflow-templates/patch.js +0 -41
  48. package/dist/domain/workflow-templates/patch.js.map +0 -1
  49. package/dist/domain/workflow-templates/plan.js +0 -58
  50. package/dist/domain/workflow-templates/plan.js.map +0 -1
  51. package/dist/domain/workflow-templates/replan.js +0 -31
  52. package/dist/domain/workflow-templates/replan.js.map +0 -1
  53. package/dist/generators/workflow.js +0 -2
  54. package/dist/generators/workflow.js.map +0 -1
  55. package/dist/runtime/execute.js +0 -2
  56. package/dist/runtime/execute.js.map +0 -1
  57. package/dist/shared/fs.js +0 -3
  58. package/dist/shared/fs.js.map +0 -1
  59. package/src/adapters/tool-targets.ts +0 -157
  60. package/src/commands/setup.ts +0 -64
  61. package/src/commands/update.ts +0 -46
  62. package/src/domain/types.ts +0 -50
  63. package/src/domain/workflow-content.ts +0 -25
  64. package/src/domain/workflow-context.ts +0 -48
  65. package/src/domain/workflow-templates/done.ts +0 -28
  66. package/src/domain/workflow-templates/implement.ts +0 -41
  67. package/src/domain/workflow-templates/index.ts +0 -7
  68. package/src/domain/workflow-templates/init.ts +0 -42
  69. package/src/domain/workflow-templates/patch.ts +0 -47
  70. package/src/domain/workflow-templates/plan.ts +0 -70
  71. package/src/domain/workflow-templates/replan.ts +0 -36
  72. package/src/generators/workflow.ts +0 -25
  73. package/src/runtime/execute.ts +0 -45
  74. package/src/shared/fs.ts +0 -66
  75. package/src/shared/paths.ts +0 -9
@@ -1,25 +0,0 @@
1
- import { resolveWorkflowPaths } from '../adapters/tool-targets'
2
- import type { FileMutation, ToolTarget, WorkflowCommandName } from '../domain/types'
3
- import { renderWorkflowArtifacts } from '../domain/workflow-content'
4
-
5
- const COMMAND_ORDER: WorkflowCommandName[] = [
6
- 'init',
7
- 'plan',
8
- 'replan',
9
- 'implement',
10
- 'patch',
11
- 'done'
12
- ]
13
-
14
- export function renderWorkflowMutations(target: ToolTarget, cwd: string): FileMutation[] {
15
- const artifacts = renderWorkflowArtifacts(target)
16
- const paths = resolveWorkflowPaths(target, cwd)
17
-
18
- const mutations: FileMutation[] = []
19
-
20
- for (const command of COMMAND_ORDER) {
21
- mutations.push({ path: paths.commandFile(command), body: artifacts.commandFiles[command] })
22
- }
23
-
24
- return mutations
25
- }
@@ -1,45 +0,0 @@
1
- import { resolveToolTargets } from '../adapters/tool-targets'
2
- import type { FileMutation, RunOptions, RunResult, ToolId } from '../domain/types'
3
- import { renderWorkflowMutations } from '../generators/workflow'
4
- import { applyManagedMutations } from '../shared/fs'
5
-
6
- export async function runSetup(options: RunOptions = {}): Promise<RunResult> {
7
- return runInMode('setup', options)
8
- }
9
-
10
- export async function runUpdate(options: RunOptions = {}): Promise<RunResult> {
11
- return runInMode('update', options)
12
- }
13
-
14
- async function runInMode(mode: 'setup' | 'update', options: RunOptions): Promise<RunResult> {
15
- const cwd = options.cwd ?? process.cwd()
16
- const toolIds = normalizeTools(options.tools)
17
- const targets = resolveToolTargets(toolIds)
18
-
19
- const mutations: FileMutation[] = targets.flatMap(target => renderWorkflowMutations(target, cwd))
20
-
21
- const check = options.check ?? false
22
- const result = await applyManagedMutations(mutations, check)
23
-
24
- return {
25
- ...result,
26
- mode,
27
- check
28
- }
29
- }
30
-
31
- function normalizeTools(tools?: ToolId[]): ToolId[] | undefined {
32
- if (!tools || tools.length === 0) {
33
- return undefined
34
- }
35
-
36
- const uniqueTools: ToolId[] = []
37
-
38
- for (const tool of tools) {
39
- if (!uniqueTools.includes(tool)) {
40
- uniqueTools.push(tool)
41
- }
42
- }
43
-
44
- return uniqueTools
45
- }
package/src/shared/fs.ts DELETED
@@ -1,66 +0,0 @@
1
- import { dirname } from 'node:path'
2
- import { existsSync } from 'node:fs'
3
- import { mkdir, readFile, writeFile } from 'node:fs/promises'
4
-
5
- import type { ApplyMutationResult, FileMutation } from '../domain/types'
6
-
7
- export async function applyManagedMutations(
8
- mutations: FileMutation[],
9
- check: boolean
10
- ): Promise<ApplyMutationResult> {
11
- const result: ApplyMutationResult = {
12
- created: [],
13
- updated: [],
14
- unchanged: [],
15
- changed: []
16
- }
17
-
18
- for (const mutation of mutations) {
19
- const fileExists = existsSync(mutation.path)
20
- const nextContent = await resolveNextContent(mutation, fileExists)
21
-
22
- if (!nextContent.changed) {
23
- result.unchanged.push(mutation.path)
24
- continue
25
- }
26
-
27
- if (!check) {
28
- await mkdir(dirname(mutation.path), { recursive: true })
29
- await writeFile(mutation.path, nextContent.content, 'utf-8')
30
- }
31
-
32
- result.changed.push(mutation.path)
33
-
34
- if (fileExists) {
35
- result.updated.push(mutation.path)
36
- } else {
37
- result.created.push(mutation.path)
38
- }
39
- }
40
-
41
- return result
42
- }
43
-
44
- async function resolveNextContent(
45
- mutation: FileMutation,
46
- fileExists: boolean
47
- ): Promise<{ content: string; changed: boolean }> {
48
- const nextContent = normalizeTrailingNewline(mutation.body)
49
-
50
- if (!fileExists) {
51
- return {
52
- content: nextContent,
53
- changed: true
54
- }
55
- }
56
-
57
- const currentContent = await readFile(mutation.path, 'utf-8')
58
- return {
59
- content: nextContent,
60
- changed: currentContent !== nextContent
61
- }
62
- }
63
-
64
- function normalizeTrailingNewline(content: string): string {
65
- return content.endsWith('\n') ? content : `${content}\n`
66
- }
@@ -1,9 +0,0 @@
1
- import { dirname, resolve } from 'node:path'
2
- import { fileURLToPath } from 'node:url'
3
-
4
- const __filename = fileURLToPath(import.meta.url)
5
- const __dirname = dirname(__filename)
6
-
7
- export function getPackageRootDir(): string {
8
- return resolve(__dirname, '../..')
9
- }