@straiffi/archon 1.2.2 → 1.2.4

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.
@@ -5,10 +5,10 @@
5
5
  <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>Archon</title>
8
- <script type="module" crossorigin src="/assets/index-BGi8klde.js"></script>
8
+ <script type="module" crossorigin src="/assets/index-DfuQewLh.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-BYbx6iT9.js">
10
10
  <link rel="modulepreload" crossorigin href="/assets/badge-Bpry9xkS.js">
11
- <link rel="stylesheet" crossorigin href="/assets/index-Bw66dtZG.css">
11
+ <link rel="stylesheet" crossorigin href="/assets/index-CRirnlH7.css">
12
12
  </head>
13
13
  <body>
14
14
  <div id="root"></div>
@@ -31,6 +31,7 @@ import { acceptProjectMemorySuggestion, applyProjectMemorySuggestionToDecision,
31
31
  import { selectRelevantProjectMemory } from './lib/projectMemoryPrompt.js';
32
32
  import { getProjectContextResponse, startProjectContextScan } from './lib/projectMemoryScan.js';
33
33
  import { getProjectFileSuggestions } from './lib/projectFileSuggestions.js';
34
+ import { updateProjectTargetSelection } from './lib/projectTargets.js';
34
35
  import { exportProjectMemoryArchive, importProjectMemoryArchive } from './lib/projectMemoryTransfer.js';
35
36
  import { buildReviewFindingsResponse, computeDiffSignature, getLatestReviewRunForContext } from './lib/reviewFindings.js';
36
37
  import { getDiscoveredSkills, normalizeSkillNames } from './lib/skills.js';
@@ -3956,56 +3957,11 @@ app.get('/projects/:id/branches', (req, res) => {
3956
3957
  }
3957
3958
  });
3958
3959
  app.post('/projects/:id/target', (req, res) => {
3959
- const project = getProjectById(req.params.id);
3960
- if (!project) {
3961
- return res.status(404).json({ error: 'Not found' });
3962
- }
3963
- const kind = req.body?.kind;
3964
- if (kind !== 'repo_root' && kind !== 'bundle') {
3965
- return res.status(400).json({ error: 'kind must be repo_root or bundle' });
3966
- }
3967
- try {
3968
- if (kind === 'bundle') {
3969
- const bundleId = typeof req.body?.bundle_id === 'string' ? req.body.bundle_id.trim() : '';
3970
- if (!bundleId) {
3971
- return res.status(400).json({ error: 'bundle_id is required for bundle targets' });
3972
- }
3973
- const bundle = getBundle(bundleId, project.id);
3974
- if (!bundle) {
3975
- return res.status(404).json({ error: 'Bundle not found' });
3976
- }
3977
- if (isProjectRootBundle(bundle)) {
3978
- return res.status(409).json({ error: 'Use the repo_root target instead of the project-root bundle' });
3979
- }
3980
- if (!resolveExistingWorktreePath(bundle.branch, project)) {
3981
- return res.status(409).json({ error: 'This bundle does not have a prepared worktree yet.' });
3982
- }
3983
- const updatedProject = updateProjectActiveTarget(project.id, {
3984
- kind: 'bundle',
3985
- bundle_id: bundle.id,
3986
- });
3987
- return res.json(serializeProject(updatedProject));
3988
- }
3989
- const requestedBranch = typeof req.body?.branch === 'string' ? req.body.branch.trim() : '';
3990
- const createBranch = req.body?.create_branch !== false;
3991
- const confirmDirtySwitch = req.body?.confirm_dirty_switch === true;
3992
- if (requestedBranch) {
3993
- switchProjectBranch(requestedBranch, project, {
3994
- create: createBranch,
3995
- allowDirty: confirmDirtySwitch,
3996
- });
3997
- }
3998
- const updatedProject = updateProjectActiveTarget(project.id, {
3999
- kind: 'repo_root',
4000
- bundle_id: null,
4001
- });
4002
- return res.json(serializeProject(updatedProject));
4003
- }
4004
- catch (error) {
4005
- const message = getErrorMessage(error);
4006
- const status = message === 'Project root has uncommitted changes. Confirm branch switch to continue.' ? 409 : 500;
4007
- return res.status(status).json({ error: message || 'Unable to update the project target' });
3960
+ const result = updateProjectTargetSelection(req.params.id, req.body);
3961
+ if (!result.ok) {
3962
+ return res.status(result.status).json({ error: result.error });
4008
3963
  }
3964
+ return res.status(result.status).json(result.value);
4009
3965
  });
4010
3966
  app.get('/projects/:id/file-suggestions', (req, res) => {
4011
3967
  const project = getProjectById(req.params.id);